07-04-2010 01:34 PM
Hi everybody.
I'm building a line following robot for an extracurricular program. The robot uses two light sensors, one on either side of the line. My team members and I programmed it so that the light sensor readings are tied directly to the motor outputs. For example, if the left sensor returns a low value (it is on the black line) then the left motor will slow down to compensate. Motors spin fastest when their respective sensor is returning a high (white) output.
This strategy works extremely well, even on tight turns. Also, the robot is in constant motion. It does not jitter or shake at all.
The problem arises when the robot encounters a sharp, square turn. Absolutely black values on both sensors will cause both motors to stop and leave the robot in an infinite loop. The grey dots in the picture below represent sensors, and the red arrow represents the direction of motion. I want the robot to recognize which direction it began to turn before both sensors are met with black values and keep turning in that direction until it can resume its path.
I thought that perhaps I could somehow record the accelerations of the motors and store the values in variables. That way, when the robot encounters a situation like this, it could recall whichever motor had a greater acceleration and continue to turn that motor.
Is there any other way that I could get the robot to 'remember' which way it started to turn?
Thank you.
07-08-2010 08:23 PM
Hi studentuser,
I do not believe that there is a straight forward way to read the acceleration of each motor, however, you may be able to find a workaround. For example, when you detect that both light sensor are seeing black, you can reset the rotation counters on each motor. Then, after some specified amount of time, you can read the rotation of each motor to determine which motor rotated the most. This would indicate which direction the robot was turning.
Aaron P
National Instruments
Applications Engineer