Set Output
The Thrifty Nova provides various ways to set the output of the motor, percent, positional, and velocity control. The following examples highlight various applications of these three control modes.
Percent Output Control
Simplest control mode - directly sets motor power:
javaCopymotor.setPercent(1.0); // 100% forward
motor.setPercent(0.75); // 75% forward
motor.setPercent(0); // Off
motor.setPercent(-0.25); // 25% reverse
motor.setPercent(-1.0); // 100% reverse
Position Control
Moves to specific encoder positions using PID control:
javaCopy// Requires configured PID!
motor.setPosition(90); // Go to position 90
motor.setPosition(-45); // Go to position -45
motor.setPosition(0); // Return to zero position
Velocity Control
Maintains specific speeds using PID control:
javaCopy// Requires configured PID!
motor.setVelocity(100); // 100 units/second forward
motor.setVelocity(-50); // 50 units/second reverse
motor.setVelocity(0); // Stop with active control
Control Flow Summary
Configure encoder type with
useEncoderType()
(Optional) Set initial position with
setEncoderPosition()
Use control methods:
setPercent()
for direct power controlsetPosition()
for position control (requires PID)setVelocity()
for velocity control (requires PID)
Read feedback with:
getPosition()
for current positiongetVelocity()
for current speed
Important Notes
Position and velocity units are always in encoder-native units
Use the
Conversion
class to convert between encoder units and real-world unitsPosition/velocity control require properly configured PID
setPosition()
sets a target for closed-loop controlgetPosition()
reads the actual measured positionCurrent readings are always in amps
All encoder readings are relative to the last
setEncoderPosition()
call
Last updated
Was this helpful?