CAN PID problems

Our team is looking this year to implement PID control embedded in the Jaguars using CAN. Unfortunately, when we try to request any value out of the Jaguars, the motors spin at top velocity.

We have modified the example code to include speed, output voltage, and PID value indicators acquired from the Jaguars, and the voltage, when any speed is requested, we get a voltage out of 12 volts, an RPM of 600 (The max, and accurate), and all the correct PID values read from the jaguar. We cannot figure out this problem, and I am very confused about this.

What values are you using for P, I, and D?

We have tried every possible combination of P,I, and D, with no noticeable results except huge values of I and D instantly cause the robot to oscillate.

We have only minimally tuned our drive PID constants (because our robot isn’t close enough to its final weight yet), but it is working fairly well with P=D=0 and I=0.01. Perhaps you are using values that are too large? If the robot is oscillating your constants are too large.

Note that you generally want to tune the PID loop with the P constant in position control, but in speed control the I constant takes the place of the P constant and P takes the place of D. CD has a lot of threads about speed-based PID control by now; refer to them for details about tuning speed PID loops.

I suggest you look closer at your feedback and command values. I’m nearly certain that while you’re commanding a positive speed, you’re getting a negative speed feedback. Or vice versa. This would explain your run away condition. If a positive Voltage output doesn’t give you a positive feedback, then your PID loop will make things worse and worse and worse until it’s running as fast as possible in the opposite direction.

Your solution is to either swap your A and B channels on the encoder, or the wires on the M+ and M- terminals. Do either one of those (not both!) and things should start working better. I believe our programming team is using P=0.5, I=0.0005, and D=0 and is getting decent results. Once they had the feedback and command directions matching, that is.