Encoders Not Working


The following code runs the motors for over 1000 counts (based on the debugger window), when it should only be running them for 200. We’ve tried using the right and left encoders in while loop condition, but it did not make a difference. Again, we can see the encoders counting past 1000 in the debug window before the motors shut off. Both encoders seem to be working because we manually roll the robot and watch the numbers count in the debug window. Does anyone see a problem in the code below?


SensorValue [flEncoder] = 0;

while(SensorValue[flEncoder] < 201)
motor[brdriveMotor] = 127;
motor[frdriveMotor] = 127;
motor[fldriveMotor] = 127;
motor[bldriveMotor] = 127;

I assume that you stop the motors after running them at full speed in the while loop.
The robot will take some time to actually come to a stop after you send 0 power to the motors. Depending on how heavy the robot is, it will continue to move (and the encoders continue to count) for a few inches.