Source: I have a masters in control theory, a publication, and ~5 years industry experience
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.
We can also have objective to explicitly define how much more important to us accurate tracking vs stabilization speed.
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.