Tracking distance

We have a robot that performs some operations in Autonomous. the problem we encounter is that all the moves are based on time. Do anyone have a suggestion as to how to track distance or number of turns of a shaft to track distance. At present the program works great only when the battery is at a certain level. If the battery is fully charged it moves to fast and when it gets to weak the distance and turns lag.

We are using Easy C4 Cortex for programming.

these count rotations of a shaft:
http://www.vexrobotics.com/vex/products/accessories/sensors/276-2156.html
these replace the green cap on the back of a motor and messure rotations that way:
http://www.vexrobotics.com/vex/products/accessories/sensors/276-1321.html

If I use the shaft encoder, must I use both input lines to get my results. Also, is it possible to use 2 encoders at one time so that I can regulate the speed that each shaft is turning, or can I only regulate one distance at a time. The reason I ask is because the motors don’t seem to run at the same speed and the robot tends to turn as it moves.

I would suggest going with both wires of you want to know the direction of travel.

All sensors can be viewed at once. Its just like any other variable.

In addition, your turning problem could be fixed with some “clever” drive straight programming if you have an encoder on each side of the chassis.

However, if it is a mechanical reason for the drifting you will want to get that fixed. Otherwise you are just stressing your motors more than necessary.

This past weekend we tried to use the quad shaft encoder to run in our autonomous program. Very limited success. The attached image is what code we are trying to test it with. The first part works, it does it’s first operation but then just sits there. What is wrong with the code. It is in Easy CV4 for cortex, version 4.2.1.7
Capture1.jpg

The first tick through the second while loop the variable is updated with the sensor value which is greater than 200 thus ending the while loop.

Resetting the variable like you do only is doing anything for 1 tick. Either reset the sensor as well or make the while loop into something like this

while(right_encoder<original_right_encoder+100)