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.

OK, so assuming your sensor board is OK, it's time to test the motor shield.  Can you write a sketch that would, send a series of commands to the motors?  Turn them on and off, vary their speed, make them work in tandem or individually?

#include <AFMotor.h>

 

AF_DCMotor motor_left(1);

AF_DCMotor motor_right(3, MOTOR12_1KHZ);

 

void setup() {

  motor_left.setSpeed(200);

  motor_right.setSpeed(200);

}

 

void loop() {

  motor_left.run(FORWARD);

  motor_right.run(FORWARD);

  delay(1000);

  motor_left.setSpeed(0);

  motor_right.setSpeed(0);

 

  delay(1000);

  motor_left.run(BACKWARD);

  motor_right.run(BACKWARD);

  motor_left.setSpeed(200);

  motor_right.setSpeed(200);

  delay(1000);

  motor_left.setSpeed(0);

  motor_right.setSpeed(200);

  delay(1000);

  motor_left.setSpeed(200);

  motor_right.setSpeed(200);

}

Ran this up, and the bot successfully made a cross type movement.  But, unfortunately one of my sensors has broke, the emitter of sensor 1.  So, I'm going to try to write LMR with it instead.  I have an extra Servo motor.  Have an idea of what to do until I get another sensor.  So I am going to mark this bot as Successfully completed.  THANK YOU ALL, for all the help.  Appreciate the quick responses and tips!

**EDIT- ok, I just may have had an epiphany and well also re-read the code.  The motors are supposed to be attached to the DC motor input.

sensor 1:  55  -  Adj 1:  0  -  sensor 2:  366  -  Adj 2:  56  -  sensor 3:  984  -  Adj 3:  255  -  sensor 4:  985  -  Adj 4:  255  -  sensor 5:  975  -  Adj 5:  255 speed:  236 

sensor 1:  42  -  Adj 1:  0  -  sensor 2:  328  -  Adj 2:  43  -  sensor 3:  975  -  Adj 3:  255  -  sensor 4:  614  -  Adj 4:  140  -  sensor 5:  454  -  Adj 5:  86 speed:  167 

sensor 1:  40  -  Adj 1:  0  -  sensor 2:  354  -  Adj 2:  52  -  sensor 3:  809  -  Adj 3:  207  -  sensor 4:  677  -  Adj 4:  162  -  sensor 5:  324  -  Adj 5:  42 speed:  121 

sensor 1:  43  -  Adj 1:  0  -  sensor 2:  970  -  Adj 2:  255  -  sensor 3:  296  -  Adj 3:  32  -  sensor 4:  804  -  Adj 4:  205  -  sensor 5:  371  -  Adj 5:  58 speed:  106 

sensor 1:  61  -  Adj 1:  0  -  sensor 2:  980  -  Adj 2:  255  -  sensor 3:  365  -  Adj 3:  56  -  sensor 4:  987  -  Adj 4:  255  -  sensor 5:  980  -  Adj 5:  255 speed:  182 

sensor 1:  68  -  Adj 1:  0  -  sensor 2:  983  -  Adj 2:  255  -  sensor 3:  325  -  Adj 3:  42  -  sensor 4:  987  -  Adj 4:  255  -  sensor 5:  980  -  Adj 5:  255 speed:  211 

 

Can actually see me moving the cardboard with tape now.  So it is working and the flucuations are good.  But, I'm measuring the motor shields Servo connections while moving the cardboard, and there is change in the voltage going to the motors.  So it would still continue on a straight path.  Doesn't make sense.  I feel like I have checked EVERYTHING on the boards.  Everything has either power and/or continuity.  Am I missing something??  Appreciate all the help so far.

 

**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.

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.

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

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!

 

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.

 

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.