Society of Robots - Robot Forum

Software => Software => Topic started by: razvanc_roro on June 05, 2007, 12:06:50 PM

Title: 50$ Robot> GO FORWARD!!!
Post by: razvanc_roro on June 05, 2007, 12:06:50 PM
Hi there!

I finnaly programmed it, modified servos and turned on! By magic, it worked!!! :D BUT :D It detects the left or right direction from which light is comming, it turn that direction, fronts the light and then, when it should go towards the source of light, it stops and doesn't do anything. And also noticed that servos doesnt work both in the same time (like for going straight). If I move the light, it's coming alive and "eye" follows the light and turn left or right corectly, but again, doesn't go towards the light... Hope I maked myself understandfull...
I don't know what to do next... I should modify some values in the program? What values should I "play" with?!?
Thank you!

Greetings from Romania,
              Razvan.
Title: Re: 50$ Robot> GO FORWARD!!!
Post by: Admin on June 05, 2007, 12:54:56 PM
lol thats odd . . . you should see this in your source code:

Code: [Select]
//light is about equal on both sides
else
{//go straight
servo_left(25);
servo_right(44);
}

Did you change any of the code?

(dont forget to post video/pics of your robot!)
Title: Re: 50$ Robot> GO FORWARD!!!
Post by: razvanc_roro on June 05, 2007, 12:57:40 PM
Yes, John! I left the same source code you offered. I don't know why those 2 servos doesn't work together. ???
I should modify the code or what?!?

I will soon post pics and videos with my robot, although you saw the pictures. :P
Title: Re: 50$ Robot> GO FORWARD!!!
Post by: Admin on June 05, 2007, 01:06:29 PM
hmmm this is odd . . .

so the servos dont budge at all when it tries to go straight - like any servo vibrations? are your batteries fully charged?

in the go straight section, try changing the 25 and 44 to different numbers and see what happens . . .

if still nothing, then try changing this line
int threshold=8;

to this
int threshold=30;

If none of this works, let me know . . .
Title: Re: 50$ Robot> GO FORWARD!!!
Post by: razvanc_roro on June 05, 2007, 01:30:59 PM
So, the battery are full charged (just a few times testing). When it must go straight (in darkness or in light) it just stay parallized :) , not moving at all. It may be the threshold?!? I will try everything you said. Hope it will work... somehow... :) Keep'n touch.
Thank you!
Title: Re: 50$ Robot> GO FORWARD!!!
Post by: dunk on June 05, 2007, 03:03:48 PM
try testing the voltage to the servos and the microcontroller as the bot runs with a multimeter if you have one.
make sure the power to the microcontroller isn't dropping too much. (called "browning out".)

dunk.
Title: Re: 50$ Robot> GO FORWARD!!!
Post by: razvanc_roro on June 05, 2007, 03:14:16 PM
Successfull !!!! Yaaay!!!! I've modified the code :
Quote
//light is about equal on both sides
else
   {//go straight
   servo_left(25);
   servo_right(44);
   }

with this one:
Quote
//light is about equal on both sides
else
   {//go straight
   servo_left(46);
   servo_right(23);
   }

and it does it's job now! :D Great (magic)!

Now... some "detail" that need to be fixed:
if I move the light and at the border between lightspot and darkness (this sound spooky :P ) the robot moves after it; but if I stop the spot and the brain says: in light: "(My left sensor)=(My right sensor)! Move forward!" and both photoresistors get into darkness, then he says the same thing: "(My left sensor)=(My right sensor)! Move forward!".
I wanna say that we must improve the contrast between lightspot and darkness, or power-up the sensitivity to light and independent of one eachother (the photoresistors)... Hope you understand what I mean.
I'll soon make a video on that, but sooner than friday night I can't. Until than I wanna ask you some suggestions on this issue.

Thank you!
Title: Re: 50$ Robot> GO FORWARD!!!
Post by: Admin on June 05, 2007, 05:07:50 PM
Yea I know what you mean, it drives straight into darkness if both sensors are equal.

There are two solutions:

The first (and easiest way) is to reduce the threshold. For example, threshold = 1. The lower the threshold, the less likely the robot will go straight.

OR

In the code you have to change it so it does something like:

If left_sensor + right_sensor = really_small_number //robot is in darkness
  then do something about it (like do a 180 to face the other direction);

You will have to tweak really_small_number until you are satisfied with it. Try 30 and see what happens.

When you get USB/serial added to your robot, it will be able to output the sensor data on your screen so you dont have to guess it. Im working on that tutorial . . . You can also use your LED to output information, for example, blink once if the sensor is 10, blink twice if the sensor is 20, three times for 30, etc.