[HN Gopher] What is a control system anyway?
       ___________________________________________________________________
        
       What is a control system anyway?
        
       Author : feltarock
       Score  : 248 points
       Date   : 2020-05-18 13:27 UTC (9 hours ago)
        
 (HTM) web link (feltrac.co)
 (TXT) w3m dump (feltrac.co)
        
       | davedx wrote:
       | 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.
        
       | carapace wrote:
       | 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?
        
       | roland35 wrote:
       | 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 wrote:
         | _> 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.
        
           | dls2016 wrote:
           | A quick intuition for this is: d/dx(e^(iwx)) = iw*e^(iwx)...
           | that is, differentiation amplifies higher frequencies more
           | than lower ones.
        
             | aidenn0 wrote:
             | Right, an integral is a low-pass filter with infinite gain
             | at DC and a derivative is a high-pass filter with gain of 0
             | (negative infinity dB) at DC; they both have 90 degrees of
             | phase shift.
        
           | silentwanderer wrote:
           | In high school we nearly always left out the I term because
           | we didn't mathematically verify our controllers, couldn't
           | risk breaking the systems we were controlling with windup,
           | and cared more about smooth and predictable motion than
           | accuracy.
        
           | rcxdude wrote:
           | It does depend on the system you're controlling, often
           | there's a natural integral in there and so you effectively
           | 'shift' everything down one (P acts more like I, D acts like
           | P, and I is a double-integral). Like how PD is fine for the
           | quadcopter control until wind is added to the simulation.
        
             | jbay808 wrote:
             | Definitely.
             | 
             | The main price of an integrator is 90 degrees of phase lag;
             | this will harm the stability of many systems but as long as
             | it's kept at a low bandwidth it's usually fine.
             | 
             | The main price of derivative gain is high frequency noise
             | amplification, and so a well designed PID will have a
             | limited bandwidth for the D term as well. For many systems,
             | especially those that are already damped or don't need the
             | extra phase margin, it's not needed or not worth the noise
             | cost.
        
           | joeberon wrote:
           | Yeah I've usually heard that the derivative component is what
           | gets left out, never heard of leaving out the integral
        
             | zwieback wrote:
             | 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.
        
               | [deleted]
        
             | edge17 wrote:
             | Yea, I built a ball beam balancing device that torqued the
             | beam using electromagnets (instead of the standard 2nd
             | order system with a motor in the center and fast response).
             | The electromagnets can not 'instantly' change the angle of
             | the beams, and the ball's dynamics lead to overall
             | instability as it rolls around and accelerates faster than
             | the system can respond.. Without a derivative term it would
             | have been impossible to control the system. That being
             | said, the project was deliberately contrived in a way where
             | the effects of the P,I,D terms were observable.
        
       | elteto wrote:
       | 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
       | 
       | 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
        
       | supernova87a wrote:
       | 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 wrote:
       | 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 wrote:
         | 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 wrote:
           | The JS simulation doesn't demonstrate this, though; the bang-
           | bang controller keeps oscillating in very short steps around
           | the goal.
        
       | Tade0 wrote:
       | 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.
        
       | moritonal wrote:
       | 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 wrote:
         | 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 wrote:
           | 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 wrote:
             | 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.
        
             | arethuza wrote:
             | The CS course I did had a lot of the maths content of the
             | related electrical engineering courses - admittedly with a
             | focus on discrete maths for the third and fourth years.
             | This did give us a lot of maths, but with no real idea as
             | to what people actually _did_ with it.
             | 
             | Fortunately, for me at least this was fixed when as a
             | postgraduate I joined a research group that was largely
             | control engineers!
        
           | rcxdude wrote:
           | Maybe I shouldn't be so hard on the teaching at my uni then.
           | There was a pretty decent amount of attempts at getting an
           | intuitive explanation of how the systems worked, and quite a
           | few demos of different control schemes and how they worked
           | and might fail (as well as tons of maths).
        
           | regularfry wrote:
           | My memory of learning control theory at university was
           | learning some super complicated stuff that was applicable to
           | 99% of control problems. PID controllers, which are good for
           | probably 95% of control problems, were effectively "an
           | exercise for the reader". So trivial compared to the broader
           | theory we were studying that nobody even thought to mention
           | them. The expectation seemed to be that when you needed them,
           | they'd just drop out of the maths and they'd need no further
           | explanation.
           | 
           | We'd already done a form of proportional control with op-
           | amps. It would have been _enormously_ helpful to start
           | control theory with discrete PI and PID to give us a
           | practical grounding and something we could actually _use_
           | before leaping off into the wider theory, but that 's not how
           | academia works...
        
             | HeyLaughingBoy wrote:
             | This problem persists even in applied classes. I was taking
             | a set of courses in Mechatronics for engineers who were
             | already working in in industry. We went deep into the
             | theory of various types of controls but when one of the
             | students (an engineer with probably 20+ years of
             | experience) asked about PID, it was dismissed as a "special
             | case" of (I think) a Phase Lead control.
             | 
             | Happily the guy teaching the lab portion of the class was
             | himself an experienced controls engineer who actually knew
             | how to use the math to accomplish something useful. We
             | learned far more from him than from the lecture classes.
        
             | Filligree wrote:
             | As someone who's only worked with PID controllers, do you
             | have any pointers to the more complicated stuff you're
             | thinking about? A wikipedia article maybe?
        
               | nuclearnice1 wrote:
               | Try Model predictive control (MPC) and linear quadratic
               | regulator (LQR)
        
       | Greek0 wrote:
       | 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...
        
         | wrigby wrote:
         | Love this! I had read another paper from Wescott about
         | sampling[1] years ago and loved it, but I didn't realize
         | there's a handful of other great articles[2] that they've
         | published.
         | 
         | 1: https://www.wescottdesign.com/articles/Sampling/sampling.pdf
         | 
         | 2: https://www.wescottdesign.com/articles.html
        
         | RealityVoid wrote:
         | 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.
        
       | zwieback wrote:
       | 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.
        
       | Jugurtha wrote:
       | 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 wrote:
         | 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 wrote:
           | 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.
        
       | baylessj wrote:
       | 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.
        
       | ryanmarsh wrote:
       | 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
        
       | lb1lf wrote:
       | 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.
        
       | pgt wrote:
       | PID-controlled sous vide with Clojure transducers:
       | https://blog.adafruit.com/2014/10/06/boiling-sous-vide-eggs-...
        
       | seiferteric wrote:
       | 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 wrote:
         | Reminds me of this project from MIT students where they built
         | an analog Segway:
         | 
         | https://techtv.mit.edu/videos/687f4627e5c14a52b24c694f7eeecf...
        
       | daxterspeed wrote:
       | 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 wrote:
         | 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...)
        
       | timvdalen wrote:
       | 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
        
       | dmarchand90 wrote:
       | I think I got a better insight into PID from this one page from
       | me entire control engineering course in university
        
         | regularfry wrote:
         | Yeah, that's the best explanation I think I've ever seen of the
         | I and D terms.
        
         | scrooched_moose wrote:
         | 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.
        
       | jagged-chisel wrote:
       | 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 wrote:
         | 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.
        
           | aidenn0 wrote:
           | My wife's Kia downshifts when you go more than a certain
           | amount over the set-speed, which lets it apply "negative"
           | throttle with engine braking.
        
           | jacques_chester wrote:
           | 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...
           | 
           | [1] Web search results are underwhelming, I refer you instead
           | to Douglas Montgomery's _Introduction to Statistical Process
           | Control_.
        
         | dls2016 wrote:
         | Hrm... I wonder if they use a feed-foward control taking into
         | account the angle of the dangle?
        
         | mauvehaus wrote:
         | In cars with manual transmissions, stepping on the clutch turns
         | off the cruise control. In one '96 Honda Civic I was driving, I
         | decided to see what happens if you slip it out of gear while
         | cruise control is on _without_ stepping on the clutch.
         | 
         | Answer: it revs the engine up. I hit the clutch before I got
         | the chance to find out whether the cruise control or the rev
         | limiter has ultimate authority. My guess is the rev limiter,
         | but I didn't want to bet on it.
         | 
         | Still, it's surprising that a computer that clearly knows
         | vehicle speed (well, wheel speed) and engine speed (presumably,
         | for engine control reasons) doesn't know that the vehicle is
         | out of gear (or suffering some kind of serious mechanical
         | malady) and respond appropriately.
        
         | chillingeffect wrote:
         | that's an example of non-linearity. probably the car only
         | applies throttle to regulate speed and not brakes.
         | 
         | home heating systems are similar in that the usually only add
         | heat.
         | 
         | in both cases, the PID would be generating the proper output,
         | but it doesn't have a means to drive the system consistent with
         | its output. e.g. it can't turn on the brakes, or air
         | conditioner.
        
       | pgt wrote:
       | I built a volume control system (hardware + software) using
       | mainly a PID controller: https://wallfly.webflow.io/
        
       ___________________________________________________________________
       (page generated 2020-05-18 23:00 UTC)