Author Topic: Roboduino IR  (Read 6204 times)

0 Members and 1 Guest are viewing this topic.

Offline Adityav95Topic starter

  • Full Member
  • ***
  • Posts: 64
  • Helpful? 0
Roboduino IR
« on: April 01, 2011, 02:39:46 AM »
Hey,

I'm building a robot with 3 hitec hs-425bb, a sharp ir and obviously the roboduino as mentioned. I want to build a robot similar to the $50 robot with ir { http://www.societyofrobots.com/robot_50_robot_sharpIR.shtml }.

Q.So it would be very helpful if someone could help me with the code or alt least provide the pseudo code.

Q.I'm using the arduino software. Is that fine or should i use something else. I don't have a hardware programmer and I'm not planning to buy one.

Thnx a lot!

Offline hopslink

  • Robot Overlord
  • ****
  • Posts: 202
  • Helpful? 14
Re: Roboduino IR
« Reply #1 on: April 01, 2011, 04:43:39 AM »
Quote
...it would be very helpful if someone could help me with the code or alt least provide the pseudo code.
Better still - airman00's complete tutorial. It's always worth a read/search round the site ;)

Quote
I'm using the arduino software. Is that fine or should i use something else. I don't have a hardware programmer and I'm not planning to buy one.
Arduino software is fine. You can also use Webbotlib. You don't need a programmer with Webbotlib/AVRStudio. Just grab a simple front end for AVRDude and you can burn a compiled .hex file to an Arduino as a one click operation, after some simple setup. You can also run AVRDude from the command line to do the same. 


Offline Adityav95Topic starter

  • Full Member
  • ***
  • Posts: 64
  • Helpful? 0
Re: Roboduino IR
« Reply #2 on: April 01, 2011, 10:34:11 PM »
Quote
Better still - airman00's complete tutorial. It's always worth a read/search round the site

But isn't that for the photovore and not IR?? i'm plannin to use a sharp ir.

Offline hopslink

  • Robot Overlord
  • ****
  • Posts: 202
  • Helpful? 14
Re: Roboduino IR
« Reply #3 on: April 02, 2011, 03:18:51 PM »
Quote
But isn't that for the photovore and not IR?...
You are right, my apologies  :-[. However that code will still get you most of the way since you need to operate drive servos and read analogue inputs with a sharp IR. By comparing the original $50 robot code with airman00's code you should be able to see the changes made to adapt the $50 code to the Roboduino. Then you can modify the roboduino $50 code to match the $50 IR code. Read all three sets of code and try to get a handle on how they work. If you get stuck then give a shout.


Offline greasemonkey94

  • Jr. Member
  • **
  • Posts: 29
  • Helpful? 1
Re: Roboduino IR
« Reply #4 on: April 04, 2011, 11:24:10 AM »
If you want to do edge detection, then you can find the pseudo code here-->http://www.societyofrobots.com/robot_sumo.shtml

pseudo code (taken from above link)

//scanner code
if sharp IR detects object
    scanning IR turns left
else //no object detected
    scanning IR turns right

//robot motion code
if scanner is pointing far left
    robot turns left
else if scanner is pointing far right
    robot turns right
else //scanner pointing forward
    robot drives straight


read through the entire thing to understand it fully .

hope this helps

Offline Adityav95Topic starter

  • Full Member
  • ***
  • Posts: 64
  • Helpful? 0
Re: Roboduino IR
« Reply #5 on: April 06, 2011, 12:06:50 AM »
thnx a lot guys, just hope i can get it to work!

Offline Adityav95Topic starter

  • Full Member
  • ***
  • Posts: 64
  • Helpful? 0
Re: Roboduino IR
« Reply #6 on: April 06, 2011, 01:18:35 AM »
guys,
in these .zips  there r lots of different file types like a .c .h .hex, what do i do with them?? which ones do i upload or program??
I have really no idea.

and for the link provided by hopslink (the airman00 tutorial:programming the bot), how do u use the bootloader instead of an ISP programmer? it says bootloader to be written soon...

Thnx in advance
« Last Edit: April 06, 2011, 01:21:32 AM by Adityav95 »

Offline hopslink

  • Robot Overlord
  • ****
  • Posts: 202
  • Helpful? 14
Re: Roboduino IR
« Reply #7 on: April 06, 2011, 05:47:29 AM »
The code for upload is the .hex file.

To use the bootloader download the front end for AVRDude that I linked to in my post above. When you launch it you simply browse for the .hex file you want to upload and select the correct port and baud rate for the Arduino. If this uses the Duemillenove bootloader then you want 57600 for baud rate, and 115200 for the later Uno. Then click to upload. Simple.

You can do the same yourself from the command line\terminal, but you will need to read the options for AVRDude.

Offline Adityav95Topic starter

  • Full Member
  • ***
  • Posts: 64
  • Helpful? 0
Re: Roboduino IR
« Reply #8 on: April 24, 2011, 04:49:59 AM »
@hopslink: 1) So to use the bootloader, the hex file and the front end should i use AVRstudio or arduino IDE?

2) Another thing...when i use arduino i usually use the the diecimila/duemilanove option so not sure which one it is. So which baud rate do i use??

3) What does the reset button on the roboduino do? if i use it will i lose the bootloader?

4) i got the following error recently on the arduino software....did some research but learnt nothing...does it mean my bootloader is corrupted?? pls help
 {avrdude: stk500_getsync(): not in sync: resp=0x00
   avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51}

Thnx a lot for being patient with me....it really helped a lot.

Offline hopslink

  • Robot Overlord
  • ****
  • Posts: 202
  • Helpful? 14
Re: Roboduino IR
« Reply #9 on: April 24, 2011, 08:24:49 AM »
Quote
1) So to use the bootloader, the hex file and the front end should i use AVRstudio or arduino IDE?
For the code you are using you would use AVR Studio as in the tutorial. When you have successfully built your code run Xloader and browse to the AVR Studio project folder for the .hex file.

Quote
2) Another thing...when i use arduino i usually use the the diecimila/duemilanove option so not sure which one it is. So which baud rate do i use??
If you are using the due/deci option in Arduino then use 57600.

Quote
3) What does the reset button on the roboduino do? if i use it will i lose the bootloader?
If you press the reset button the Roboduino stops and runs it's normal startup sequence. The bootloader always runs first, and then whatever code you last uploaded is run from the beginning. There is a reset triggered every time you connect to the Roboduino via the USB port. The bootloader is not lost, it sits right at the end of the program memory and is protected from being overwritten.

Quote
4) i got the following error recently... ...does it mean my bootloader is corrupted??
It is possible the bootloader is corrupted but it is much more likely to be a communications error. Does it happen all the time? 

Offline rbtying

  • Supreme Robot
  • *****
  • Posts: 452
  • Helpful? 31
Re: Roboduino IR
« Reply #10 on: April 24, 2011, 10:04:58 AM »
i got the following error recently on the arduino software....did some research but learnt nothing...does it mean my bootloader is corrupted?? pls help
 {avrdude: stk500_getsync(): not in sync: resp=0x00
   avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51}


This error usually means the bootloader didn't run - did you hit the reset button the moment before starting the upload?  The Arduino IDE does this for you, but avrdude doesn't, unless specifically told to. 

For simplicity's sake, if you don't actually understand the C code used to generate the hex files, you'd probably have been better off starting from the Arduino IDE and writing your own program - it would also give you a working toolchain for the code/compile/upload/test process.

Offline Adityav95Topic starter

  • Full Member
  • ***
  • Posts: 64
  • Helpful? 0
Re: Roboduino IR
« Reply #11 on: April 24, 2011, 10:51:06 PM »
@hopslink: actually this is the first time and happened only in my friends place but it kept happening on his comp for some reason...

@rbtying: Nope i didn't hit any reset button...i just wrote some code which worked earlier and hit upload on arduino IDE but now it gave me this error. BTW what is a working toolchain?? :( I know i've been trying to write my code for the bot but i miss out a lot of key things in it so it didn't work well, that made me resort to this and simultaneously learn some code....

thnx a lot guys...

Offline rbtying

  • Supreme Robot
  • *****
  • Posts: 452
  • Helpful? 31
Re: Roboduino IR
« Reply #12 on: April 25, 2011, 01:55:09 AM »
Try to upload the "blink without delay" example in the Arduino IDE, both with and without pressing the reset button the moment before hitting upload.  It may take some fiddling (possibly a lot of fiddling, although probably not) in order to get it to work - the auto-reset's not the most reliable thing on the board.  Since this problem only occurs on your friend's computer, it's possible that the DTR pin isn't being set properly on the FTDI (due to some driver malfunction or something). 

It is far more rewarding to learn how to program in C (via the Arduino IDE or not) than it is to upload somebody else's binary - the best part of making a robot is programming it, after all (Personal opinion xD).  If it helps, the Servo library built into the Arduino handles all the servo code for you (you just feed it a value between 0 and 180, with 90 being 90 degrees or stopped, if it's modified for continuous rotation).  The analogRead method will give you 10-bit voltage readings from an ADC pin, which you can use to determine distance. 

A 'toolchain' is the basically the system that compiles your code, links it against existing libraries, and deploys it to your target.  The Arduino IDE should handle all of that in the background for you - you won't even see it.  It's what runs when you click 'upload'.

Offline hopslink

  • Robot Overlord
  • ****
  • Posts: 202
  • Helpful? 14
Re: Roboduino IR
« Reply #13 on: April 25, 2011, 02:17:38 AM »
Does your friend have an Arduino board that works with his Arduino software? It may be any of a number of causes including missing/wrong FTDI drivers, wrong board selection, wrong COM port... see the Arduino troubleshooting page for things to try.

If the error happens on his computer and not on yours then the issue is somewhere on his computer, and not on the Roboduino.

Agreed - you will get much more out of this if you learn to code, and program this for yourself as rbtying suggests. 

Offline Adityav95Topic starter

  • Full Member
  • ***
  • Posts: 64
  • Helpful? 0
Re: Roboduino IR
« Reply #14 on: April 26, 2011, 03:09:15 AM »
@rbtying: yup sure i'll just give that a go. I know that programming is fun but the thing is i have no basic knowledge of C/C++....so it might take time to learn...

@hopslink: The thing is 4 of us have pooled in cash and working on this robot and he doesn't have another arduino board...yea it doesn't happen on my comp at least not yet...

thnx a lot guys.
ADITYA

Offline Adityav95Topic starter

  • Full Member
  • ***
  • Posts: 64
  • Helpful? 0
Re: Roboduino IR
« Reply #15 on: April 26, 2011, 04:21:26 AM »
Another problem...I got no idea how or what to convert in this code: http://www.societyofrobots.com/downloads/robot_source_50_sharpIR_v1.zip
to make it compatible with roboduino and my sharp GP2D12 IR.

Forget writing my own code as of now....i read the code mentioned above and found it really challenging.  :( So for now i have gotta use the above code only.

I guess i need to make changes due to the fact that i'm using an ATmega168 and not an ATmega8 and the fact that i might be using different pins on the board itself. Am i right in this aspect? IF i am then pls let me know how do i make changes? ???

I figured out(according to this: http://www.societyofrobots.com/step_by_step_atmega168_swapout.shtml ) that if u change atmega8 to atmega168 in code and change timer.c and timer.h to timerx8.c and timerx8.h and put in the the new timerx8.c and .h  and the global.h from http://www.societyofrobots.com/downloads/sbs_source_photovore_v1.zip .....then it ought to work. Is that right??  ??? pls help!!

Thnx a lot. :)
« Last Edit: April 26, 2011, 04:52:06 AM by Adityav95 »

Offline rbtying

  • Supreme Robot
  • *****
  • Posts: 452
  • Helpful? 31
Re: Roboduino IR
« Reply #16 on: April 26, 2011, 08:26:45 PM »
Another problem...I got no idea how or what to convert in this code [...]

This is why you should be trying to write your own code.  My last post here gives example code for an Arduino and a Sharp GP2D12. 

Arduino code is much easier to understand than base ATMega code because it's been abstracted to a higher level by the various libraries given.  You are making your own life harder, at least for now, by trying to understand reasonably complex low-level code when you aren't experienced enough with the language. 

[...] Forget writing my own code as of now....i read the code mentioned above and found it really challenging.  [...]

This is why you should start with simpler code and work up - if you're having trouble reading Admin's code, it makes more sense to try making your own with the help of the Arduino libraries than to work with "challenging" code.

 


data_list