I was wondering how to program encoders so I can move forward a certain distance.
Announcement
Collapse
No announcement yet.
How to use Encoders
Collapse
X

Originally posted by 3805Mentor View PostDid you get error messages? Did the program run? Did all the telemetry statements appear on the Driver station?
Comment

Originally posted by FTC12676 View Postset motor mode to RUN_TO_POSITION
Set target  encoder pulse count  you will have do math to convert distance to pulses based on wheel dia and gear ratio
set power
thats it
Comment

Originally posted by 3805Mentor View PostAs he said in his post, you do the math. Look up how many encoder counts per revolution for the motor. In one revolution the wheel will move the robot the circumference of the wheel, which you can compute from the diameter. If geared, adjust for the gear ratio.
Comment

Sorry, that last message interrupted by my cat typing on the keyboard. Not sure why sometimes you can edit a message and sometimes (like this time) you can't. I meant to say
You would need to subtract the length of your robot if you are doing this on the inside of the field, as you are not actually moving the full 144 inches.
Comment

Better idea could be place a mark or draw line with marker where robots front wheel touches tiles and drive straight ( this is key) to 34 tiles across and mark another line where now front wheels touches the tiles. Now measure the distance between two marks. While doing this use telemetry to record initial wheel position and final wheel position. Now subtract final wheel position from initial wheel position from telemetry and divide it by distance travelled in inches. That will give you count per inches.
Comment

The sample program PushbotAutoDriveByEncoder_Linear should do exactly what you are looking for.
The calculations are all there to drive your entered number of inches  You may just need to change the 3 constants at the top to match your specific motor ticks, gear ratio, & wheel diameter.
Comment
Comment