[HN Gopher] PID Controller: A Simple Control Loop Mechanism
       ___________________________________________________________________
        
       PID Controller: A Simple Control Loop Mechanism
        
       Author : vackosar
       Score  : 38 points
       Date   : 2021-05-28 18:34 UTC (4 hours ago)
        
 (HTM) web link (vaclavkosar.com)
 (TXT) w3m dump (vaclavkosar.com)
        
       | oceanghost wrote:
       | If I may recommend "PID without a PHD"
       | 
       | https://www.wescottdesign.com/articles/pid/pidWithoutAPhd.pd...
        
       | Animats wrote:
       | Wasn't there an HN article recently which linked to a useful site
       | on PID controller tuning? That was interesting. PID controllers
       | are easy to create but hard to tune.
        
         | shawnz wrote:
         | See https://news.ycombinator.com/item?id=27273399
        
       | valbaca wrote:
       | I worked with a PID controller in college. It's a concept that's
       | stuck with me to this day.
       | 
       | https://en.wikipedia.org/wiki/PID_controller
       | 
       | Proportional-integral-derivative
       | 
       | P: proportional, this one is obvious. Water is WAY too cold, turn
       | the knob WAY up
       | 
       | I: integral, how long does it take for feedback to take effect.
       | You don't want to turn the knob up and up each second if it takes
       | 10 seconds for the change to take effect.
       | 
       | D: derivative, a bit trickier.
       | 
       | What's really interesting is seeing how humans apply these
       | concepts, which are so intuitive to things like balance, we don't
       | even think about them. In face we'll apply them to where they
       | don't apply or are faulty. You'll see it when people learn to
       | back up a car for the first time or start winning at blackjack.
        
         | chowells wrote:
         | Your description for Integral is how the Derivative term is
         | used.
         | 
         | Proportional: set the control based on a multiple of the
         | difference between the current and the target.
         | 
         | Integral: adjust that setting based on cumulative difference
         | over time. This handles the case where the proportional setting
         | isn't providing enough of a change.
         | 
         | Derivative: adjust the setting based on how fast the current
         | value is approaching the target value. This provides damping
         | when the error is decreasing rapidly to minimize overshoot and
         | oscillation around the target.
         | 
         | What's interesting is that a lot of controllers leave out the
         | derivative term. Car cruise controls are often only PI, for
         | instance. This works best when it's ok to approach the target
         | slowly anyway, so oscillation is minimal.
        
           | jbay808 wrote:
           | > What's interesting is that a lot of controllers leave out
           | the derivative term
           | 
           | This is because a PD controller controlling system X is
           | equivalent to a PI controller for the system (dX/dt). For
           | example, a PI controller adjusting force to control velocity
           | is equivalent to a PD controller adjusting force to control
           | position.
           | 
           | If your system has a strong "momentum-like" term (larger than
           | its damping), you need a derivative term to stabilize it. So
           | a force-position controller needs D, but a room heater does
           | not, because when you stop heating the room, the temperature
           | doesn't keep coasting upwards (usually - there can be some
           | phase lag if your sensor is far from your heater, or if your
           | room is on fire).
           | 
           | A force-velocity controller (cruise control) also does not
           | have "momentum", as you can see from the fact that if you
           | stop applying force, velocity stops increasing immediately.
        
             | thrdbndndn wrote:
             | Speaking of room heater, I remembered when I was studying
             | on control theory in university and learned PID, I was
             | thinking "this thing is so simple and yet so effective, it
             | gotta be everywhere!".
             | 
             | It's a little bit disappointing when I later realized that
             | most of heater/air conditioner basically just use on/off
             | control with a deadband. I guess the limiting factor here
             | isn't the controller but the actuator part, but still a
             | let-down to see them being so primitive.
        
               | analog31 wrote:
               | Interestingly, I've seen mechanical on/off controllers
               | with a tiny heater on the sensor, turning it into a time
               | proportioning controller.
        
               | jay3ss wrote:
               | From what I can recall from my optimal controls course
               | using on/off is actually an optimal controller.
               | 
               | Edit: It's called a bang-bang controller [0]
               | 
               | [0]:
               | https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control
        
               | jbay808 wrote:
               | Yeah, hysteresis control aka "bang bang" control can also
               | be unreasonably effective.
               | 
               | It's a natural choice when your furnace can't throttle,
               | or can but operates most efficiently at one output level
               | anyway.
               | 
               | Since the system always pushes as hard as it can, it
               | automatically reaches the setpoint in the minimum
               | possible time. It's almost like a PID controller with
               | infinite gain. But the tradeoff is jitter -- all the
               | error gets pushed up to the highest frequency bands. As
               | long as you don't care about that in your system, it's a
               | great choice and effortless to tune.
               | 
               | It can also be a bad choice if there's any cost to
               | changing or toggling the output, like if your furnace
               | wears out from switching on and off a lot.
        
               | shawnz wrote:
               | On-off or "bang-bang" control actually makes a lot of
               | sense for home thermostats. For example consider:
               | 
               | - With a home thermostat you probably want it to reach
               | the desired temperature as quickly as possible. PID will
               | never reach the setpoint as fast as bang-bang control
               | since bang-bang control will always use the maximum
               | possible power.
               | 
               | - PID might help you avoid overshooting the desired
               | temperature but that's not really an important issue for
               | a home furnace. In fact it might be better if it
               | overshoots the desired temperature a bit on very cold
               | days.
               | 
               | - The air in the home acts like a big thermal battery
               | that helps negate the need for a sophisticated
               | controller.
               | 
               | PID works very good for a wide variety of situations but
               | it's important to remember it is not always the best tool
               | for every job. In that way it is kind of like
               | "quicksort".
        
       ___________________________________________________________________
       (page generated 2021-05-28 23:00 UTC)