# PID Help

Our programming team has been working hard with the PID portion of the robot. However, we have not been able to get it working. We are using four USDigital E8P encoders, and four CANJaguars (one for each wheel), as well as four mecanum wheels. When the robot is activated with a P, I, and D value of anything > 0 the robot trys to go every direction at the same time. We need to know how to fix this, or just a detailed discription of how to use these encoders with CANJaguars to get the PID working.

The first thing to check is the sign of everything.

Are you doing PID on the jaguar or on the cRio?

First, make sure that a positive value for motor results in a positive change (We usually define positive as forward, right, up, right-turn). If not, invert it after the PID control.

Second, make sure a positive change in the sensor results in a positive change in the sensor signal. If you roll it in the positive direction, do your counts and go up and velocities positive? If not, invert it before the PID control.

Then, you can try running PID control. If the direction is wrong, the control loop will compensate in the wrong direction, and since it keeps getting further from the target, it will keep compensating further in the wrong direction until it hits the limits of its authority.

All robots have the issue that the motors on opposite sides need to be driven inverse from each other. Some teams reverse the motor leads, but if you use encoders (which are not as easy to invert) it is much easier to invert (typically the right side) in software.

The Jaguars use a VELOCITY PID algorithm that is best tuned by starting with the I term small (say 0.01) and raise it slowly until it becomes unstable. Then increase the P term to make it more stable.

I am attaching a spreadsheet that we use for initial estimates of the PID values. The ones you want to use are the last two columns labeled JagI and JagP. We typically tell the jaguar that the encoder lines is the number of ticks per inch (not ticks per rev) so the reported speed is in inches per second, not RPM. If you want RPM, the values in the table need to be scaled.

Drivetrain_Model_KOP2014.xlsx (342 KB)

Drivetrain_Model_KOP2014.xlsx (342 KB)