Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.arch.embedded > #29691 > unrolled thread

PID controller: dummy questions

Started bypozz <pozzugno@gmail.com>
First post2020-06-25 19:55 +0200
Last post2020-06-28 13:10 -0400
Articles 8 on this page of 28 — 9 participants

Back to article view | Back to comp.arch.embedded


Contents

  PID controller: dummy questions pozz <pozzugno@gmail.com> - 2020-06-25 19:55 +0200
    Re: PID controller: dummy questions Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2020-06-25 21:14 +0200
    Re: PID controller: dummy questions DJ Delorie <dj@delorie.com> - 2020-06-25 15:29 -0400
      Re: PID controller: dummy questions David Brown <david.brown@hesbynett.no> - 2020-06-26 08:43 +0200
    Re: PID controller: dummy questions Richard Damon <Richard@Damon-Family.org> - 2020-06-25 22:21 -0400
    Re: PID controller: dummy questions pozz <pozzugno@gmail.com> - 2020-06-26 10:59 +0200
      Re: PID controller: dummy questions David Brown <david.brown@hesbynett.no> - 2020-06-26 11:07 +0200
      Re: PID controller: dummy questions Rick C <gnuarm.deletethisbit@gmail.com> - 2020-06-26 09:10 -0700
      Re: PID controller: dummy questions Richard Damon <Richard@Damon-Family.org> - 2020-06-26 12:29 -0400
        Re: PID controller: dummy questions Rick C <gnuarm.deletethisbit@gmail.com> - 2020-06-26 12:00 -0700
          Re: PID controller: dummy questions Richard Damon <Richard@Damon-Family.org> - 2020-06-26 22:24 -0400
            Re: PID controller: dummy questions Paul Rubin <no.email@nospam.invalid> - 2020-06-26 21:41 -0700
              Re: PID controller: dummy questions DJ Delorie <dj@delorie.com> - 2020-06-27 01:15 -0400
                Re: PID controller: dummy questions Paul Rubin <no.email@nospam.invalid> - 2020-06-26 23:12 -0700
                  Re: PID controller: dummy questions Rick C <gnuarm.deletethisbit@gmail.com> - 2020-06-27 00:07 -0700
                    Re: PID controller: dummy questions pozz <pozzugno@gmail.com> - 2020-06-27 16:53 +0200
                      Re: PID controller: dummy questions David Brown <david.brown@hesbynett.no> - 2020-06-27 17:31 +0200
                        Re: PID controller: dummy questions Rick C <gnuarm.deletethisbit@gmail.com> - 2020-06-27 10:09 -0700
                          Re: PID controller: dummy questions Rick C <gnuarm.deletethisbit@gmail.com> - 2020-06-27 15:44 -0700
                      Re: PID controller: dummy questions Richard Damon <Richard@Damon-Family.org> - 2020-06-27 12:34 -0400
                  Re: PID controller: dummy questions DJ Delorie <dj@delorie.com> - 2020-06-27 11:51 -0400
              Re: PID controller: dummy questions Rick C <gnuarm.deletethisbit@gmail.com> - 2020-06-26 23:06 -0700
                Re: PID controller: dummy questions Paul Rubin <no.email@nospam.invalid> - 2020-06-26 23:18 -0700
                  Re: PID controller: dummy questions Rick C <gnuarm.deletethisbit@gmail.com> - 2020-06-27 00:23 -0700
              Re: PID controller: dummy questions Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2020-06-27 10:28 +0300
              Re: PID controller: dummy questions Richard Damon <Richard@Damon-Family.org> - 2020-06-27 18:13 -0400
      Re: PID controller: dummy questions Hans-Bernhard Bröker <HBBroeker@t-online.de> - 2020-06-26 22:30 +0200
        Re: PID controller: dummy questions Phil Martel <pomartel@comcast.net> - 2020-06-28 13:10 -0400

Page 2 of 2 — ← Prev page 1 [2]


#29721

FromDJ Delorie <dj@delorie.com>
Date2020-06-27 11:51 -0400
Message-ID<xnsgegcxs5.fsf@delorie.com>
In reply to#29708
Paul Rubin <no.email@nospam.invalid> writes:
> Do you mean it saturates (controller stops increasing it once it reaches
> some maximum)?  Ok, but won't it reach the maximum and stay there?  The
> Ki math I think was:
>
>   I += Ki * err   (note += not = )
>   Vout = P + I
>
> So if the error is almost always positive, I will keep increasing.

The error is *after* all three PID factors are added.  The I factor
reduces the error.  If it reduces the error to zero, the I term stops
increasing.

In real life terms, consider this: you want to heat a pot of water to a
slow boil.  You turn on the stove, at first a lot as a "guess" but as
the pot approaches the boiling you turn the heat down (P term).
Eventually you have to start tweaking the heat up a bit to bring the
temperature up, this is the I term.  As you approach the right temp, you
tweak in smaller increments, until you're there.

> I'm imagining a tank starting with 20 degree water and you want to heat
> it to 50 degrees.  Now the error is 30 degrees, or am I interpreting the
> wrong thing as the error?

Error is 30.

> You turn on the heat and the error decreases
> as the water gets hotter.  Eventually the water reaches 50 degrees and
> the error is 0, but I is some positive number (the integral of the error
> over the time it took to reach 50 degrees).

Better example: when the heat gets to 45 degrees (error=5) the P term
has been reduced enough that the water doesn't get any warmer.  If the
water were to warm up, the heat would be reduced, and it would cool
again.  You've reached steady state, and this is as close as the P term
can get you.  This happens relatively quickly.  Let's say the P term is
providing 500 watts at this point.

Now, you need a little more heat to make up the difference.

The I term sees the small remaining error, and slowly adds more heat,
until the temperature slowly climbs to the set point.  The I term might
be adding another 5 watts or so

> Now you draw out some hot water,

And the error quickly jumps up, the P term immediately reacts.  The I
term slowly starts rising again.  More heat pours in.  The temperature
might rise past the set point, but then the error is *negative* and the
I term slowly goes down until it's back where we started.

> But really, the error will always be either positive or near 0.  So I
> keeps increasing.
> I have to be missing something.  Thanks.

You're missing that if the I term keeps increasing, eventually the water
will be too hot, the error negative, and that reduces the I term again.

It's like the pot on the stove.  You turn the heat up until the water is
the right temperature, but if you *keep* turning the knob up, the water
becomes too hot, and you have to turn the knob back down again.

[toc] | [prev] | [next] | [standalone]


#29707

FromRick C <gnuarm.deletethisbit@gmail.com>
Date2020-06-26 23:06 -0700
Message-ID<cd9742f1-b875-42e8-bbe0-063f54fe361fo@googlegroups.com>
In reply to#29704
On Saturday, June 27, 2020 at 12:41:31 AM UTC-4, Paul Rubin wrote:
> Richard Damon <Richard@Damon-Family.org> writes:
> > 2) It can go to some finite, non-zero state. This indicated neither a
> > pole or zero near zero. A proportional controller will have a finite
> > error result, so you may want an integral term in the system.
> 
> Slightly tangential but can someone explain if the integral term is
> supposed to decay?  Otherwise, can't it potentially keep getting bigger
> and bigger without bound?  E.g. in a thermal system, you have to keep
> adding heat to account for losses, or for (say) hot water being drawn
> out of a water heater, and being replaced by incoming cold water.

You are missing the point that the output of the controller is the rate of added heat, i.e. heat flow, not some quantity of heat added.  The integral term accounts for the base heat flow required to maintain the set temperature.  After that is achieved by the integral term ramping up as needed the proportional term minimizes fluctuations from short term variations in the heat flow out of the system.  

In the water heater example the integral term will be ramping up the entire time the heater is not up to temperature.  The rate of increase of the heat flowing in will lower until the set point is achieved at which point the integral term will be at a maximum, but too high with the water temperature continuing to rise.  Once the temperature rises above the set point the integral ramps down until it reaches a minimum with the temperature too low again.  With the proportional gain set much higher than the integral gain, these overshoots will diminish, but never be eliminated.  Adding in the derivative term with the right setting will allow the temperature to ramp up in a critically damped manner without overshoot... in theory.  I've always settled for the damped oscillations rather than trying to deal with the added noise from a derivative term.  

-- 

  Rick C.

  -- Get 1,000 miles of free Supercharging
  -- Tesla referral code - https://ts.la/richard11209

[toc] | [prev] | [next] | [standalone]


#29709

FromPaul Rubin <no.email@nospam.invalid>
Date2020-06-26 23:18 -0700
Message-ID<87wo3tyqta.fsf@nightsong.com>
In reply to#29707
Rick C <gnuarm.deletethisbit@gmail.com> writes:
> In the water heater example the integral term will be ramping up the
> entire time the heater is not up to temperature.  The rate of increase
> of the heat flowing in will lower until the set point is achieved at
> which point the integral term will be at a maximum, but too high with
> the water temperature continuing to rise.

Let's say the water heater is insulated, but not perfectly (which is
impossible).  That means heat steadily escapes from the system and you
have to keep adding energy to maintain the temperature.  That is, the
error (difference between measured temperature and goal temperature) is
always positive or zero, except maybe for a few moments when you
overshoot slightly.  Therefore, the integral of the error should keep
increasing.

I tried reading the Wikipedia article about PID and thought I understood
it, but still come away from it with the same impression.  I'm clearly
missing something.

[toc] | [prev] | [next] | [standalone]


#29712

FromRick C <gnuarm.deletethisbit@gmail.com>
Date2020-06-27 00:23 -0700
Message-ID<4a32b0f7-72b2-41a5-b908-9de99dde7033o@googlegroups.com>
In reply to#29709
On Saturday, June 27, 2020 at 2:18:44 AM UTC-4, Paul Rubin wrote:
> Rick C <gnuarm.deletethisbit@gmail.com> writes:
> > In the water heater example the integral term will be ramping up the
> > entire time the heater is not up to temperature.  The rate of increase
> > of the heat flowing in will lower until the set point is achieved at
> > which point the integral term will be at a maximum, but too high with
> > the water temperature continuing to rise.
> 
> Let's say the water heater is insulated, but not perfectly (which is
> impossible).  That means heat steadily escapes from the system and you
> have to keep adding energy to maintain the temperature.  That is, the
> error (difference between measured temperature and goal temperature) is
> always positive or zero, except maybe for a few moments when you
> overshoot slightly.  Therefore, the integral of the error should keep
> increasing.
> 
> I tried reading the Wikipedia article about PID and thought I understood
> it, but still come away from it with the same impression.  I'm clearly
> missing something.

Your mistake is thinking the integral term will only overshoot "slightly".  Once the integral term rises to heat the added water it is too high to maintain the temperature of the take once it reaches the set point.  So the error will shoot past the zero point and become negative quickly.  The integrator doesn't make the temperature rise to gently reach the set point.  At the point the temperature crosses the set point it increasing the fastest it will move.  So now the error has to be negative for a while to bring it back to zero from the other direction.  

Increasing the gain on the proportional term and keeping the gain on the integral term low will minimize the ripples, but never eliminate them.  So the error will always wing positive and negative.  

You need to keep in mind that if the integral term is high, the heat output will be high.  Thinking the set point will only be passed a little bit is not accurate.  You need to stop "feeling" the design and try looking at some real numbers.  

If LTspice is too complicated for you, you can use a spread sheet to make calculations in a stepwise manner.  Write the equations for the three controller terms and one for the combined heat output based on the previous values.  Write the equations for the heat output (losses) based on present temperature and the intermittent water draw.  Write the equations for the temperature of the tank in terms of the previous temperature and the heat inputs and outputs.  

Copy each of these from one row to the next for many rows and watch the temperature change across the rows.  I evaluate DSP algorithms this way.  You can even chart the columns to see temperature and the heat flows change and watch the oscillations of temperature and heat output. 

-- 

  Rick C.

  +- Get 1,000 miles of free Supercharging
  +- Tesla referral code - https://ts.la/richard11209

[toc] | [prev] | [next] | [standalone]


#29713

FromTauno Voipio <tauno.voipio@notused.fi.invalid>
Date2020-06-27 10:28 +0300
Message-ID<rd6sf4$r4r$1@dont-email.me>
In reply to#29704
On 27.6.20 07:41, Paul Rubin wrote:
> Richard Damon <Richard@Damon-Family.org> writes:
>> 2) It can go to some finite, non-zero state. This indicated neither a
>> pole or zero near zero. A proportional controller will have a finite
>> error result, so you may want an integral term in the system.
> 
> Slightly tangential but can someone explain if the integral term is
> supposed to decay?  Otherwise, can't it potentially keep getting bigger
> and bigger without bound?  E.g. in a thermal system, you have to keep
> adding heat to account for losses, or for (say) hot water being drawn
> out of a water heater, and being replaced by incoming cold water.


The integral term is supposed to approach a stable value, to
compensate for the steady-state error of pure proportional
control. What is supposed to decay is the total error term.

-- 

-TV

[toc] | [prev] | [next] | [standalone]


#29728

FromRichard Damon <Richard@Damon-Family.org>
Date2020-06-27 18:13 -0400
Message-ID<gwPJG.46650$HY4.18722@fx37.iad>
In reply to#29704
On 6/27/20 12:41 AM, Paul Rubin wrote:
> Richard Damon <Richard@Damon-Family.org> writes:
>> 2) It can go to some finite, non-zero state. This indicated neither a
>> pole or zero near zero. A proportional controller will have a finite
>> error result, so you may want an integral term in the system.
> 
> Slightly tangential but can someone explain if the integral term is
> supposed to decay?  Otherwise, can't it potentially keep getting bigger
> and bigger without bound?  E.g. in a thermal system, you have to keep
> adding heat to account for losses, or for (say) hot water being drawn
> out of a water heater, and being replaced by incoming cold water.
> 

The integral term is supposed to be a pure integral, no decay. It will
only keep getting bigger if you keep having error of the same sign.

Often, limits are put on the integration, to limit the overshoot from
'windup' as the system tries to get close or special rules to hold the
integrator when the P-D part of the loop is driving hard.

[toc] | [prev] | [next] | [standalone]


#29702

FromHans-Bernhard Bröker <HBBroeker@t-online.de>
Date2020-06-26 22:30 +0200
Message-ID<hln46jF6c4kU1@mid.dfncis.de>
In reply to#29696
Am 26.06.2020 um 10:59 schrieb pozz:
> 
> The proportional term (P) of a PID controller can't mimic this "manual 
> control", 

Nobody ever claimed it could.  A P-only controller simply won't meet 
that goal.

That's a large part of the reason why everybody routinely talks about 
full PID-controllers.

People know better than to just react linearly.  You would be doing a 
good deal of D- and I-type controlling, too, and most likely some more 
that doesn't fit into the PID model at all.  Especially if it's not the 
first time ever you've been turning that knob.  You will have got a 
"feel" for it after just a few tries.

Nobody in their right mind ever claimed the human brain was as bluntly 
stupid as a P controller.  A PID controller is still way simpler than 
what you would do yourself.  We use them not because they're better at 
the job than humans, but rather because they're cheaper and more 
reliable in the long run.

All said, I believe your apparent frustration at the answer you've found 
has more to do with asking the wrong question than with anything else.

[toc] | [prev] | [next] | [standalone]


#29743

FromPhil Martel <pomartel@comcast.net>
Date2020-06-28 13:10 -0400
Message-ID<ba4KG.51163$%p.11040@fx33.iad>
In reply to#29702
On 6/26/2020 16:30, Hans-Bernhard Bröker wrote:
> Am 26.06.2020 um 10:59 schrieb pozz:
>>
>> The proportional term (P) of a PID controller can't mimic this "manual 
>> control", 
> 
> Nobody ever claimed it could.  A P-only controller simply won't meet 
> that goal.
> 
> That's a large part of the reason why everybody routinely talks about 
> full PID-controllers.
> 
> People know better than to just react linearly.  You would be doing a 
> good deal of D- and I-type controlling, too, and most likely some more 
> that doesn't fit into the PID model at all.  Especially if it's not the 
> first time ever you've been turning that knob.  You will have got a 
> "feel" for it after just a few tries.
> 
> Nobody in their right mind ever claimed the human brain was as bluntly 
> stupid as a P controller.  A PID controller is still way simpler than 
> what you would do yourself.  We use them not because they're better at 
> the job than humans, but rather because they're cheaper and more 
> reliable in the long run.
> 
> All said, I believe your apparent frustration at the answer you've found 
> has more to do with asking the wrong question than with anything else.

I've found Tim Wescott's website helpful
https://www.wescottdesign.com/

Especially this:
https://www.wescottdesign.com/articles/pid/pidWithoutAPhd.pdf


-- 
Best wishes,
--Phil
pomartel At Comcast(ignore_this) dot net

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.arch.embedded


csiph-web