# I don't understand thermostats

Started by July 14, 2015
```
Imagine a mass that we want to heat with some closed-loop controller.
It's C2 below. Voltage represents temperature. Thermal systems are
diffusive, which we represent as a bunch of RC lags. Assume the
voltage at C4 is the temperature sensor.

If I were to design a PID controller, I'd have to really think about
it, or fiddle some, to keep it stable. But if I do a dumb on/off
thermostat, it seems to always work. I can tweak the hysteresis and
vary the p-p temperature excursions and the switching frequency, but
it's always stable. Or maybe it's always unstable. But it works.

As Vh gets smaller, the oscillation frequency converges to some
limiting value, which is I guess the ultimate performance of a
thermostat for this physics. To get any less temperature excursion, I
guess I'd have to do a real PID loop. Curious.

This may have something to do with the fact that there is no thermal
equivalent to an inductor.

Version 4
SHEET 1 880 680
WIRE 0 0 -288 0
WIRE 528 0 80 0
WIRE -288 160 -288 0
WIRE -224 160 -288 160
WIRE -96 160 -144 160
WIRE -16 160 -96 160
WIRE 96 160 64 160
WIRE 192 160 96 160
WIRE 304 160 272 160
WIRE 416 160 304 160
WIRE 528 160 528 0
WIRE 528 160 480 160
WIRE -288 224 -288 160
WIRE -96 224 -96 160
WIRE 96 224 96 160
WIRE 304 224 304 160
WIRE -288 336 -288 288
WIRE -96 336 -96 288
WIRE 96 336 96 288
WIRE 304 336 304 288
FLAG -288 336 0
FLAG -96 336 0
FLAG 96 336 0
FLAG 304 336 0
SYMBOL Digital\\schmtinv 416 96 R0
WINDOW 0 2 -10 Left 2
WINDOW 3 -30 23 Left 2
SYMATTR InstName A1
SYMATTR Value Vh=0.002
SYMBOL cap 80 224 R0
WINDOW 0 67 13 Left 2
WINDOW 3 64 44 Left 2
SYMATTR InstName C1
SYMATTR Value 1m
SYMBOL cap -112 224 R0
WINDOW 0 63 18 Left 2
WINDOW 3 64 53 Left 2
SYMATTR InstName C2
SYMATTR Value 5m
SYMBOL cap -304 224 R0
WINDOW 0 60 22 Left 2
WINDOW 3 66 53 Left 2
SYMATTR InstName C3
SYMATTR Value 1m
SYMBOL res -128 144 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R1
SYMATTR Value 1K
SYMBOL res 80 144 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R2
SYMATTR Value 1K
SYMBOL res 96 -16 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R3
SYMATTR Value 1K
SYMBOL cap 288 224 R0
WINDOW 0 67 13 Left 2
WINDOW 3 64 44 Left 2
SYMATTR InstName C4
SYMATTR Value 1m
SYMBOL res 288 144 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R4
SYMATTR Value 1K
TEXT -208 -56 Left 2 !.tran 50 uic
TEXT 192 -88 Left 2 ;THERMOSTAT
TEXT 192 -48 Left 2 ;JL  July 14, 2015
TEXT -72 80 Left 2 ;===== thermal lags =====

--

John Larkin         Highland Technology, Inc
picosecond timing   precision measurement

jlarkin att highlandtechnology dott com
http://www.highlandtechnology.com

```
```On Tuesday, July 14, 2015 at 1:29:26 PM UTC-7, John Larkin wrote:
> Imagine a mass that we want to heat ...Thermal systems are
> diffusive, which we represent as a bunch of RC lags.

> ... there is no thermal
> equivalent to an inductor.

It'd be nice if that were the case, but you CAN get thermal overshoot,
just like an inductor, when your components achieve ignition temperature.
Usually, there's only one such event, ash doesn't burn.

One expects any material substance to react to pressure by reduction
in size.   One is surprised, then, on examining the behavior of
fulminate of mercury.
```
```On Tue, 14 Jul 2015 13:29:14 -0700, John Larkin wrote:

> Imagine a mass that we want to heat with some closed-loop controller.
> It's C2 below. Voltage represents temperature. Thermal systems are
> diffusive, which we represent as a bunch of RC lags. Assume the voltage
> at C4 is the temperature sensor.
>
> If I were to design a PID controller, I'd have to really think about it,
> or fiddle some, to keep it stable. But if I do a dumb on/off thermostat,
> it seems to always work. I can tweak the hysteresis and vary the p-p
> temperature excursions and the switching frequency, but it's always
> stable. Or maybe it's always unstable. But it works.

<< snip >>

Control theorists would call the behavior a "stable limit cycle".  It's
always moving around (that's the cycle), but the system exhibits bounded-
input, bounded-output stability (that's the "stable").  There's just no
way you can analyze the system behavior using a linear model, yet, it
works pretty well.

You have no hope, even in theory, of settling on the One True
Temperature, but if you'll always be within acceptable bounds and the
temperature cycling isn't an issue, do you care?

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
```
```On Tue, 14 Jul 2015 13:29:14 -0700, John Larkin
<jlarkin@highlandtechnology.com> wrote:

>
>
>Imagine a mass that we want to heat with some closed-loop controller.
>It's C2 below. Voltage represents temperature. Thermal systems are
>diffusive, which we represent as a bunch of RC lags. Assume the
>voltage at C4 is the temperature sensor.
>
>If I were to design a PID controller, I'd have to really think about
>it, or fiddle some, to keep it stable. But if I do a dumb on/off
>thermostat, it seems to always work. I can tweak the hysteresis and
>vary the p-p temperature excursions and the switching frequency, but
>it's always stable. Or maybe it's always unstable. But it works.
>
>As Vh gets smaller, the oscillation frequency converges to some
>limiting value, which is I guess the ultimate performance of a
>thermostat for this physics. To get any less temperature excursion, I
>guess I'd have to do a real PID loop. Curious.
>
>This may have something to do with the fact that there is no thermal
>equivalent to an inductor.
>
<snip>

You need a deadbeat controller, long thermal time constants.

Cheer
s
>Version 4
>SHEET 1 880 680
>WIRE 0 0 -288 0
>WIRE 528 0 80 0
>WIRE -288 160 -288 0
>WIRE -224 160 -288 160
>WIRE -96 160 -144 160
>WIRE -16 160 -96 160
>WIRE 96 160 64 160
>WIRE 192 160 96 160
>WIRE 304 160 272 160
>WIRE 416 160 304 160
>WIRE 528 160 528 0
>WIRE 528 160 480 160
>WIRE -288 224 -288 160
>WIRE -96 224 -96 160
>WIRE 96 224 96 160
>WIRE 304 224 304 160
>WIRE -288 336 -288 288
>WIRE -96 336 -96 288
>WIRE 96 336 96 288
>WIRE 304 336 304 288
>FLAG -288 336 0
>FLAG -96 336 0
>FLAG 96 336 0
>FLAG 304 336 0
>SYMBOL Digital\\schmtinv 416 96 R0
>WINDOW 0 2 -10 Left 2
>WINDOW 3 -30 23 Left 2
>SYMATTR InstName A1
>SYMATTR Value Vh=0.002
>SYMBOL cap 80 224 R0
>WINDOW 0 67 13 Left 2
>WINDOW 3 64 44 Left 2
>SYMATTR InstName C1
>SYMATTR Value 1m
>SYMBOL cap -112 224 R0
>WINDOW 0 63 18 Left 2
>WINDOW 3 64 53 Left 2
>SYMATTR InstName C2
>SYMATTR Value 5m
>SYMBOL cap -304 224 R0
>WINDOW 0 60 22 Left 2
>WINDOW 3 66 53 Left 2
>SYMATTR InstName C3
>SYMATTR Value 1m
>SYMBOL res -128 144 R90
>WINDOW 0 0 56 VBottom 2
>WINDOW 3 32 56 VTop 2
>SYMATTR InstName R1
>SYMATTR Value 1K
>SYMBOL res 80 144 R90
>WINDOW 0 0 56 VBottom 2
>WINDOW 3 32 56 VTop 2
>SYMATTR InstName R2
>SYMATTR Value 1K
>SYMBOL res 96 -16 R90
>WINDOW 0 0 56 VBottom 2
>WINDOW 3 32 56 VTop 2
>SYMATTR InstName R3
>SYMATTR Value 1K
>SYMBOL cap 288 224 R0
>WINDOW 0 67 13 Left 2
>WINDOW 3 64 44 Left 2
>SYMATTR InstName C4
>SYMATTR Value 1m
>SYMBOL res 288 144 R90
>WINDOW 0 0 56 VBottom 2
>WINDOW 3 32 56 VTop 2
>SYMATTR InstName R4
>SYMATTR Value 1K
>TEXT -208 -56 Left 2 !.tran 50 uic
>TEXT 192 -88 Left 2 ;THERMOSTAT
>TEXT 192 -48 Left 2 ;JL  July 14, 2015
>TEXT -72 80 Left 2 ;===== thermal lags =====
```
```On 7/14/2015 1:29 PM, John Larkin wrote:
>
>
> Imagine a mass that we want to heat with some closed-loop controller.
> It's C2 below. Voltage represents temperature. Thermal systems are
> diffusive, which we represent as a bunch of RC lags. Assume the
> voltage at C4 is the temperature sensor.
>
> If I were to design a PID controller, I'd have to really think about
> it, or fiddle some, to keep it stable. But if I do a dumb on/off
> thermostat, it seems to always work. I can tweak the hysteresis and
> vary the p-p temperature excursions and the switching frequency, but
> it's always stable. Or maybe it's always unstable. But it works.
>
> As Vh gets smaller, the oscillation frequency converges to some
> limiting value, which is I guess the ultimate performance of a
> thermostat for this physics. To get any less temperature excursion, I
> guess I'd have to do a real PID loop. Curious.
>
> This may have something to do with the fact that there is no thermal
> equivalent to an inductor.

All HVAC systems exhibit overshoot (well, face-bypass can control this
but no one controls habitable space with such an inefficient approach!).

With oil/gas-fired hot water, the thermal mass of the heated water
sitting in the radiators continues to warm the interior air long after
the "fire" has been removed.  Even if you turn off the circulating pump,
the heated water in the pipes/radiators still radiates heat -- until it
falls to room temperature (if you rely on the water jacket for DHW,
then it probably *never* reaches room temperature!)

With gas fired forced air, the furnace "coasts" after the thermostat
stops calling for heat (to remove the heat stored in the heat
exchanger, ducts, etc.).

Note that in none of these systems do you have anything more than a
bang-bang controller operating.  I.e., you can't tell the furnace to
produce "36% heat" -- it's on or off.  All you can do is fiddle with
hysteresis and *size* the plant to fit the load (e.g., too big and
too small are both bad options)

You can, however, do some prediction to anticipate when the interior
temperature will reach the desired setpoint and reduce the call for
heat (cooling) before that time.  This can reduce hysteresis at the
expense of overall efficiency (tolerating a larger deadband gives
you better efficiency)

```
```On Tue, 14 Jul 2015 14:13:36 -0700 (PDT), whit3rd <whit3rd@gmail.com>
wrote:

>On Tuesday, July 14, 2015 at 1:29:26 PM UTC-7, John Larkin wrote:
>> Imagine a mass that we want to heat ...Thermal systems are
>> diffusive, which we represent as a bunch of RC lags.
>
>> ... there is no thermal
>> equivalent to an inductor.
>
>It'd be nice if that were the case, but you CAN get thermal overshoot,
>just like an inductor, when your components achieve ignition temperature.

But systems composed of heat sources and masses and thermal conductors
don't ring or overshoot, whereas mechanical systems do ring and
overshoot and oscillate. You have to add some non-thermal element,
like electronics or some mechanical gidget, or gain somehow, to make a
thermal system ring.

Maybe that makes thermostat systems so docile.

It does look like, for a nontrivial system, the p-p temperature
excursion and frequency will be limited by the process, all the way
down to zero hysteresis, which is equivalent to an ideal comparator.
So it's kinda hard to get wrong.

--

John Larkin         Highland Technology, Inc
picosecond timing   precision measurement

jlarkin att highlandtechnology dott com
http://www.highlandtechnology.com

```
```In article <gcabqatiaij1slj29lu0h1bk8ck5gkfcog@4ax.com>,
John Larkin  <jlarkin@highlandtechnology.com> wrote:

>But systems composed of heat sources and masses and thermal conductors
>don't ring or overshoot, whereas mechanical systems do ring and
>overshoot and oscillate.

Seems to me that by limiting the system to "heat sources and masses
and thermal conductors", you have eliminated any way for the
temperature of the "downstream" parts of the system to affect the heat
source.  Hence, no feedback... and hence the classic conditions for
oscillation cannot be met.

>                           You have to add some non-thermal element,
>like electronics or some mechanical gidget, or gain somehow, to make a
>thermal system ring.

Or like a thermostat?

Put a "bang-bang" thermostat into the system to control the heat
source, and you've introduced feedback... and at this point, the
system sure-and-for-gosh is oscillating!  It cycles above and below
the setpoint temperature, at a rate set by the thermal mass of the
system, the rate of loss-of-heat, and the rate-of-added-heat when the
heater is on.  Plot the temperature vs. time with the right axis
scales, and you'll see something akin to a distorted sine or triangle
or sawtooth wave.

That's really not very different from the oscillations you'd get in a
mechanical system... like a ping-pong ball in a column, with a
fixed-force air jet which is turned on every time the ball falls below
a specific height.

>It does look like, for a nontrivial system, the p-p temperature
>excursion and frequency will be limited by the process, all the way
>down to zero hysteresis, which is equivalent to an ideal comparator.
>So it's kinda hard to get wrong.

FSVO "right" and "wrong".

If the thermometer has too much thermal mass of its own, or isn't
tightly coupled to the air in the room, it'll be slow in sensing the
increase (or decrease) in temperature in the process area, and you'll
end up with loads of overshoot.

Household thermostats often have an "anticipator" built in, to limit
this effect.  It's a small heater, located near the sensing element,
which goes on at the same time as the main house heater.  This helps
the thermostat "anticipate" the amount by which the main heater is
probably warming the room air, and reduces the delay in shutting off
when the right temperature is reached.

If this sounds a bit like slapping adding a few pF of capacitance
across the feedback resistor in an op amp circuit, to cancel out the
phase lag caused by stray capacitance at the inverting node... well,
yeah!

```
```On Tue, 14 Jul 2015 17:54:52 -0700, dplatt@coop.radagast.org (Dave
Platt) wrote:

>In article <gcabqatiaij1slj29lu0h1bk8ck5gkfcog@4ax.com>,
>John Larkin  <jlarkin@highlandtechnology.com> wrote:
>
>>But systems composed of heat sources and masses and thermal conductors
>>don't ring or overshoot, whereas mechanical systems do ring and
>>overshoot and oscillate.
>
>Seems to me that by limiting the system to "heat sources and masses
>and thermal conductors", you have eliminated any way for the
>temperature of the "downstream" parts of the system to affect the heat
>source.  Hence, no feedback... and hence the classic conditions for
>oscillation cannot be met.

A simple mechanical system, like a rod sticking out of the ground, or
a solid sphere, can ring if you whack it. The three basic elements of
the differential equation are there. An RLC will ring, ditto. Thermal
systems can't ring, because the inductor equivalent doesn't exist.
It's like making a circuit out of just resistors and capacitors.

>
>>                           You have to add some non-thermal element,
>>like electronics or some mechanical gidget, or gain somehow, to make a
>>thermal system ring.
>
>Or like a thermostat?

Yup.

>
>Put a "bang-bang" thermostat into the system to control the heat
>source, and you've introduced feedback... and at this point, the
>system sure-and-for-gosh is oscillating!

Sure. If you add a non-thermal component.

It cycles above and below
>the setpoint temperature, at a rate set by the thermal mass of the
>system, the rate of loss-of-heat, and the rate-of-added-heat when the
>heater is on.  Plot the temperature vs. time with the right axis
>scales, and you'll see something akin to a distorted sine or triangle
>or sawtooth wave.
>
>That's really not very different from the oscillations you'd get in a
>mechanical system... like a ping-pong ball in a column, with a
>fixed-force air jet which is turned on every time the ball falls below
>a specific height.
>
>>It does look like, for a nontrivial system, the p-p temperature
>>excursion and frequency will be limited by the process, all the way
>>down to zero hysteresis, which is equivalent to an ideal comparator.
>>So it's kinda hard to get wrong.
>
>FSVO "right" and "wrong".
>
>If the thermometer has too much thermal mass of its own, or isn't
>tightly coupled to the air in the room, it'll be slow in sensing the
>increase (or decrease) in temperature in the process area, and you'll
>end up with loads of overshoot.

My model has several coupled lags, with the last one representing the
sensor response. The loop regulates nicely.

>
>Household thermostats often have an "anticipator" built in, to limit
>this effect.  It's a small heater, located near the sensing element,
>which goes on at the same time as the main house heater.  This helps
>the thermostat "anticipate" the amount by which the main heater is
>probably warming the room air, and reduces the delay in shutting off
>when the right temperature is reached.

In my circuit, that would be another resistor that leapfrogs several
of the RCs. I'll try that.

--

John Larkin         Highland Technology, Inc
picosecond timing   precision measurement

jlarkin att highlandtechnology dott com
http://www.highlandtechnology.com

```
```In article <gcabqatiaij1slj29lu0h1bk8ck5gkfcog@4ax.com>,
jlarkin@highlandtechnology.com says...
>
> On Tue, 14 Jul 2015 14:13:36 -0700 (PDT), whit3rd <whit3rd@gmail.com>
> wrote:
>
> >On Tuesday, July 14, 2015 at 1:29:26 PM UTC-7, John Larkin wrote:
> >> Imagine a mass that we want to heat ...Thermal systems are
> >> diffusive, which we represent as a bunch of RC lags.
> >
> >> ... there is no thermal
> >> equivalent to an inductor.
> >
> >It'd be nice if that were the case, but you CAN get thermal overshoot,
> >just like an inductor, when your components achieve ignition temperature.
>
> But systems composed of heat sources and masses and thermal conductors
> don't ring or overshoot, whereas mechanical systems do ring and
> overshoot and oscillate. You have to add some non-thermal element,
> like electronics or some mechanical gidget, or gain somehow, to make a
> thermal system ring.
>
> Maybe that makes thermostat systems so docile.
>
> It does look like, for a nontrivial system, the p-p temperature
> excursion and frequency will be limited by the process, all the way
> down to zero hysteresis, which is equivalent to an ideal comparator.
> So it's kinda hard to get wrong.

You need to provide a (D) factor for the PID..

As the Precess value reaches Set point value, the D
factor will start to shut down the output to the rate
of the clime.

I've seen many PID controllers and it seems that not everyone
is on the same page. They generally get the P correct but seem
to have issues with (I) and (D), (D) being a real problem.

A good (D) response should actually attempt to lower output
power if the rate of change is increasing too fast. And the
same for the other way, if the rate of decrease is too fast it
should actually increase power output.

Some systems are just Pulsed, so in such cases you simply generate
what would looks like a slow PWM when (D) needs to do something or
your PV is close to set point(SP)

(P) will dictate pulse rate to maintain setpoint.

If you're interested, there is an analog PID controller used
mostly for dancer control but also can be applied for others.

Sim the circuit you would like but you'll see how the (lead)(D)
function behaves and (Lag)(I) works. This method of control in
my opinion is absolutely perfect. I have applied this method in
software many times for PID control instead of using built in PID
functions which vary all over the place from one device to another.

http://wwww.contrexinc.com/PDF/Reflex/tm_12m03_104.pdf

In this case, the dancer input would be the PROCESS VALUE (Feed back)
DANCER POS is SP (Set point).
help to control the impact of the effect, something you don't get in
most PID systems.

Jamie

```
```On 15/07/2015 02:10, John Larkin wrote:
> the differential equation are there. An RLC will ring, ditto. Thermal
> systems can't ring, because the inductor equivalent doesn't exist.
> It's like making a circuit out of just resistors and capacitors.
>

But even circuits without L can ring if there is enough accumulated R-C
phase shift?

piglet

```