View Full Version : PID Help
Hey,
I'm the head programmer of my team 3339.
I want to teach my crew how to use PID properly and I'm having a hard time finding a good presentation that will explain each parameter and the general principals.
Moreover, I am looking for a simulation for PID in order to demonstrate how it works. The one I've found in LabVIEW is not responding fast enough as a real motor would.
Can you help me?
plnyyanks
25-12-2014, 11:36
There are many, many threads on CD and the general internet about PID control. Try searching around.
Here's some good resources from NI:
Additionally, if you search through NI's website, they have some great (http://www.ni.com/white-paper/3782/en/) resources (http://www.ni.com/white-paper/6440/en/) about PID theory (and their examples are in LV). You can also view the complete help page for the PID VI here (http://zone.ni.com/reference/en-XX/help/370401J-01/lvpid/pid_vi/).
And here are some more resources:
The PID VI (http://zone.ni.com/reference/en-XX/help/370401J-01/lvpid/pid_vi/) is entirely mathematical (http://en.wikipedia.org/wiki/PID_controller) - it doesn't care what the inputs are, all it does it brings the error of the system (Setpoint - Process Variable) down to zero. It will work exactly the same with encoder rates and distances, provided that the SP and PV are scaled the same way (and the constants are tuned properly). I'd be more than happy to explain how some of the math works, if you'd like.
As for your specific system issues, it just looks like the constants aren't tuned properly. Read a little bit about PID Theory (http://www.ni.com/white-paper/3782/en/) (also: wikipedia (http://en.wikipedia.org/wiki/PID_controller#PID_controller_theory)) and take a look at some tips (http://www.ni.com/white-paper/6440/en/#toc9) on designing a good controller (the rest of that page is helpful too). You may also want to start with the Ziegler-Nichols method (http://en.wikipedia.org/wiki/Ziegler%E2%80%93Nichols_method) for tuning (start with all zero, bring P up until it oscillates, add D to dampen and add I to correct for steady state error.
Just another note - if I remember, the LabVIEW implementation of the algorithm doesn't use Kp, Ki, and Kd as straight constants. It actually uses time constants (http://en.wikipedia.org/wiki/Time_constant) for I and D (so it has Kp, Ti, and Td). You can see details (http://zone.ni.com/reference/en-XX/help/370401J-01/lvpidmain/pid_vi_algs/) of the NI implementation here (http://zone.ni.com/reference/en-XX/help/370401J-01/lvpidmain/pid_algs/). You can verify this in the help popup (ctrl-H) for the VI. Plan your constants accordingly.
And this page (http://www.engineers-excel.com/Apps/PID_Simulator/Description.htm) looks like it has some cool simulation resources, and some overviews about the theory behind the controller.
There are many, many threads on CD and the general internet about PID control. Try searching around.
Here's some good resources from NI:
And here are some more resources:
And this page (http://www.engineers-excel.com/Apps/PID_Simulator/Description.htm) looks like it has some cool simulation resources, and some overviews about the theory behind the controller.
Thanks alot!
I have question about the Labview implantation (your 2nd quote):
Should I use Ti and Td differently of what is written about Ki and Kd or is it the same?
plnyyanks
25-12-2014, 14:53
Take a look at this page specifically (http://zone.ni.com/reference/en-XX/help/370401J-01/lvpidmain/pid_vi_algs/), it details the exact math behind each of the P, I, and D parts of the controller.
Integral:
http://zone.ni.com/images/reference/en-XX/help/370401J-01/noloc_eq_vitrapint.gif
Derivative:
http://zone.ni.com/images/reference/en-XX/help/370401J-01/noloc_eq_vipartderact.gif
So in the integral case, Ki = Kc/Ti. It's a similar thing for the derivative part.
Disclaimer: I have no idea if NI has changed their implementation since I last looked at it (a year or two ago), so verify exactly what constants are used with the 2015 docs when they come out.
DonRotolo
25-12-2014, 20:38
One story I've found to help people understand is a car's Cruise Control. We all know that it's a system used to keep a car moving at a constant speed.
P is the difference between the set speed and the actual speed. When P is non-zero, the system takes action to move this 'error' towards zero.
D is how fast you want to accelerate (or decelerate) back to the set speed. You may want to adjust this depending on engine power: with a very weak engine would want to go to full throttle quickly, with a very powerful engine you'd want to add throttle slowly. If you add too much power, you'd go past the set speed and have to slow down...the system would go too fast then too slow, continuously.
I is a little tricky, but basically it's fine control right around the set speed, allowing small speed errors to accumulate over time and allow for corrective action (like P) that is gentle instead of a large response (like D)
I made a PID simulator to teach some of our programmers. It simulates an arm with or without gravity pulling it down.
Check out my post about it here: http://www.chiefdelphi.com/forums/showthread.php?t=130801
For a sample of a well tuned loop, try setting a setpoint of 200, a mass of 0.03, kP of .35, and kD to 5, then click start.
The simulation is fairly realistic, and takes into account motor torque curves and the inertia of the arm.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.