Predict, then test
- For 12 motor turns, a 6:1 motor-to-output reduction, and a 0.1 m pulley, predict output turns and travel.
- Change encoder polarity. Explain why the sign reverses without changing the pulley size.
- Challenge: enable active-low wiring. Which raw electrical state means pressed? Set it, record home, then change motor turns and interpret the distance relative to home.
Assume a non-slip pulley, a constant effective diameter, and an encoder that reports motor revolutions. Ratio means motor turns per output turn. This model has no debounce, switch fault detection, cable stretch, or mechanical limits. A homing sequence on hardware needs a mentor-reviewed safe direction, speed and travel limit.
Inputs
Conversion and reference
Model
output turns = (motor turns − reference turns) / reduction ×
sign. travel = output turns × π × pulley diameter. Before a
home is recorded, reference turns are assumed to be zero; that is not
evidence that the mechanism is physically at home. Once the
interpreted switch is pressed, recording home stores the current motor
reading as the zero reference.
WPILib: Encoders in software · WPILib: Digital inputs in software