View Full Version : [FTC]: Encoders
astephen68
17-02-2009, 23:03
Does anybody have any sample code for encoders that i can take a look at. Thanks if you do.
Which language?
If you are using RobotC, this will work
nMotorEncoder[YOUR_MOTOR1_HERE] = 0;
nMotorEncoder[YOUR_MOTOR2_HERE] = 0;
nMotorEncoderTarget[YOUR_MOTOR1_HERE] = X_Distance;
nMotorEncoderTarget[YOUR_MOTOR2_HERE] = X_Distance;
motor[YOUR_MOTOR1_HERE] = 100;
motor[YOUR_MOTOR2_HERE] = 100;
Just substitute "YOUR_MOTOR1_HERE" and "YOUR_MOTOR2_HERE" for the names of the motors you are using, and then substitute "X_Distance" for the number of rotations you want to travel.
ttldomination
18-02-2009, 12:32
I don't think you need to do the motor[motorname] = 100;, I think the encoders already go to the target encoder positions.
Is that right?
You still need to motor[motorname] = 100;. nMotorEncoderTarget[] does not move the motor. It only set the target.
ttldomination
18-02-2009, 15:19
Oh..really...what happens when the encoders reach the target position?
The motors should just stop.
astephen68
18-02-2009, 22:43
I want to know how to use encoders on an arm in and out of autonomous. I have gotten it to go up but its not reconizing a second button in robotc what should i do
Can you post what code you have so far?
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.