
What is a control system anyway? - feltarock
https://feltrac.co/control/2020/01/12/simple-control-systems.html
======
Greek0
PID Without a PhD [1] is an excellent paper that gives a good intuition for
PID controllers. In addition, it has concrete advice on how to go about
implementing a practical control scheme, and how to tune the PID constants.

It's really my go-to reference for any practical control theory application.

[1]:
[https://www.wescottdesign.com/articles/pid/pidWithoutAPhd.pd...](https://www.wescottdesign.com/articles/pid/pidWithoutAPhd.pdf)

~~~
RealityVoid
It kind of bugs me that I understand PID quite well and I've coded quite a few
for of them. But trying to dive deeper into control systems, I always hit a
wall caused by my weak mastery or mathematics.

I've heard someone say that PID is the deepest you can get without in control
systems without advanced mathematics and I think hey might be right.

~~~
TheSoftwareGuy
I took a linear control systems class in college, probably at the peak of my
mathematical abilities. I hadn’t yet forgotten the fundamentals of Laplace,
Fourier, and solving differential equations. Not to say I was some math
wizard, but at least the prerequisites were fresh on my mind.

It was fascinating, but I just couldn’t grok it. Whatever weaknesses I had in
the relevant maths, that class just seemed to amplify it x10. I still wish I
could have absorbed more of the knowledge

~~~
tobinfricke
I think a practical lab component is necessary to really grok controls. The
theory can be extremely abstract - to internalize it requires some hands-on
experience too (in my opinion).

------
seiferteric
In lieu of my final in control systems class, the professor allowed anyone to
make a PID controller and present it to the class instead. All the EEs went
this route (seems unfair to the others in retrospect LOL) and it was a great
experience. Many did it digitally, but I opted for purely analog with op-amps
for P, I and D with a summing op amp circuit at the end. This was connected to
a pair of power transistors to drive a DC motor (from my lego mindstorm) and
some gears to move a stick on a board. The input was a potentiometer with a
nice metal knob. Each of the PID also had a pot to control it's own
amplification before going into the summing circuit so you could adjust and
see the behavior of each element. This was one of the most rewarding projects
I have ever done I think, so cool to see it in action.

~~~
deadso
Reminds me of this project from MIT students where they built an analog
Segway:

[https://techtv.mit.edu/videos/687f4627e5c14a52b24c694f7eeecf...](https://techtv.mit.edu/videos/687f4627e5c14a52b24c694f7eeecfa4/)

------
roland35
PID loops are simple and effective control solutions and are relatively easy
to incorporate into embedded controllers as well. Generally I have left out
the integration step because it can easily cause instabilities, even with a
wind-up preventer.

When things get more complicated like with flight controllers or advanced
motor drives PID is not recommended. Another problem I've seen is people gloss
over tuning a PID controller properly too.

~~~
ChuckNorris89
_> Generally I have left out the integration step because it can easily cause
instabilities, even with a wind-up preventer._

Funny, in automotive we always left out the derivative component not the
integral which IMHO is the most useful component of the controller.

~~~
joeberon
Yeah I've usually heard that the derivative component is what gets left out,
never heard of leaving out the integral

~~~
zwieback
If you have a system without natural dampening and can't tolerate overshoot or
oscillation you'd use a bit of D to slow things down.

------
Jugurtha
I've had the chance to have had a teacher who exposed us to the design of
robust RST controllers and optimal control (Pontryagin, Lyapunov, Bellman,
Hamilton, Jacobi), Evans' work. Getting into an ML shop and looking at what my
colleagues who do DL were doing made me think: hmmm, this backpropagation-
thingy looks really familiar.

There was, and still _is_ , a comparatively scarcity of documentation on these
as most of the content online only tackles PID when it comes to "control
systems".

Fascinating stuff.

~~~
RealityVoid
Soo, if I wanted to look deeper in the maths for these RST controllers, where
should I be looking? As I've been confessing in another comment in this
thread, I am quite stumped how to proceed to understand more complex
controllers. This is all my fault, because of my weak grasp of advanced
mathematics.

~~~
HeyLaughingBoy
The best book I know of is pretty old by this point, but it's very readable!
_Modern Control Systems_ by Dorf & Bishop. Probably pretty expensive by now,
too!

There's also the Control Systems Design Guide, but that's more of a cookbook-
style. Dorf and Bishop is a theory book, but a good one.

------
Tade0
Beautiful introduction.

I remember my PID lab in college - we had two plexiglass towers with water in
them and a pump - our task was to calculate the PID parameters so that one of
the columns reached a certain level. I think it was measured by a buoy, so we
had a pretty noisy input to begin with, but that was part of the problem at
hand.

It was a great introduction because the lab was 2h and the pump rather slow,
so we couldn't just half-ass it.

~~~
zyberzero
We had the same! Our towers leaked water as well (not sure if a feature or a
bug in the lab, there was a non-trivial amount of duct tape involved), so you
really needed to take "external forces" into consideration.

------
daxterspeed
These visualization are very satisfying and provide some wonderful insight.

A few minor bugs: \- The gray area is always too small, so there's plenty of
area of the canvas that never gets cleared. \- Perhaps this is intended, or
maybe it's caused by by the demo running at 144Hz, but the drone is always
swept away by the wind for me. It doesn't even stand a chance to fight it.

~~~
vardump
Same issue at 120 Hz, the drone had no chance against the wind. Confused me up
until reading your comment.

Works fine after setting refresh rate to 60 Hz. (Btw, amazing how bad
scrolling looks at 60 Hz after getting used to 120 Hz! Never noticed it before
nor did I think it could matter...)

------
jagged-chisel
OT anecdote

If the cruise control in my vehicle is using PID, it still needs some tweaks.
It's super aggressive when it's lower by 2pmh and often overshoots.

My mom's is horrid: takes forever to get up to speed, then allows downhill
drift to drive the vehicle nearly 5mph over the set speed.

I feel like this kind of stuff would be fun to tweak in a simulator to help me
understand why it doesn't work better, or show that I'm not entirely crazy and
it can indeed be improved.

~~~
ncallaway
What's often hard about this situation is tuning to one problem case (fixing
that downhill drift) often makes a _different_ scenario worse. For example,
fixing the downhill drift can make that overshoot worse.

I can imagine tuning something like this for a cruise control scenario would
be tricky, because there's probably hundreds of different cases to test for.

I think a simulator here could be particularly fun to toy with, because you
could have "unit tests" with 200 different scenarios that you try to optimize
for. You could set your parameters, and it could run the 200 different
scenarios, and show you were your parameters did well and where they did
badly.

~~~
jacques_chester
There's a lot of literature spread across a bunch of fields. The one I first
saw was "Active Nonlinear Tests"[0] from the systems dynamics / complex
systems area. The idea is that you perform searches of parameter space for a
simualation to find the places where it exhibits dramatic nonlinearities.

I've since seen something similar but not identical in the Statistical Process
Control world: robust process (or product) design[1]. The idea is that any
given system can be thought of as a function that represents X = F(a, b, c,
...) + E, where E is some measure of error or noise that can't be removed. The
goal is to find settings for a, b, c etc that _minimise the effect of E_. So
that even if uncontrolled noise swirls around, your process remains stable.
You can imagine flipping that to look for maxima instead.

[0] [https://www.santafe.edu/research/results/working-
papers/acti...](https://www.santafe.edu/research/results/working-
papers/active-nonlinear-tests-ants-of-complex-simulation-)

[1] Web search results are underwhelming, I refer you instead to Douglas
Montgomery's _Introduction to Statistical Process Control_.

------
zwieback
Very nice! I've been working as a controls engineer for 20+ years and this is
one of the best visualizations I've come across.

------
lb1lf
As others have said, this page provided more understanding than more than one
university course I've taken.

Oh, and anecdotally I'll state that while Ziegler-Nicholls was great for my
lab exercises, it was, ahem, quickly dropped when I started tuning heavy
lifting equipment. Increasing proportional gain until stable oscillation was
achieved with 160 metric tons in the test tower outside was, ahem, not boring.
Not in the least.

------
dmarchand90
I think I got a better insight into PID from this one page from me entire
control engineering course in university

~~~
scrooched_moose
I was thinking the same thing.

In my class, at no point was it explained why we would want to do this. It was
"This is the math for a P controller. Here's some homework. Now test. This is
the math for a PID controller....". Things didn't click until years later.

Looking back, it was a shortcoming in so many classes I took. Actually
discussing the problem we were trying to solve adds so much intuition and
understanding to the mathematics.

------
elteto
This was the controls lab final project when I was back in college [0] (video
is not mine). It was a super cool project.

Our task was to tune two PID controllers (one for each motor) to move the
"head/pickup tip" to the color balls on the screen and then drive back to
"drop" the ball in its respective "bucket". We were given the forward and
inverse kinematic models, as well as a black box piece of code to actuate the
motors, so we could focus on just tuning the PIDs. Lots of fun!

[0]
[https://www.youtube.com/watch?v=PLk7nn2hWN0](https://www.youtube.com/watch?v=PLk7nn2hWN0)

Edit: found a video of a project from a different year, also really cool and
about tuning PIDs:

[1]
[https://www.youtube.com/watch?v=ohwVLDmCSns](https://www.youtube.com/watch?v=ohwVLDmCSns)

------
carapace
Huh, I once plugged a 2D physics engine into Tkinter and made a little floaty
PID drone sim. I added balls that spawned from above it and fell on it, and it
would stay on point. I'll see if I can find it later today if anyone's
interested?

------
timvdalen
Very cool! On my device, the actual canvas is a bit bigger than the area
you're clearing, resulting in this[1].

[1]: [https://i.imgur.com/orrXwZT.png](https://i.imgur.com/orrXwZT.png)

~~~
aasasd
That glitch is proper oldschool lo-fi trippy fun, though. Would consume
substances and play with it for half an hour if I had anything right now.

------
pgt
PID-controlled sous vide with Clojure transducers:
[https://blog.adafruit.com/2014/10/06/boiling-sous-vide-
eggs-...](https://blog.adafruit.com/2014/10/06/boiling-sous-vide-eggs-using-
clojures-transducers/)

------
baylessj
Really like the visualization, this does a great job of explaining the
concepts of PID in an easy to understand way!

The visualization used here could also work as a nice foundation for more
complex controls algorithms for 2D space like path planning splines and pure
pursuit.

------
davedx
I'm working on this exact problem except for an autonomous boat, so probably
it's completely transferable, so this is nice timing. For now though I think
I'm going to use a much simpler autopilot system (that I've already coded):
Accelerate towards target at maximum speed; if within a certain distance of
target, slow to approach speed (10%); if within "arrived at target" distance,
cut speed to 0 (station keeping). This seems to work "well enough" in my
JavaScript simulator, but I really wonder how it will do on actual water.

------
moritonal
Great explanation, we often end up writing the same rules in video games.

Any "drone" logic to do with some kind of builder unit or even a literal drone
in something like COD needs rules like this.

~~~
artemonster
every time I see such great, simple and intuitive explanations I always
remember how these topics were presented in Uni and want to tear-up a little:
monotone voiced prof draws some nonsensical formulas and crap on blackboard,
explaining zero things, giving zero context and examples. After a lecture
you'd go to an excercize and start applying these formulas to artificial
isolated problems, like a symbol manipulating machine. I always imagined
myself being a person in that famous "chinese room experiment", a mindless
monkey, manipulating symbols in equations with zero underlying understandings,
just as it was "taught". brrr.

~~~
ilikerashers
I second that. University education in Electronic Engineering tends to favour
rote learning over understanding.

People could be genuinely interested in this stuff if engineering tried to
focus more on creativity than memorization.

~~~
TeMPOraL
Same here. Give some interesting, non-artificial problems to solve. Tune a PID
on an actual (real or simulated) pole balancing machine. Tune a controller on
a (simulated!) rocket chasing a target in the sky. Give problems that students
can relate to and understand, and in context that allows for exploration and
interactively verifying solutions.

------
supernova87a
Those are great controllable animations/simulations! Thanks for sharing that!

I had always wanted to get a physical intuition for how PID changes led to
different behaviors. (And for example, in practical life, how an autopilot
doesn't wildly overshoot and oscillate around a VOR radial when trying to
intersect it).

------
LoSboccacc
it's interesting but that not how thermostats work, sure they're on-off but
they have hysteresis they don't keep switching

also you can use bang bang demo and inertia to orbit the thing moving the
point on the tangent at the fastest approach, which is awesome.

~~~
paulgb
The thermostat he describes is not stateless, the key phrase is "When the
temperature is too high _by some amount_ " (emphasis mine) -- the thermostat
will turn on outside a particular range.

This matches my understanding of a simple thermostat, is it wrong?

~~~
TeMPOraL
The JS simulation doesn't demonstrate this, though; the bang-bang controller
keeps oscillating in very short steps around the goal.

------
ngcc_hk
The idea in the article is about acceleration and not velocity is great. We do
not deal with the target but error. And the response to acceleration has to be
proportional.

Why can’t it apply to real drone? Interrupt needed?

------
pgt
I built a volume control system (hardware + software) using mainly a PID
controller: [https://wallfly.webflow.io/](https://wallfly.webflow.io/)

------
ryanmarsh
A great example of this is a tweet from Max Howell (creator of Homebrew)
regarding interviewing at Google.

 _Google: 90% of our engineers use the software you wrote (Homebrew), but you
can’t invert a binary tree on a whiteboard so fuck off._

[https://twitter.com/mxcl/status/608682016205344768?lang=en](https://twitter.com/mxcl/status/608682016205344768?lang=en)

