Configure Onboard PID

The Thrifty Nova provides both position and velocity control using an onboard control loop, running on the motor controller at 1kHz. A PID must be configured in order to use position and velocity control functionality. The PID controller has an additional feed-forward term.

There are two separate builtin PID configurations. These can be individually configured, and then the active PID configuration can be selected by Selecting Active PID Configuration.

Configuring the PID Object

Below is how to set individual PID settings on the controller's first PID slot. Note that these can be chained together just like standard configuration functions.

motor.pid0.setP(0.5)    // set the proportional term to 0.5
     .pid0.setI(0.24)   // set the integral term to 0.24
     .pid0.setD(0.16)   // set the derivative term to 0.16
     .pid0.setFF(1.12); // set the feed-forward term to 1.12

Setting the configuration for the second PID slot is as simple as changing pid0 to pid1.

motor.pid1.setP(0.66)   // set the second PID's proportional term
     .pid1.setFF(1.19); // set the second PID's feed-forward term

Selecting Active PID Configuration

To select the first PID configuration, pid0, as active, use the following code.

motor.usePIDSlot(PIDSlot.SLOT0);

And to select the second PID configuration, pid1, as active, use the following code

motor.usePIDSlot(PIDSlot.SLOT1);

Use PID API Details

Set the PID slot to use for feedback control.

usePIDSlot(PIDSlot pidSlot)

Parameters:

  • encoderType The PID slot to use.

PID Configuration API Details

Functionality for configuring the Integral Zone is currently in progress on the Thrifty Nova firmware.

Set

Set the PID controller terms from a PIDController object.

set(PIDController pid)

Parameters:

  • pid The PIDController object.

Set P Term

Sets the proportional term for the PID controller.

setP(double p)

Parameters:

  • p The proportional term.

Set I-Term

Sets the integral term for the PID controller.

setI(double i)

Parameters:

  • i The integral term.

Set D-Term

Sets the derivative term for the PID controller.

setD(double d)

Parameters:

  • d The derivative term.

Set FF-Term

Sets the feed forward term for the PID controller.

setFF(double ff)

Parameters:

  • ff The feed forward term.

Last updated