Let's Make Robots!

Robot Problem(s) (SOLVED)

I am having an issue with both my sensors and my potentiometer, that's why I labeled as "problem(s)" because I'm thinking they may be inner twined.  You can check my robot post for connections and some more information: http://letsmakerobots.com/node/30291.  If you need anymore information I will gladly post.

My sensors are reading:


sensor 1:  124  -  Adj 1:  0  -  sensor 2:  0  -  Adj 2:  0  -  sensor 3:  10  -  Adj 3:  0  -  sensor 4:  0  -  Adj 4:  0  -  sensor 5:  0  -  Adj 5:  0 speed:  25 

sensor 1:  109  -  Adj 1:  0  -  sensor 2:  0  -  Adj 2:  0  -  sensor 3:  9  -  Adj 3:  0  -  sensor 4:  0  -  Adj 4:  0  -  sensor 5:  0  -  Adj 5:  0 speed:  25 

sensor 1:  84  -  Adj 1:  0  -  sensor 2:  0  -  Adj 2:  0  -  sensor 3:  9  -  Adj 3:  0  -  sensor 4:  0  -  Adj 4:  0  -  sensor 5:  0  -  Adj 5:  0 speed:  25 

sensor 1:  79  -  Adj 1:  0  -  sensor 2:  0  -  Adj 2:  0  -  sensor 3:  9  -  Adj 3:  0  -  sensor 4:  0  -  Adj 4:  0  -  sensor 5:  0  -  Adj 5:  0 speed:  26 



The serial reading is supposed to show what the sensors are seeing and show the adjustments they're making.  My problem is they're either not reading anything or they're trying to adjust, but the wheels continue(When they are trying to adjust, the numbers are outrageous.)  This reading was taken with a piece of white cardboard with black electrical tape under the bot.  When i use the potentiometer, the wheels are not slowing down.  The serial output shows the adjustment of the potentiometer, but the wheels continue full throttle.  I'll greatly appreciate any ideas or nudges in the right direction.  Thanks in advanced!


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

the problem could be in the code itself. can you post that?

I wasn't going to post all of the code...but then I couldn't figure out which would be the most important.





Some tips

1. Check the sensor values without the motors. Plug them out.

2. Check the IR LEDs of the sensors with a Digi cam. They should be glowing pink or purple.

3. The card board should be placed as close as possible to the sensors, between 1..5mm

Your code looks ok at first sight.

Edit--OK, I see by your code that it's a line follower.  Can you run some example code to test your motor shield?

I see what seem to be some IR emitter/detector pairs.  Are they obstacle sensors?  Can you post your circuit?  Or at least one emitter/detector pair?  (I don't have the book you mentioned.)  And I see you're running off of an adafruit motor shield.  I'm guessing your sketch controls the motors according to levels from the IR detectors.  Your post seems to be a chart or matrix of conditions and results.  But I'm not sure what you're expecting.  Or getting for that matter.

Did you breadboard this circuit before commiting it to your perfboard so you could test it and become familiar with its operation?  Your first step should be to lay it out on a breadboard, apply power, test it and check the levels you get.  Then when you understand how it works, connect it to an Arduino and run some test code.  When it all works, THAT'S when you build your board.  When it doesn't work--you know what to look for or maybe you can even compare it to your test bed.

At this point, you could be chasing solder shorts or opens.  Dead or degraded components.  Possibly bad code.  I'd start by getting the motor shield out of the way and hang LEDs off the Arduino outputs instead.  If you can turn them on and off or change their brightness then you know if your sensors and code are working.

If that doesn't work, then test your sensor array, disconnected from the Arduino.  Do ANY of the branches work the way you're expecting?  To test your sketch, you could use switches, if you're testing logic levels, or a potentiometer as part of a voltage divider to get an analog level, and LEDs on your outputs, as I described earlier.

Right now, it could be your sensors, motors, code or construction. I think we may need to simplify and isolate. First off, do the sensors work? As mentioned above, check them with a digital camera and be sure they are glowing. If so, I would stop using the code you are using now and instead, write a simple sketch that A) reads the sensors and B) sends the values to the serial monitor. No "adj", no mapping the values, no motors, etc --Just read the sensors and get the numbers. Assuming that you are getting numbers from your sensors, you can move on. I would suspect that this is a hardware issue.

You can do one better and even write some more simple code --Write a sketch that simply reads one ADC and sends it to the serial monitor. If this works, try it with your black stripe and white background and see if the numbers change and if they make sense. Go from there.


I tore the whole bot apart and I'm going to test piece by piece.  At this point I am testing the IR emitter/detectors.  I looked at them via a digital camera and I see the lights on the IR emitter's, but when I ran it straight to the Arduino board, I get:


sensor 1:  98  -  Adj 1:  0  -  sensor 2:  0  -  Adj 2:  0  -  sensor 3:  0  -  Adj 3:  0  -  sensor 4:  0  -  Adj 4:  0  -  sensor 5:  0  -  Adj 5:  0 speed:  5 

sensor 1:  98  -  Adj 1:  0  -  sensor 2:  0  -  Adj 2:  0  -  sensor 3:  0  -  Adj 3:  0  -  sensor 4:  0  -  Adj 4:  0  -  sensor 5:  0  -  Adj 5:  0 speed:  5 

sensor 1:  96  -  Adj 1:  0  -  sensor 2:  0  -  Adj 2:  0  -  sensor 3:  0  -  Adj 3:  0  -  sensor 4:  0  -  Adj 4:  0  -  sensor 5:  0  -  Adj 5:  0 speed:  5 

sensor 1:  93  -  Adj 1:  0  -  sensor 2:  0  -  Adj 2:  0  -  sensor 3:  0  -  Adj 3:  0  -  sensor 4:  0  -  Adj 4:  0  -  sensor 5:  0  -  Adj 5:  0 speed:  4 



So it seems that the sensors aren't outputing anything.  I checked it up againts a the white cardboard and black electrical tape again and sensor 1 didn't even change.  Though sensor one seems to be the only one outputing...it's not giving me anything significant. 


**Edit:  HA, sensor 1, of all sensors wasn't connected at all, but it was the only one outputting, funny and odd at the same time!


Can you measure the change in voltage from sensor 1 where it goes into the Arduino when you swipe the white card and tape?

Like Calculon320 said: "First bot is where you learn to diagnose."  I already started desoldering the board and I'm just going to redo the whole thing.  But, when and if I have an issue again, I will definetly do that!  Appreciate the tip anyway.

**EDIT--WOOHOOO, found a dumb solder, was a ground I am getting a reaction now, WOOT.  About time.  lol, now I have to finish this damn board and check my motor shield!  Thanks for ALL the tips, will post on my motor shield when I get to it!


Alright, Danceswithrobots, I hooked up a sensor and I'm not getting arbritary numbers, 1023, whether there is tape or no tape.  Though when I measured the voltage I'm getting 4.80 with tape and 4.85 without.  So it is registering, but I don't know if that is significant enough or not.  So I'm getting more and more lost as I go, lol.

Good catch with your soldering mistake!

OK, now that you're getting some response, your circuit apparently works, but needs to be tweaked.

Hmm. . .I'm wonderring if ambient light is overloading your detector.  Can you shield it from room light somehow? Also, is your detector part of a voltage divider, or bias your detector, (phototransistor?) somehow?  Try changing the value of the resistor, or replace it with a potentiometer.  You want to get a nice big change in voltage when switching between light and dark.

Edit--if you change the value of a resistor in order to get a bigger voltage swing, you want to make sure that it never goes above 5 volts before connecting it to the arduino again.  Probably not an issue, but I wanted to be clear on that.