go away spammer

Author Topic: 50$ robot - Ir mod - around and around it goes  (Read 3807 times)

0 Members and 1 Guest are viewing this topic.

Offline rabadswompeTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
50$ robot - Ir mod - around and around it goes
« on: March 29, 2011, 05:41:36 PM »
Well, I'm finaly there!

Got trouble with wiring...sorted.
Got trouble figuring out programming (loading everything needed) in AVR studio ... sorted
Got trouble because of low batteries... sorted

THEN I was able to upload the Sharp IR mod program in the Atmega8

Zoom

and round-round-round it goes.(like in admin's bloopers at the end of the IR o mod demo video. What causes this?

My guess (very uneducated) : It seems that during the calibration period, the robot fails to calibrate(?????????????).

Should I set an arbitrary value ????

advice please!
« Last Edit: March 30, 2011, 04:32:23 AM by rabadswompe »

Offline rbtying

  • Supreme Robot
  • *****
  • Posts: 452
  • Helpful? 31
Re: 50$ robot - Ir mod - around and around it goes
« Reply #1 on: March 29, 2011, 06:00:28 PM »
Use a multimeter to find the voltage that the sensor outputs at a known distance, multiply by (1024 / 5.00v), and use that as your 'set' value - see if that works properly.

Offline rabadswompeTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: 50$ robot - Ir mod - around and around it goes
« Reply #2 on: March 30, 2011, 04:30:34 AM »
I will do thy bidding my master.

red probe on the wire that connects to the atmega8, black on ground...right? while disconnecting power to servos so the whole thing stays still.

Thanks for your help.

intuitive learning is frustrating at first but when it takes off... the fun is worh it!

« Last Edit: March 30, 2011, 04:31:51 AM by rabadswompe »

Offline Conscripted

  • Robot Overlord
  • ****
  • Posts: 291
  • Helpful? 10
Re: 50$ robot - Ir mod - around and around it goes
« Reply #3 on: March 30, 2011, 01:55:01 PM »
I hope you get your bot working properly. I had a bit of trouble getting mine to work. I posted a thread a couple of years ago. http://www.societyofrobots.com/robotforum/index.php?topic=8371.0 I was finally able to get mine to work properly after adjusting the code a bit. I don't remember the exact changes I made and unfortunately my code was lost when my drive crashed. I know i had to adjust my scan_angle and max_scan_angle. I also adjusted how quickly the scanning servo moved by changing
Code: [Select]
if (sharp_IR_reading > scan_thresh)//object detected
{
if (scan_angle>41) //overflow protection
scan_angle-=2;//scan right
}
else //object not detected
{
if (scan_angle<=max_scan_angle) //maximum servo angle
scan_angle+=2; //scan left
to something like this.
Code: [Select]
if (sharp_IR_reading > scan_thresh)//object detected
{
if (scan_angle>41) //overflow protection
scan_angle-=1;//scan right
}
else //object not detected
{
if (scan_angle<=max_scan_angle) //maximum servo angle
scan_angle+=1; //scan left

I recommend unplugging your servo's and paying close attention to what the scan servo is doing. All the spinning will only prevent you from determining what is actually going on.

Good luck.
Conscripted

Offline rabadswompeTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: 50$ robot - Ir mod - around and around it goes
« Reply #4 on: March 31, 2011, 06:06:31 AM »
 :D ;D

I actually got it to follow an object! But the range seems short (about 3"). I'm currently playing with range values between the () where the code calls for autoscanning.

I'll check the code mods you posted Conscripted...thanks

Thanks also Rbtying!

Yann

Offline Conscripted

  • Robot Overlord
  • ****
  • Posts: 291
  • Helpful? 10
Re: 50$ robot - Ir mod - around and around it goes
« Reply #5 on: March 31, 2011, 07:12:13 AM »
The code I posted will only make the scan servo move slower. I used it when trying to figure out what was going on with my bot. After I got it working I restored it to the default values. I got to thinking about it and the problem I had was that my servo responded to much different values for scan angle. Once I adjusted those it worked like a charm. I'm glad you got it to follow an object. Which IR sensor are you using. When will you have a video?

Conscripted

Offline rabadswompeTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: 50$ robot - Ir mod - around and around it goes
« Reply #6 on: March 31, 2011, 08:23:43 AM »
I got a vid now but can't uploade it here at work... will post it tonight. Watch for it :)

I'm usig a sharp IR sensor from Robotshop.com (same thing as the tutorial).

Offline rabadswompeTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: 50$ robot - Ir mod - around and around it goes
« Reply #7 on: March 31, 2011, 05:38:11 PM »
here are a few pics of the finished 50$ robot with Sharp IR ... and 2 vids showing a "depth perception problem and and angle problem...I think.









as you can see...2 decks of plastic (obtained with a little dumpster diving, 2 tuna can tops, 2 brocoli elastics and some different length bolts and nuts.

here are the vids
1st : depth perception



Offline rabadswompeTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: 50$ robot - Ir mod - around and around it goes
« Reply #8 on: March 31, 2011, 05:42:04 PM »
next vid : scanning angle. The 2 modified servos were unplugged and I was both testing the range (I'd preffer a 30cm/12" range rather than what I have now) and angle left and right. This is a 180° servo unmodified. All batteries are fresh.



So... you noticed I'm a french canadian speaking english lol

Now... please direct me to solve the range and the angle.

thanks!

Yann
« Last Edit: March 31, 2011, 05:53:06 PM by rabadswompe »

Offline rabadswompeTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: 50$ robot - Ir mod - around and around it goes
« Reply #9 on: April 01, 2011, 02:50:25 PM »
really???? nobody knows how to extend the range of the sharpIR sensor????? It operates below the intended range...

no hints????

Offline rbtying

  • Supreme Robot
  • *****
  • Posts: 452
  • Helpful? 31
Re: 50$ robot - Ir mod - around and around it goes
« Reply #10 on: April 01, 2011, 03:40:29 PM »
You haven't posted any data - it would probably be helpful (you want five to ten data points, at known distances reasonably spread out (within the sensors range) and the corresponding voltages).

You should probably also tell us what sensor you're using, exactly.  There are a number of Sharp IR rangefinders, and the characterstic response curve is quite different between different models.

Realistically, I think you're thresholding at a distance that's too low.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: 50$ robot - Ir mod - around and around it goes
« Reply #11 on: April 01, 2011, 03:45:30 PM »
I'll take some guesses:

What are the voltages (or ADC values) you are getting from the Sharp?
Exactly which Sharp do you have? Post the full part number as they make four different ones with different ranges.

Set up a controlled test with a large object at measure distances and measure the voltage with a voltmeter. You don't need the processor for this, just supply 5V to the Sharp.
Does the voltage to distance match the graph in the data sheet?

The Sharp draws a large current when its switches on its LED. Try adding a cap right on the Sharp PCB at the connector pins. Try at least a 10uF preferably one with low ESR.

Offline rabadswompeTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: 50$ robot - Ir mod - around and around it goes
« Reply #12 on: April 01, 2011, 04:33:00 PM »
all my stuff is at work (yes, for real) but I'll get the measurements you mentinnend first thing monday!

Thanks for the hints! I really appreciate!

Yann

Offline rabadswompeTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: 50$ robot - Ir mod - around and around it goes
« Reply #13 on: April 02, 2011, 05:52:18 AM »
I went back to the website (www.robotshop.ca... who have an office 10mins away from my workplace  :)) where I bought the Sharp IR sensor. It's a  GP2D120XJ00F

here is what they say about the sensor :

• Infrared range finder 4cm (~1.5") to 30cm (~12")
• Supply voltage: -0.3 to +7V
• Analog interface
• Lead free, ROHS compliant

Read the distance of the object in front of your robot. The Sharp GP2D120 IR Range Sensor - 4 to 30 cm takes a continuous distance reading and reports the distance as an analog voltage with a distance range of 4cm (~1.5") to 30cm (~12"). The interface is 3-wire with power, ground and output. This sensor requires a JST 3-pin connector (RB-Lyn-164).






Offline rabadswompeTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: 50$ robot - Ir mod - around and around it goes
« Reply #14 on: April 04, 2011, 04:26:42 PM »
What are the voltages (or ADC values) you are getting from the Sharp?
Does the voltage to distance match the graph in the data sheet?
The Sharp draws a large current when its switches on its LED. Try adding a cap right on the Sharp PCB at the connector pins. Try at least a 10uF preferably one with low ESR.

the Ir gets 4.94V. At 20cm range, I get 0.68v. At 10cm I get 1.26v. At 4cm I get 2.58v.
Comparing to the pdf graph found in "useful links" here: http://www.robotshop.com/ca/sharp-gp2d120-ir-range-sensor-4-30-cm-2.html

It seems to all check out more or less... I'm using the wall as the target for the sensor.

any Ideas? Wiring is good, the sensor gets the gorrect amount of electricity, it reads distances... must be in the code ...right? And if so, where can it be ??????

Thanks

 

Offline rabadswompeTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: 50$ robot - Ir mod - around and around it goes
« Reply #15 on: April 04, 2011, 04:34:56 PM »
Realistically, I think you're thresholding at a distance that's too low.

I've tried , during auto calibration, to make it threshold farther but it doesn't want to. Where can I assign a fixed threshold value in the code? Ideally I'd like a 30cm fixed range all the time (no auto calibration).

Offline rbtying

  • Supreme Robot
  • *****
  • Posts: 452
  • Helpful? 31
Re: 50$ robot - Ir mod - around and around it goes
« Reply #16 on: April 04, 2011, 05:01:14 PM »
30cm fixed won't work - it's the absolute maximum range of the sensor, and readings will be highly unreliable.  Instead, try around 25cm.

A quick way to convert 10-bit (0-1024) ADC values to ranges that I regressed from your (rather few) data points:
Code: [Select]
     distance_cm = 7955 * (adcVal) ^ (-1.20) // ^ in this case is the exponent function, e.g., 4^3 = 4*4*4 = 64
     adcVal = 1681 * (distance_cm) ^ (-0.82)

Under these equations, a 25 cm threshold would be an ADC value of about 120. 

Assigning a fixed value is done like a variable: remove the autocalibration portion and replace it with something like this:

Code: [Select]
     scan_thresh = 120; // or whatever threshold value you pick.


Offline rabadswompeTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: 50$ robot - Ir mod - around and around it goes
« Reply #17 on: April 04, 2011, 05:46:45 PM »
thanks.... 1000 thanks!

I only took a few readings just to compare to the chart in the manual... but if you tell me to take a reading for every 2cm of range, I'll do it. I swear I'll do it.

I'll try to mod the code with the 120 value tomorrow (the ARV studio, the avr isp mk2 and everything else being at work).

I'll post for sure tomorrow evening.

Again  thanks for the guidance and help.

Yann

Offline rbtying

  • Supreme Robot
  • *****
  • Posts: 452
  • Helpful? 31
Re: 50$ robot - Ir mod - around and around it goes
« Reply #18 on: April 04, 2011, 06:53:33 PM »
The process for deriving the equation is detailed here, and is quite simple if you know how to use Excel (or any other spreadsheet program). 

You will want to use around ten readings, ranging from, say, 3cm to 33cm, such that you have enough data to be confident in your regression.  If you post your data up on these forums, we'll make our best efforts to find the equation for you, but knowing how to do it yourself is invaluable. 

Offline rabadswompeTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: 50$ robot - Ir mod - around and around it goes
« Reply #19 on: April 04, 2011, 06:57:24 PM »
I'll get  to work doing this tomorrow pm and show my findings.


Offline rabadswompeTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: 50$ robot - Ir mod - around and around it goes
« Reply #20 on: April 04, 2011, 07:30:46 PM »
couldn't let it go... I had to get the values before going to bed.

I got 15 readings from 4 to 32cm (every even number) .

Will work on the values (on excell)  tomorrow...
« Last Edit: April 04, 2011, 07:37:15 PM by rabadswompe »

paulstreats

  • Guest
Re: 50$ robot - Ir mod - around and around it goes
« Reply #21 on: April 05, 2011, 03:41:49 AM »
Everybody is assuming that the program uses 10 bit adc. The sharp IR mod actually uses 8 bit adc, so please ensure that any numbers given are set to reflect this.

I would suggest commenting out this

autocalibrate();

in the main routine. do this to comment it out.
//autocalibrate();

now underneath write

scan_thresh=30;

this should set your scan threshhold to scan for objects between about 4cm to 22cm.

If you still have problems then I would suggest that it isnt to do with the program. (dont waste time graphing your sensor output, you already verified that it is working. This is a very simple program and does not require spending time graphing sensor data).

 You say that the Sharpir is recieving just under 5v. Does this mean that it is being powered through the regulator? I noticed in the pictures that you went for the 9v battery option to power the regulator, I dont think that 9v option is providing enough power for both the microcontroller and the led bursts from the Sharp IR, I would recommend powering the Sharp some other way if you can. If your main battery pack is producing about 7v then just feed the regulator from that and remove the 9v battery altogether.

Offline rabadswompeTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: 50$ robot - Ir mod - around and around it goes
« Reply #22 on: April 05, 2011, 10:39:27 AM »
I would suggest commenting out this

autocalibrate();

in the main routine. do this to comment it out.
//autocalibrate();

now underneath write

scan_thresh=30;

this should set your scan threshhold to scan for objects between about 4cm to 22cm.

If you still have problems then I would suggest that it isnt to do with the program. (dont waste time graphing your sensor output, you already verified that it is working. This is a very simple program and does not require spending time graphing sensor data).

Well... it worked wonders! now the robot tracks and follows an object no problem.

Is there a good book on the language "C" used in this programm ????? I'm a dinosaur, i know, but reading a book, underlining in it... I feel I'd learn the language quicker.

Will post a vid of the robot doing it's thing tonight!

@rbtying : don't worry, I'll do the graph so I can learn!

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: 50$ robot - Ir mod - around and around it goes
« Reply #23 on: April 05, 2011, 11:47:16 AM »
There is really only one book on C, the "C Programming Language" by K & R.
http://en.wikipedia.org/wiki/The_C_Programming_Language
http://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628

I have a first edition I bought over 30 years ago and still refer to it.
On-line there is:
http://publications.gbdirect.co.uk/c_book/



Offline rabadswompeTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: 50$ robot - Ir mod - around and around it goes
« Reply #24 on: April 05, 2011, 12:32:40 PM »
you mean I get this book 4 free??? Sweet!

making this robot only got my interest spiked on understanding the language better... Skills were developped, got familiarized with tools, terminology...

a great experience!

Already thinking about "the next one" lol

Offline rabadswompeTopic starter

  • Jr. Member
  • **
  • Posts: 43
  • Helpful? 0
Re: 50$ robot - Ir mod - around and around it goes
« Reply #25 on: April 05, 2011, 04:23:54 PM »
here's the vid of the 50$ robot contructed strait to Sharp IR mod with lots of forum members' help!

The autocalibration has been edited out and a value of 30 has been given as a threshold. Works great!


 


Get Your Ad Here

data_list