Talon SRX PID parameters

Hi. First timer here.

We are attempting to use the PID functionality of the Talon SRX and am confused about the magnitude of the parameters to be used in the SetPID method. We are using a Quadrature Encoder.

From the ‘Can Talon SRX PID’ example C++ code it states, just before the call to SetPID:
// These values are in units of throttle / sensor_units where throttle ranges
// from -1023 to +1023 and sensor units are from 0 - 1023 for analog
// potentiometers, encoder ticks for encoders, and position / 10ms for
/ speeds.

And in the CanTalonSRX.h is states:

  • P gain is specified in throttle per error tick. For example, a value of 102 is ~9.9% (which is 102/1023) throttle per 1
  •  ADC unit(10bit) or 1 quadrature encoder edge depending on selected sensor.

Since we are using a Quadrature Encoder are we correct in assuming that the values for P, I and D should be integer values, according to the comment above, ‘encoder ticks for encoders’?

Our tests using integer values did not work. When we used PID values all less than 1.0 we had better results but the encoder never reached the set point. Any ideas?

Thanks in advance.

I messed around with it and, I had a lot of trouble. They don’t have very much documentation on exactly what the methods in the class do and it didn’t seem to work very well. We decided to plug the encoders into the Talons to save DIO ports but to run the PID loop on the roboRIO.


P, I, and D are floating-point gains.

They are not encoder ticks. They are in units of throttle/sensor_units as stated in the comment section you posted.

When we used PID values all less than 1.0 we had better results but the encoder never reached the set point. Any ideas?

Watch this video, especially PID tuning starting at at 9:03

Joey1939, What was it that you needed that wasn’t in the Talon SRX Software Reference Manual?

Also, the verbatim PIDF code used by Talon is in section 18 of the software reference manual. That was deliberate so programmers didn’t have to guess at the implementation.

kmrchiefdelphi, if you want a specific answer about what’s happening with a specific set of gains and error, you’re best best is to screenshot capture the Self-Test results (and the gain values that are under the self-test results). That displays your throttle, the ClosedLoopErr, and sensor pos/vel.

ClosedLoopErr is what multiplied by Kp, and is your target - current sensor position (or velocity if that’s selected). So yep if you are using quad encoder, then there is 4XCPR units per rotation where CPR=countsPerRotation. Talon is always in 4X mode.

Integral accum sums closedLoopErr every 1ms.
dErr is the change in ClosedLoopErr per 1ms.

Thanks for the replies. The video was very helpful in our understanding of the PID parameters.