PID Questions

Hey guys.
I’m attempting to develop a PID code with this thread as reference https://vexforum.com/t/a-pid-controller-in-robotc/20105/1 .
Using the code provided, is there a way I can control the setting time? Overshoot? How can I make my graph go critically damped? Under-damped?
Example pictures:
Dampening-graph.jpg
I’ll mainly use it for distances and angles, using encoders and potentiometers respectively.

I’ll appreciate any help.
Thank you, Vex community.

It’s a long read, but please go through this. You are concerned with the motor examples more than the temperature ones.

The graph you show shows the overshoot and undershoot of your PID variables.

When they say underdamped, that means the drive does not slow down in time and it goes past the target. It is not being held back enough as it approaches. Then the controller starts backing off more and eventually reverses direction to get you back to the target it just shot past. However, since the control variables are having it come in too hot, it still shoots past the target on the bottom end. This gets less and less each time so you see it settle down to the target steady state. But you don;t want that. You want to hit the target right away.

There are many way to tune that to get you to the critically damped. That is a fancy term for “just right” and optimally getting to the target state without overshooting.

Copy of the one excellent document from Free Range Robotics in 2012. Having some trouble getting it from NZ sites on my work proxy.
http://www.madison-schools.com/site/handlers/filedownload.ashx?moduleinstanceid=19089&dataid=70925&FileName=PID%20Programming%20Guide.pdf

Starting on page 12 it shows the ways to tune the PID constants to get what you want. I prefer the Ziegler Nichols method described on page 14. Set I and D constants to zero and make it so your proportional constant never decays. The lowest P constant that does that is the critical oscillation that is used in the Ziegler Nichols equations. The other key now is finding the period of time between peaks. Logging the data is necessary here to find that. Pop these values in the formulas and you get the P I and D values which align to the critically damped value you see above.

You can then tune slightly from there using guidance from page 12.

One note: make sure the integral is capped to between 20% and 40% of motor power contribution (Max 35 motor power is what I tell our guys but it does depend on what you are controlling). Otherwise the integral takes over and contributes far too much. it is in the NZ examples.