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

  1. Configure encoder type with useEncoderType()

  2. (Optional) Set initial position with setEncoderPosition()

  3. Use control methods:

    • setPercent() for direct power control

    • setPosition() for position control (requires PID)

    • setVelocity() for velocity control (requires PID)

  4. Read feedback with:

    • getPosition() for current position

    • getVelocity() 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 units

  • Position/velocity control require properly configured PID

  • setPosition() sets a target for closed-loop control

  • getPosition() reads the actual measured position

  • Current readings are always in amps

  • All encoder readings are relative to the last setEncoderPosition() call

Last updated