PID Without a PhD (2016) [pdf]
wescottdesign.com
wescottdesign.com
Look for Model Predictive control, Dynamic Matrix Control, Adaptive Control, or even Linear Quadratic Regulator.
Source: I have a masters in control theory, a publication, and ~5 years industry experience
1. PID's work adequately for more situations than anything else.
2. If a PID doesn't work you should redesign your hardware.
3. Phase noise will totally mess with you.
The hardest part of PID for folks to get a handle on is how to tune it, ideally automatically.
People often just twiddle with numbers and get frustrated For hobbyists, the availability of correct automated tuning algorithms is sparse, even though the algorithms are well known and actually not that hard once you translate "control theory speak" into "computer science speak". Most folks would be better off autotuning for their systems.
I actually wrote and published some auto pid tuning code years ago that uses the relay method here: https://github.com/dberlin/PLC-PID-Autotuner (It's in PLCopen, but i can give you codesys versions/etc if you want, and converting to something like arduino would take no time, but someone finally made a working arduino library i think)
Nowadays you can find a few more working libraries, but still.
One example: I use a PID to control a vacuum motor on my CNC machine being used to hold down parts, set to achieve a certain amount of PSI in clamping pressure. The system is basically undisturbed for long periods of times, but a hole gets cut in the part and the amount of vacuum needed to maintain hold-down goes up.
This is a very simple system - it needs fast response, but the response is very straightforward - there is a very direct relationship between speed of vacuum motor and hold down pressure. It can also be safely overshot, but not undershot. (IE if it goes wild and moves the motor too fast nothing bad happens, but if it wildly undershoots it the parts move and get ruined :P)
Simple autotuning methods work great on this kind of system. I watch people twiddle with values, you name it. It takes about 2 minutes to auto-tune a pid here (mostly swapping a part with no hole and a part with a hole) and the result will be better than anything you come up with manually.
There are more complex methods, as GP mentioned, but they won't drive much better results than you are already geting for this kind of system.
The place where PIDs fall down (in systems hobbyists might use) tends to be something like controlling the temperature on a big green egg. They can maintain a steady state to within 0.1degrees or whatever once warmed up, but they get super-confused by the warm-up time. They can also oscillate into chaos very easily because of the lag time between "blowing on fire" and "temperature probe notices result" (which is highly dependent on accuracy and response tme of the probe). Overshoot is also bad because the only way to make temperature go down is to stop blowing on the fire, etc.
The result is that most smoker controllers have a warmup time/phase before they engage a PID, and then carefully adjust to avoid overshoot.
While more advanced methods might control this completely without the need to do the initial warmup phase, it's not obvious to me the complexity is worth it for that sort of thing. You are talking about going from simple loop that you can plot and reason about to often much more complex mathematical formalisms.
It can quickly become an even more magic box that you can't touch.
There are of course, places it is worth it, i just doubt most hobbyists will run into them.
Even in that case PID is often the answer. Only that you vary the P, I, and D factors. It's called gain-scheduling [1]. You linearize your non-linearities at multiple points, and change your PID parameters to match.
Of course non-linearity is a very broad concept. So this may or may not apply to your non-linear system. The class of linear systems is easily described. The class of non-linear systems is everything else.
- Anything where you want high performance. Lag and lead compensation is very often needed. That's not complex to do. It's often necessary (especially in analog design). PID works, but rarely optimally.
- Complex nonlinearities. Although simple ones, PID can be quite robust to (even more so than "smarter methods").
- A lot of systems which are highly multidimensional, and especially where controls isn't cleanly separable from path planning.
It's worth noting, in lower-quality control courses (e.g. a prof who specializes in another field, teaching this course on the side), a lot of incorrect things are taught here. I'm seeing some of that represented in this (broader) discussion.
TL;DR: Be careful what you read online.
That's a complex, multidimensional, nonlinear system (albeit with relatively simple dynamics). PID won't do it, since you don't even know which way the PID terms should go. There are approaches which mix PID with other methods, though.
A lot of analog systems too, such as some audio amplifiers, use more complex control techniques simply because they achieve higher performance. If you want low distortion, you need a lot of gain in your feedback loop. Most use rather simple controllers, but some go very fancy.
Some have complex linear dynamics. A system with a right half plane zero means that if you push right, the system goes left than right. That's very difficult to control. An example (called a boost amplifier) works like this, in analogy:
You have a bucket of water. You can either turn on a spigot to fill the bucket at a fixed rate, or one to empty it from a hole in the bottom (so at a rate proportional to how full it is). You'd like water to come out at a given rate. What is the ratio of time between filling and emptying?
- In the short term, if you empty for less time, less water comes out, because duh.
- In the long term, though, ALL the water which goes in must come out. If you empty for less time, you fill for more time, so it gets fuller, water pressure goes up, and more water comes out.
The above is actually completely analogous, mathematically, to how a USB device might take a 5V power rail and make a -12V power rail from it. You connect an inductor to 5V, charge it up with a current, and have it drive the -12V rail down.
If you're controlling more complex systems, you might have a mix of all of the above: nonlinearity AND complex dynamics.
Is your nick accurate? If so, you should already know this.
We can also have objective to explicitly define how much more important to us accurate tracking vs stabilization speed.
CS majors (I was EE) aren't generally taught PID, and I have milked my arcane knowledge. It's very profitable to type in the control loop, do some Ziegler-Nichols, and go home early.
EDIT Oh, I forgot the most recent time I've used PID was with the high-school robotics team I coach. We used PID for part of our robot. I didn't go too deep with the students, it's really just a P controller, but it solved the problem, and dramatically simplified the code.
There are only two types of controllers: PID control, PhD control
https://en.wikipedia.org/wiki/Ziegler%E2%80%93Nichols_method
http://brettbeauregard.com/blog/2011/04/improving-the-beginn...
I'll add, I've been meaning to write up my own "realities of PID", one day I'll get around to it.
What is NOT readily apparent when you look all these treatments of PIDs is what happens with the poles-zeros of your control-loop (PID) and the interplay with the system or plant.
I have consistenly found all these "it's so simple, integrator removes long-term error, differentiation improves response time" ignores the fact that if you don't pay attentions to the poles-zeros of your overall response you get some very puzzling results.
In a nutshell, understanding the s-domain (Bode) view of your plant and control-loop means you can usually use PID to sovle control-loop problems. But most people don't have a model of their plant (like some of the examples DannyBee has listed) which means you can't easily auto-tune a PID or most control-loops.
Examining the step-response is probably the first clue to your plant, assuming you won't physically break something with that stimulus...
PID control is probably what you'll see in an introductory undergraduate engineering control theory course (which I haven't taken). I think you'd typically study the dynamics using numerical simulation and Laplace transforms. You might think about making a practical project (I made a PID reflow oven controller).
After that you're off to the races with State Space methods (e.g. Chen's "Linear System Theory and Design".) and you can think about problems like stabilizing a quadrocopter based on inertial measurements.
He also has a free "The Fundamentals of Control Theory" book (I haven't read it, so unfortunately I can't provide an opinion on it).
Ph.D means you're doing something like:
* H2-optimization and optimal controls
* System ID
* Intuitive classical controls (Bode obstacle course, Nyquist, root-locus, etc.)
* Fancy discrete state-space methods / search / shortest path
* Machine learning, and the thing training itself
... and so on. PID is nice since it's idiot-friendly.
(And even with a Ph.D and a complete understanding of all of the above, it's often more fun or efficient to be an idiot and just use PID; I've never seen a place where PID was the right answer, but it's oh-so-often a good-enough answer)
It may be idiot friendly, but boy do I wish the idiots who did the noise cancellation on my earphones had heard of integrator windup.
If you are working in this field, no you don't need a PhD, but for the love of god invest some time into learning more appropriate techniques for the work. Start with learning to work with MIMO systems in state-space, then learn to use LQR (literally a one-liner in MATLAB) and reduced-order observers, then some nonlinear techniques like Lyapunov functions and integrator backstepping for those tricky nested loops. I'm happy to suggest resources for anyone interested.
> Start with learning to work with MIMO systems in state-space, then learn to use LQR (literally a one-liner in MATLAB) and reduced-order observers, then some nonlinear techniques like Lyapunov functions and integrator backstepping for those tricky nested loops
Ok mate.
Compared to linear control theory, nonlinear controls is much more fractured and domain-specific. No concept is as widely applicable as ones from linear controls. Khalil's Nonlinear Systems book is generally considered a top reference, but it does start to get into the PhD-level stuff and I don't recommend it to a non-specialist unless you are really into this stuff. I can give more specific recommendations if you have a particular industry or application in mind.
1) One of the key things in control systems is to deal with uncertainty. If you have a hundred trains, none of them should crash. You want a control system which you can understand to work even in corner cases. ML is bad at that.
2) You need to train an ML. Unless you have a very good model of the thing you're controlling (generating which is usually harder than designing an optimal control system), training an RL means crashing airplanes, burning out amplifiers, or destroying self-driving cars as the system "learns." Even so, when moving from model to reality, it's likely you didn't capture some oddball part of the system.
3) In many cases, there is some give-and-take between control system design and system design. In an extreme case, the PID can be purely mechanical or electrical (e.g. an op-amp). In a less extreme case, if you can design the mechanical system to avoid having e.g. a right-half-plane singularity, controls becomes easier. RL isn't at the level where you can do that kind of codesign.
4) It's a lot more complex.
So "in general," no. In some specific cases, yes.
RL is mostly beneficial for rather complex systems, such as walking robots or anytime a word like "nonholonomic" comes up. For relatively linear, relatively low-dimensional systems, classical methods will give better results for less effort.
An RL algorithm running on a general-purpose computer, you'll be lucky to hit tens of milliseconds.
That makes a big difference.
For those unfamiliar with control systems, delay matters a lot. Something like an audio amplifier (where you can't hear anything <20kHz) will generally have a bandwidth in the tens of megahertz, and more is better. A rule-of-thumb is:
https://en.wikipedia.org/wiki/Gain%E2%80%93bandwidth_product
In other words, if you'd like to bring down error by a factor of 10,000, your loop will generally like to be around 10,000x faster than whatever it's controlling. If something has a time constant of 1 second, you still might want to be able to react at the speed of microseconds. That's not a hard-and-fast rule per se (I can give all sorts of ways to work around it), but what is true is the more general principle that minimizing delays can be very, very helpful (even for things which otherwise seem pretty slow).
Determinism is often valued in safety critical systems. The system can't work _sometimes_. The system can't even work correctly _eventually_. It must produce the desired result in the time allotted. Actuating the thing 20ms too late could be as bad doing it incorrectly depending on the application.
I'm no ML expert, but that seems to be a problem for those types of solutions in some spaces.
The whole concept never really ‘clicked’ until I watched some demonstrations, like this [1] video. After seeing that one in particular, I realised that it’s everywhere… not everything is just a robotic on/off, or a directly proportional response based on feedback from some input.
So RL is usually too cumbersome for relatively little gain.
Source: I'm a roboticist working with RL.