Rotary encoders#
The enc2 tile carries two rotary encoders, each with a push-to-click shaft. Use them for continuous values — arm setpoint, shooter speed, LED brightness on the robot.
What the Driver Station sees#
FRC. Each encoder can be bound to one of four axes. The axis reports an accumulated position — turn it clockwise and the number goes up, keep turning and it keeps going. There are four axes in total, so two enc2 tiles claim all of them.
An axis does not spring back to centre and has no deadzone.
Scale sets how far one click moves the axis. The default, 256, makes every click one step your robot code can see; smaller values need several clicks before anything changes. At 256 the axis reaches its end after about 128 clicks, around six turns of a typical knob. Pick a larger scale for a knob that should reach the end in fewer turns. Changing the scale zeroes the position.
FTC. Under xinput an encoder becomes pulsed buttons instead: one button pulses per detent clockwise, another per detent anticlockwise, and your OpMode counts them.
Pulsed buttons are available under frc too, if you would rather count clicks than read a position.
The shaft push#
The push switch on each encoder is an ordinary key. Bind it like any other key to a logical button number.
Zeroing#
The board can zero any axis, or all of them, on command — at the start of a match, or when the mechanism it drives is homed.