# PID autotuning - not working for heating application

Started by November 5, 2009
```"Frank W." wrote:

>"Tim Wescott" <tim@seemywebsite.com> wrote:
>
>> To hazard a guess, I'd say that one way or another when you command a 6%
>> drive to your heater you're getting 1/4 as much heat as when you command a
>> 12% drive

>95C steady state with 7% heat and 80C steady state with 3.5% heat. Heating

Did you consider possible long time constants for "steady state"? Slow
warming of enclosures can ruin your model extraction.

And what is "heat", IOW how do you control the heater - phase angle,
full wave? As Tim wrote, there might be a nonlinear function. And if
you control a SCR without mains synchronisation, you might get huge
uncertainties for low power values.

>from room temperature to 95C takes ~1min, cooling takes hours (cooling from
>95C to 80C takes 15min).

1k/min : 70k/min = 1.4%, that's not so far off from 3.5% to assume
nonlinear behaviour. And your cooling experiment might be influenced
by a hot environment.

Oliver
--
Oliver Betz, Munich
despammed.com might be broken, use Reply-To:
```
```"Oliver Betz" <obetz@despammed.com> wrote:
> And what is "heat", IOW how do you control the heater - phase angle,
> full wave?

Full wave. Phase angle is not permitted here with so much wattage.

> you control a SCR without mains synchronisation, you might get huge
> uncertainties for low power values.

The relay has a ZC circuit. 50hz power and 1s cycle time means 100 zero
crossings/cycle, ie. 1% granularity, equals 0.5% average error.

```
```"Frank W." <frankw_usenet@mailinator.com> wrote in message
news:7lggquF3dt584U1@mid.dfncis.de...
>
> Since all PID temperature controllers have Autotune, there must be a
> solution for this problem. Any ideas?

As you probably know from control theory, the basic theory of a PID
controller is that you have a system described by a set of linear
differential equations that is inherently unstable or has some performance
problems.  As a result you strap a PID controller onto it (with said
controller also described by its own linear differential equations), and the
resulting system (now described by linear differential equations which are a
mathematical mix of the underlying system and the PID controller) has better
characteristics.

Did you notice that there is a word that appears many times in my
description above?

Want to guess what the word is?

That word is "linear".

A system with a time delay is not described by linear differential
equations.  Strapping a PID controller onto it is bad math.

One of the more classic examples is a shower or an industrial process that
mixes fluids of varying temperature and the sensor is located substantially
downstream from the mixing value.  This is a pure time delay.  My shower at
home is like that.  I turn the water a little hotter.  Nothing happens.  I
turn it a little more hotter.  Nothing happens.  Then I turn it a little
more hotter.  Then the wave of hot liquid hits me and I scream in agony.

Over time, I've adapted to my shower.  I don't burn myself anymore.

I think the control algorithms you want to use for a system like yours fall
outside the range of PID.  I'm sure there is a body of theory that covers
it, but I don't know what that is.

I would heat the system full bore for a fixed period of time, then stop and
wait to see how the temperature catches up.  And work from there.

The best control strategy for that system isn't going to be PID.  That is a
non-linear system.

Datesfat

```
```"Datesfat Chicks" <datesfat.chicks@gmail.com> wrote in message
news:qZSdncz-fbqoB2TXnZ2dnUVZ_uGdnZ2d@giganews.com...
> "Frank W." <frankw_usenet@mailinator.com> wrote in message
> news:7lggquF3dt584U1@mid.dfncis.de...
>>
>> Since all PID temperature controllers have Autotune, there must be a
>> solution for this problem. Any ideas?
>
> As you probably know from control theory, the basic theory of a PID
> controller is that you have a system described by a set of linear
> differential equations that is inherently unstable or has some performance
> problems.  As a result you strap a PID controller onto it (with said
> controller also described by its own linear differential equations), and
> the resulting system (now described by linear differential equations which
> are a mathematical mix of the underlying system and the PID controller)
> has better characteristics.
>
> Did you notice that there is a word that appears many times in my
> description above?
>
> Want to guess what the word is?
>
> That word is "linear".
>
> A system with a time delay is not described by linear differential
> equations.  Strapping a PID controller onto it is bad math.
>
> One of the more classic examples is a shower or an industrial process that
> mixes fluids of varying temperature and the sensor is located
> substantially downstream from the mixing value.  This is a pure time
> delay.  My shower at home is like that.  I turn the water a little hotter.
> Nothing happens.  I turn it a little more hotter.  Nothing happens.  Then
> I turn it a little more hotter.  Then the wave of hot liquid hits me and I
> scream in agony.
>
> Over time, I've adapted to my shower.  I don't burn myself anymore.
>
> I think the control algorithms you want to use for a system like yours
> fall outside the range of PID.  I'm sure there is a body of theory that
> covers it, but I don't know what that is.
>
> I would heat the system full bore for a fixed period of time, then stop
> and wait to see how the temperature catches up.  And work from there.
>
> The best control strategy for that system isn't going to be PID.  That is
> a non-linear system.

From Wikipedia's entry on PID controllers:

http://en.wikipedia.org/wiki/PID_controller

<QUOTE>
Another problem faced with PID controllers is that they are linear. Thus,
performance of PID controllers in non-linear systems (such as HVAC systems)
is variable. Often PID controllers are enhanced through methods such as PID
gain scheduling or fuzzy logic. Further practical application issues can
arise from instrumentation connected to the controller. A high enough
sampling rate, measurement precision, and measurement accuracy are required
</QUOTE>

I don't know what the best control strategy is, but it ain't PID.

Datesfat

```
```On Tue, 10 Nov 2009 11:54:36 -0500, Datesfat Chicks wrote:

> "Frank W." <frankw_usenet@mailinator.com> wrote in message
> news:7lggquF3dt584U1@mid.dfncis.de...
>>
>> Since all PID temperature controllers have Autotune, there must be a
>> solution for this problem. Any ideas?
>
> As you probably know from control theory, the basic theory of a PID
> controller is that you have a system described by a set of linear
> differential equations that is inherently unstable or has some
> performance problems.  As a result you strap a PID controller onto it
> (with said controller also described by its own linear differential
> equations), and the resulting system (now described by linear
> differential equations which are a mathematical mix of the underlying
> system and the PID controller) has better characteristics.
>
> Did you notice that there is a word that appears many times in my
> description above?
>
> Want to guess what the word is?
>
> That word is "linear".
>
> A system with a time delay is not described by linear differential
> equations.  Strapping a PID controller onto it is bad math.
>
> One of the more classic examples is a shower or an industrial process
> that mixes fluids of varying temperature and the sensor is located
> substantially downstream from the mixing value.  This is a pure time
> delay.  My shower at home is like that.  I turn the water a little
> hotter.  Nothing happens.  I turn it a little more hotter.  Nothing
> happens.  Then I turn it a little more hotter.  Then the wave of hot
> liquid hits me and I scream in agony.
>
> Over time, I've adapted to my shower.  I don't burn myself anymore.
>
> I think the control algorithms you want to use for a system like yours
> fall outside the range of PID.  I'm sure there is a body of theory that
> covers it, but I don't know what that is.
>
> I would heat the system full bore for a fixed period of time, then stop
> and wait to see how the temperature catches up.  And work from there.
>
> The best control strategy for that system isn't going to be PID.  That
> is a non-linear system.

I've been resisting forking this over into the control newsgroup: now
it's compelling.

Systems with delay can be perfectly linear, as well as time invariant --
they just can't be described by ordinary differential equations with a
finite number of states.

To be linear, a system only needs to satisfy the superposition property.
A delay element satisfies superposition just fine.

And while a PID controller may not be the theoretically best controller
for a system with delay, in many cases it's not a bad choice at all.  PID
controllers can and will give perfectly satisfactory service with plants
that have significant delay.  The thousands, if not millions, of PID
controllers in mills and factories around the world that are controlling
plants whose responses are dominated by delay certainly belie any
declaration that the PID controller isn't a good choice to control a
plant with delay.

None of the above is intended to minimize the difficulty in analyzing and
designing a truly optimal controller for a plant with pure delay --
that's an exercise that can make your brain hurt, and fast.  And nothing
of the above is intended to chase you away from taking plant delays more
directly into account if a discrete-state controller such as a PID won't
let you eke the performance that you need out of your plant.

But in the absence of significant nonlinearities or time varying behavior
you can use all the analysis tools that are suitable for linear time
invariant systems on a system with delays just fine.  You can do good
design work, without ever having to explicitly write out the differential
equations, much less solving them.

So if you don't want to get lost in Mathemagic Land searching for
performance that isn't necessary for your product's success, a good ol'
PID controller may be exactly the optimal controller -- in terms of
adequate performance and reasonable engineering time -- even if it
particular plant you're trying to control.

--
www.wescottdesign.com
```
```"Tim Wescott" <tim@seemywebsite.com> wrote in message
news:rPCdnSIjis5QNWTXnZ2dnUVZ_oli4p2d@web-ster.com...
>
> Systems with delay can be perfectly linear, as well as time invariant --
> they just can't be described by ordinary differential equations with a
> finite number of states.

Hi Tim,

I might have missed something significant here.

It is my assumption that a system with a pure time delay is inherently
non-linear.

Let's take my shower example with a pure delay in the pipes ...

With no delay, you can just say that

Temperature(t) = Valve_Position

or perhaps with a little thermal mass thrown in you can say that:

d Temperature / dt = K * (Valve_Position - Temperature)

where of course I'm assuming that valve position and water temperature are
the same thing.

The first is I think a 0'th order linear differential equation and the
second is a 1st-order LDE.

But how would you linearize a system with a pure time delay, exactly?

The shower example with a pure pipe delay between the shower valve and my
skin is fine.

Thanks, Datesfat

```
```Datesfat Chicks wrote:
> "Tim Wescott" <tim@seemywebsite.com> wrote in message
> news:rPCdnSIjis5QNWTXnZ2dnUVZ_oli4p2d@web-ster.com...
>>
>> Systems with delay can be perfectly linear, as well as time invariant
>> -- they just can't be described by ordinary differential equations with a
>> finite number of states.
>
> Hi Tim,
>
> I might have missed something significant here.
>
> It is my assumption that a system with a pure time delay is inherently
> non-linear.

Superposition is sufficient proof of linearity. What comes out of a pipe
(assuming that there is no mixing in transit) is almost a delayed linear
superopsition of what is pushed into it, but it is not linear because it
is not a pure delay. When the input velocity increases because both hot
and cold water are flowing, the delay time decreases. Superposition
doesn't strictly apply because the time to look isn't well defined.

Any delay pushes a servo system toward unstable. That's not a linearity
problem.

> Let's take my shower example with a pure delay in the pipes ...
>
> With no delay, you can just say that
>
>   Temperature(t) = Valve_Position
>
> or perhaps with a little thermal mass thrown in you can say that:
>
>   d Temperature / dt = K * (Valve_Position - Temperature)
>
> where of course I'm assuming that valve position and water temperature
> are the same thing.

There's also the time it takes the valve to move.

> The first is I think a 0'th order linear differential equation and the
> second is a 1st-order LDE.
>
> But how would you linearize a system with a pure time delay, exactly?

> The shower example with a pure pipe delay between the shower valve and
> my skin is fine.

But, as I wrote above, a pipe is onlt a pure delay as long as the flow
is constant.

Jerry
--
Engineering is the art of making what you want from things you can get.
&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;
```
```On Nov 5, 9:37=A0am, "Frank W." <frankw_use...@mailinator.com> wrote:
> Is there a control engineering expert here?
Yes.
> Since all PID temperature controllers have Autotune, there must be a
> solution for this problem.
Some auto tuning algorithms are pretty crude and I think some
companies implement the simplest auto tuning algorithms just to say
they have one.  It is a marketing thing.  How are the customers to
know the difference?  If they knew the difference they wouldn't need
the auto tuning.

> Any ideas?
Turn down the gain for one.  It looks like the control output , gray
bar, amplitude is variable and not a simple on/off SSR.
Because the plant responds so quickly to the output I think the PID
update time should be faster but then the lack of resolution
will be a limitation.  Using the derivative gain may be handy to but
again the lack of resolution will be a factor.
A tried and true method is the feed forward. If one know how much
control output is require for every temperature then one can compute
the control output and be with a percent or two without even using the
PID gains.  The PID gains are just used to correct for errors in the
feed forward predictions.
You should be able to get very close with a feed forward and a
proportional gain.  The integrator will simply remove the last bit of
error.

Auto tune works great when the plant matches the model AND the system
is properly excited.  If not then auto tune doesn't work so well.  Are
the water levels in the boiler constant?  If not can the water level
be detected?  Obviously the temperature will rise more slow or not as
fast if the boiler is full of water as opposed to being empty.

Does the tuning need to be better for a coffee machine?  Manual tuning
should be easy enough.

When I get serious I prefer to make a model of the system.  The
excitation requires a few steps in the control output.  The steps
should be big enough so the response is clearly more significant than
the noise.  The dead time should be clearly visible and the same goes
for the rise time. One can often get the plant gain, time constant and
dead time by inspection.  If not then one must log the control output
and the response.  Then one fits a FOPDT or SOPDT model to your coffee
machine.  I do this using Scilab's optim or lsqrsolve.  Then one goes
to the www.controlguru.com site and uses the IMC, internal model
control, equations there for computing the gains.  For a FOPDT
Kc=3Dt1/((tc+dt)*K)
ti=3Dt1
Where:
Kc is the controller gain.  It should have units of %output per
degree.
ti is the integrator time constant which is usually in minutes.
t1 is the plant time constant
K is the plant gain.  This has units of degree per % control output.
tc is the closed loop time constant.  tc is made smaller for more
aggressive tuning and longer for more conservative tuning.  The value
for tc is dependent on the plant time constant and dead time.  The
formula for tc on on the www.controlguru.com site.

You can see from the equation that the dead time reduces the gain.
Also, if the plant gain changes due to the water level then K will be
a function of water and the controller gain will then be modified as a
function of water level.
Kc=3Dt1/((tc+dt)*K(WaterLevel))

I would start here.  Once the plant gain, time constant and dead time
are know there are other options.  On the www.controlguru.com site
there are formulas for adding the derivative time constant td.   One
can also implement a Smith Predictor.   A Smith Predictor isn't that
hard to implement.  The hard part is finding the plant parameters.

I talked to someone else on the phone about making a high end coffee
or espresso machine a few months back.  Our product was gross overkill
but would have made a nice research tool.

Peter Nachtwey
```
```On Tue, 10 Nov 2009 13:24:00 -0500, Datesfat Chicks wrote:

> "Tim Wescott" <tim@seemywebsite.com> wrote in message
> news:rPCdnSIjis5QNWTXnZ2dnUVZ_oli4p2d@web-ster.com...
>>
>> Systems with delay can be perfectly linear, as well as time invariant
>> -- they just can't be described by ordinary differential equations with
>> a finite number of states.
>
> Hi Tim,
>
> I might have missed something significant here.
>
> It is my assumption that a system with a pure time delay is inherently
> non-linear.
>
> Let's take my shower example with a pure delay in the pipes ...
>
> With no delay, you can just say that
>
>    Temperature(t) = Valve_Position
>
> or perhaps with a little thermal mass thrown in you can say that:
>
>    d Temperature / dt = K * (Valve_Position - Temperature)
>
> where of course I'm assuming that valve position and water temperature
> are the same thing.
>
> The first is I think a 0'th order linear differential equation and the
> second is a 1st-order LDE.
>
> But how would you linearize a system with a pure time delay, exactly?
>
> The shower example with a pure pipe delay between the shower valve and
> my skin is fine.
>
> Thanks, Datesfat

Well, if it's already linear you don't linearize it.

Take the system y = h(x, t) ==> y(t) = x(t - td).  Testing this with
superposition we get

y1(t) = x1(t - td),
y2(t) = x2(t - td),

y1(t) + y2(t) = x1(t - td) + x2(t - td)

which is both h(x1, t) + h(x2, t) and h(x1 + x2, t) -- therefore the
system is linear.

Note that as Jerry points out a shower isn't necessarily a linear system,
unless your shower valve insures a constant flow and the pipes don't have
any turbulence.  Let a vastly simplified version be

y(t) = x(t - kd * x(t)),

(this doesn't capture the delay behavior in even a perfect pipe)

Then we try superposition:

y1(t) = x1(t - kd * x1(t)),
y2(t) = x2(t - kd * x2(t)).

This does _not_ equal the system output to the sum:

ys(t) = x1(t - kd * (x1(t) + x2(t))) + x2(t - kd * (x1(t) + x2(t))).

so this system isn't linear -- but not for the reason that you thought.

--
www.wescottdesign.com
```
```On Tue, 10 Nov 2009 12:45:24 -0800, pnachtwey wrote:

> On Nov 5, 9:37&nbsp;am, "Frank W." <frankw_use...@mailinator.com> wrote:
>> Is there a control engineering expert here?
> Yes.
>> Since all PID temperature controllers have Autotune, there must be a
>> solution for this problem.
> Some auto tuning algorithms are pretty crude and I think some companies
> implement the simplest auto tuning algorithms just to say they have one.
>  It is a marketing thing.  How are the customers to know the difference?
>  If they knew the difference they wouldn't need the auto tuning.

-- snip --

> Auto tune works great when the plant matches the model AND the system is
> properly excited.  If not then auto tune doesn't work so well.  Are the
> water levels in the boiler constant?  If not can the water level be
> detected?  Obviously the temperature will rise more slow or not as fast
> if the boiler is full of water as opposed to being empty.
>
> Does the tuning need to be better for a coffee machine?  Manual tuning
> should be easy enough.

-- snip --

> I talked to someone else on the phone about making a high end coffee or
> espresso machine a few months back.  Our product was gross overkill but
> would have made a nice research tool.
>
> Peter Nachtwey

Speaking of overkill, why not just use an on-off thermostat with some
hysteresis?  Energy consumption?  Lack of cool?

For that matter, how about modeling the whole range of coffeemakers that
you expect (or that you're willing to warrant the device as working).
Then see if you can get reasonable performance with just one tuning
setting*.  Then instead of telling the customer he can mess around with
autotune, you can tell him he can just plug & play.

* I've done this on blood pressure monitor; we expected to need four
different tunings for the whole range of cuffs from 'premie arm' to 'fat
guy thigh', and ended up needing just one.

--
www.wescottdesign.com
```