Hello. I am currently using the TalonSRX Encoder and PID software to set velocity values. Whenever I try to set the TalonSRX’s in velocity mode to any value, whether it be something insignificant like 5, or something big like 300, the talon just goes at full speed, unless I have all my PID values at 0. No matter what I change my Talon PID values to I get an error of ~2500, which is ridicously high. I have the talon set to use the CTRE Mag Encoder in relative (quadrature) mode and I know the encoder works fine since I am getting proper position feedback from the encoders. So does anyone know why I’m getting such a high error and fast movement?
It seems the most likely cause is that your motor direction and your encoder direction are not the same (they are not “in phase”). They need to react such that when the motor is spinning in a positive direction, the encoder also moves in a positive direction. Failure to do this causes the system to respond backwards to the error, and the more it responds the further off it gets until it’s running at full speed the wrong way.
There is a software command “setSensorPhase()” to change the phase if it’s backwards.
See section “7.4. Correcting sensor direction, best practices.” of the Talon SRX Software Reference Manual for more information.
The PID values don’t affect the error - the PID values, along with the error and its history determine the duty cycle the motor. A ridiculously large error is quite likely to cause a full speed condition, as you are seeing.
To verify, is the encoder wired directly to the SRX, and you are using its internal velocity control?
Double check all of your encoder units and direction, as noted above. In particular, note that (emphasis mine):
While there are good reasons and it works, 100ms is probably not what most people would assume if they hadn’t read this.