 ### Network # Hysteresis needed in 741 Op-Amp circuit

J

#### John Fields

Jan 1, 1970
0
1. THE THERMISTOR

For a good discussion of how thermistors work, refer to:

http://www.epcos.com/inf/50/db/ntc_02/00170027.pdf

For the purpose at hand, (determining how the change in resistance
affects the voltage into the comparator) refer to the "1006" column
in:

http://www.epcos.com/inf/50/db/ntc_02/01470178.pdf

and you'll notice that at 15°C the value of Rt/R25 for 15°C is 1.4883,
and at 35°C it's 0.686.

What that means is that if the thermistor has a resistance of 10000
ohms at 25°C, then at 15°C it'll have a resistance of 14,883 ohms, and
at 35°C it'll have a resistance of 6860 ohms.

2. THE VOLTAGE DIVIDER

Now, if we connect the thermistor in series with a resistor and apply
a fixed voltage across them, like this:

E1
|
[R1]
|
+---->E2
|
[RT1]
|
GND

Then when temperature increases and the resistance of the thermistor
(RT1) decreases, E2 will also decrease. Conversely, when the
temperature to which RT1 is exposed decreases, E2 will increase.

The exact relationship is:

E1 RT1
E2 = ------
R1+RT1

so, if we make E1 = 12V and R1 = 100kohms, then at 15°C,

12*14883
E2 = ------------- ~ 1.555V
100000+14883

and the power being dissipated in the thermistor will be:

E² 1.555²
P = --- = ----- = 162µW
R 10000

At 35°C, the potput voltage will be:

12*6860
E2 = ------------- ~ 0.7703V
100000+6860

and the power dissipated by the thermistor:

E² 0.7703²
P = --- = ------- = 86µW
R 6860

The power dissipated in the thermistor may be enough to cause a
self-heating error to occur, but you'd need to look at the data sheet
for the particular thermistor you're using to make sure.

In any case, if the self-heating error is negligible with respect to
the accuracy you're looking for, with 1.555V out at 15°C and 0.770V
out at 35°C, that's a spread of 780mV from one end of the temp range
to the other, which is pretty good.

3. THE REFERENCE DIVIDER.

If we now connect our thermistor circuitry to the + input of a voltage
comparator, like this,

+12V>---------+---------+----+
| | |
[100K] | [RL]
| | |
+--------|+\ |
| | >--+----->OUT
| |-/
| |
[RT1] |
| |
GND>----------+---------+---------->GND

and we arrange things so that the voltage on the - input is 0.770V,
then when the voltage on the + input rises to 0.770V or higher, the
comparator's output transistor will switch off and the voltage on OUT
will be pulled up to +V through RL.

We can do that by using another voltage divider, like this:

+V>---+-------+-----+----+
| | | |
E1--+ [100K] | [RL]
| | | |
[R1] +----|+\ |
| | | >--+----->OUT
E2--+-------|----|-/
| | |
[R2] [RT1] |
| | |
GND>--+-------+-----+---------->GND

and selecting R1 and R2 so that the voltage at their junction will be
0.770V. An easy way to do this is to look at the comparator data
sheet to find out what the required input current is and making the
resistances small enough to swamp out that current. For the LM311,
that comes out to about 350nA, so if we make the divider current 350µA
the LM311's input currents will contribute about a 1% error to the
divider's output voltage. Better yet, let's make the divider current
about 1mA and use 1% resistors for the divider. That way, most of the
error will be in the resistors, where we can easily account for it.

Since we've got a 12V supply, and 10kohms is a standard 1% value, and
12V into 10k is about 1.2mA, let's make R1 = to 10k and figure out
what R2 needs to be to get us to 0.770V.

Since our new divider is the same as the old one, we can write:

E1 R2
E2 = ------
R1+R2

and rearrange to solve for R2:

E2 R1
R2 = -------
E1-E2

which gives us:

0.770*10000
R2 = ------------- = 685.66 ohms
12-0.770

681 ohms is a standard 1% value, so plugging that into

E1 R2
E2 = ------
R1+R2

to get the voltage into the comparator's - input gives us:

E1 R2 12*681
E2 = ------- = ----------- = 0.765V
R1+R2 10000+681

That's a voltage error of 5 parts out of 770, which is just a little
over 1/2 a percent, so since the resistor tolerance error will
dominate at this point we have a tentative solution, and our circuit
now looks like this:

+V>---+-------+-----+----+
| | | |
| [100.0K] | [RL]
| | | |
[10.0K] +----|+\ |
| | | >--+----->OUT
+-------|----|-/
| | |
 [RT1] |
| | |
GND>--+-------+-----+---------->GND

4. THE VARIABLE REFERENCE.

Now, we could use the same procedure to figure out a new R2 for a temp
of 15°C, and switch between the two, or figure out a whole bunch of
different R2's and switch them in and out for the different temps we
wanted to set to between 15 and 35°, but a much nicer way to do it
would be to use a pot.

In order to be able to do that, our circuit changes to:

+V>---+-------+-----+----+
| | | |
[R1] [100.0K] | [RL]
| | | |
| +----|+\ |
| | | >--+----->OUT
[R2]<-----|----|-/
| | |
[R3] [RT1] |
| | |
GND>--+-------+-----+---------->GND

Where R1 is a pot and R1 and R3 are 1% resistors used to set the ends
of the pot's resistive element to the voltages corresponding to 15°
and 35°C.

Just to get a feel for things, if we want the end of the pot connected
to R1 to be at the higher endpoint voltage (1.555V) and we keep R1 at
10k,then the series combination of R2 and R3 has to be:

E2 R1 1.555*10000
R2+R3 = ------- = ------------ ~ 1489 ohms
E1-E2 12-1.555

and if we want the lower end of the pot to be at 0.77V, then since
there's

E1 12
I = ----------- = ------------ = 1.04mA
R1+(R2+R3) 10000+1489

flowing in the circuit, and

E
R = ---
I

0.77V
then R3 = ------- = 740 ohms.
1.04mA

Since 750 ohms is a standard 1% value, that leaves
1489ohms - 750ohms = 739 ohms for the pot.

739 ohms is _not_ a standard end-to-end resistance for a pot, so we'll
have to do something to fix that. Since R1R2R3 is a voltage divider,
all we're really concerned with is the ratios of resistances, so let's
scale up the 739 ohms to 1000 ohms, which is a standard end-to-end
resistance for pots, and then scale up everything else and see what
happens.

1000/739 = 1.353, so R1 needs to go to 13530 ohms, R2 will go to 1000
ohms and R3 will need to go to 1000 ohms as well. So now, since the
closest we can get to 13530 ohms with 1% resistors is 13700 ohms, our
string now looks like this:

+12V
|
[13.7K]
|
|
<----Vout
|
|

|
GND

With the wiper at the top of the pot, Vout will be:

12*2000
Vout = --------- = 1.528V
15700

and at the bottom of the pot it will be:

12*1000
Vout = --------- = 0.764V
15700

(1.555-1.528)*100
So, we'll have an error of ----------------- ~ -1.7%
1.555

(0.770-0.764)*100
on the high end, and ------------------- = + 0.78% on the high end.
0.764

Not too shabby, and now, after adding all the resistor values and
introducing the hysteresis resistor, our circuit looks like this:

+12>---+--------+-----+-------+
| | | |
[13.7K] [100.0K] | [RL]
| | | |
| +-------[Rh]--+
| | | |
| +----|+\ |
| | | >-----+----->OUT
<-----|----|-/
| | |
| | |
 [RT1] |
| | |
GND>---+--------+-----+---------->GND

5. HYSTERESIS

Since a comparator has what amounts to essentially infinite gain, if
its input signals are allowed to move through the switching region
slowly, any noise present on the inputs during that time _will_ cause
the output to swing wildly between its limits. If slowly moving
signals _must_ be accommodated, the cure for the problem is to cause
the input(s) to quickly move out of the sensitive region when the
output changes state. This is done by connecting the output to the
non-inverting input so that when the non-inverting input goes more
positive than the inverting input, causing the output to go high, a
little of that high-going output signal is coupled back to the
non-inverting input, causing it to quickly go even higher, moving it
quickly out of the noisy region, thus preventing the "chatter" which
would otherwise surely occur. In this instance, that positive feedback
is called "hysteresis".

The amount of hysteresis intoduced into the circuit can be controlled
by selecting the resistance of the feedback resistor, which is part of
yet another voltage divider.

Looking at the output of the circuit above in a little more detail
shows us that the output stage is a transistor with an open collector
which pulls the putput down to ground when it is turned on and allows
the output to float when it's turned off, and what's important to
remember is that when the non-inverting (+) input is more positive
than the inverting (-) input the output will be turned off, allowing
current to flow from the supply and through RL into whatever is
connected to the comparator's output.

+12>---+--------+-------+-----+
| | | |
[13.7K] [100.0K] | [RL]
| | | |
| +--[Rh]-------+
| | | |
| | +------+ |
| +----|+ C|-+----->OUT
| | |LM311 |
<-----|----|- E|-+
| | +------+ |
| | | |
 [RT1] | |
| | | |
GND>---+--------+-------+-----+----->GND

Since the LM311 can sink 50mA, there's no reason why it can't be used
to dirctly drive a 12V relay with a coil resistance of

12V
R = ----- = 240 ohms
50mA

or greater, so adding that circuitry yields:

+12>---+--------+-------+-----+-------+
| | | |K | O--> |
[13.7K] [100.0K] | [1N4001] [COIL]- | - -|
| | | | | | O------>COM
| +--[Rh]-------+-------+ |
| | | | +----------->NO
| | +------+ |
| +----|+ C|-+
| | |LM311 |
<-----|----|- E|-+
| | +------+ |
| | | |
 [RT1] | |
| | | |
GND>---+--------+-------+-----+----->GND

Checking the sense of the output, we find that as the thermistor heats
up its resistance will decrease until it causes the comparator's +
input to go more negative than its - input, which will cause the
output transistor to turn on, energizing the relay, so this a cooling
thermostat. That is, if it gets hot enough to turn on the relay, the
relay will turn on the A/C, cooling the thermistor until the voltage
on the + input goes more positive than the voltage on the - input,
turning off the output transistor, turning off the relay, then
turning off the AC until it gets hot enough to turn it back on...

Now that we have that all figured out, if we simplify the circuit by
replacing the comparator's input with a resistor and its output with a
switch we'll have what amounts to:

+12>---+---------+
| |
[100.0K] 
| |
+--[Rh]---+-+-------->Eout
| |
| +-> |
Ein---+----+ |
| | O
[RT1] [Rin] |
| | |
GND>---+----+----------+---->GND

If 240 ohms (the relay coil resistance) << than Rh and Rin is >> RT1,
(which they will be) then the circuit further simplifies to:

+12>---+-------------+
| |
[100.0K] |
| |
+--[Rh]---O |
| | |
| O--> |<--O
Ein---+ |
| |
[RT1 |
| |
GND>---+----+

So that with the switch in the rightmost position we have:

+12>---+------+
| |
[100.0K] [Rh]
| |
+------+--->Ein
|
[RT1]
|
GND>---+

And with the switch in the leftmost position we have:

+12>---+
|
[100.0K]
|
+------+--->Ein
| |
[RT1] [Rh]
| |
GND>---+------+

Since, at 15°C, (without Rh in the circuit) we'll have an output
voltage of 1.55V from the thermistor and, at 35°C, an output voltage
of 0.77V, we'll have a 780mV change for a 20° change in temperature,
which is a sensitivity of 39mV/°C. That won't be quite true over
every increment of that range, since the thermistor is a non-linear
device but, for now, it's close enough.

Next, let's say that the accuracy spec's for the thermostat will
allow, after everything else has been accounted for, an extra degree C
to be used up to get the hysteresis we need. That means, since we've
got a sensitivity of 39mV/°C, that we've got 39mV to play around with
to get some hysteresis.

Now, below 15°C our thermistor will exhibit a resistance > 14883 ohms,
and if it warms up to 15°C, our circuit will look like this:

+12>---+
|
[100.0K]
|
+---->1.55V
|

|
GND>---+

When this happens and the comparator's - input is set to 1.55V, the
output will go low and turn on the relay, and what we'd like to do is
to fool the thermostat into thinking that when that happens it's
actually 16° outside so that it'll move the input switching point a
little closer to ground to get away from the noise-susceptible input
transition region.

Since the thermistor resistance decreases when it gets hotter, what we
can do when the output goes low is to parallel the thermistor with
enough resistance to lower the 1.55 volts by one degree, to 1.51V
(rounding the 39mV/°C sensitivity to 40mV/°C).

Looking at the thermistor circuitry like this:

E1
|
[R1]
|
+---->E2
|
[R2]
|
GND

And setting E1 = 12V, E2 = 1.51V, and R1 = 100kohms,

we can solve for R2, the total resistance we need to get 1.51V out by
writing:

E2 R1 1.51*100000
R2 = ------- = ------------- ~ 14395 ohms
E1-E2 12.0-1.51

Since, at 15°, the thermistor will be at 14883 ohms, we'll need to
parallel it with a resistor to make the combination look like 14395
ohms, like this:

E1
|
[R1]
|
+-----+--->E2
| |
[R2] [R3]
| |
+-----+
|
GND

Knowing that the equation for the total resistance of two parallel
resistors is:

R2 R3
Rt = -------
R2+R3

and that R2 = 14883 ohms and Rt = 14395 ohms,

we can rewrite it to solve for R3 like this:

Rt R2 14395*14883
R3 = -------- = ------------- ~ 439kohms
R2-Rt 14883-14395

The closest 1% resistor we can get which won't exceed our 1°C error
budget is 432k, but that'll still give us nearly the 40mV of
hysteresis we're looking for, so let's choose that value tentatively.

Now, let's say the temp starts falling from that point. Since it's
really 15° outside and we've fooled the comparator into thinking that
it's 16°, it's going to have to fall to 14° for the comparator to
think that it's 15° outside, but when it gets there the comparator's
output will go open-collector and the feedback resistor will now be
connected to +12V through the relay coil. If the coil looks like 240
ohms its resistance will be negligible compared to the feedback
resistor's 439kohm resistance, so since the thermistor's sensitivity
is -401 ohms/°C, (assuming it's linear for the sake of this
discusion...) its resistance will rise to 14482 ohms and the circuit
will now look like this:

12V 12V
| |
[100K] [439K]
| |
+-------+--->E2

|
GND

100k in parallel reduces to a total resistance of

100000*439000
Rt = --------------- = 81447 ohms.
100000+439000

So, the circuit further reduces to

12V
|

|
+---->E2
|

|
GND

And the voltage into the comparator's + input, E2, will now be

12.0*14482
E2 = ------------- ~ 1.812V
81447+14482

Since the [15°C] reference voltage on the comparator's -input will be
sitting at 1.555V, that 1.812V represents a hysteresis of about 257mV,
which represents the introduction of about a 6.6°C error. If the
error spec is +/- 1°, that's very, very, bad.

Fortunately, since the reason for the error is the asymmetry of the
thermistor string, we can fix it by making the string symmetrical.
That is, by making the series resistor and the thermistor the same
value at the center of the thermistor's resistance range for the
temperature range it will be sensing.

For our thermistor, with an R of 14883 ohms at 15°C and an R of 6860
ohms at 35°C, that comes out to 10,872 ohms for the series resistor,
so with the nearest 1% resistor installed, our new circuit will look
like:

12V
|

|
+---->E2
|
[Rth]
|
GND

Now E2 will be 6.98V at 15°C (Rth = 14883 ohms) and 4.688V at 35°C
(Rth = 6860 ohms), so the new voltage sensitivity will will be about
115mV/°C.

115mV is a lot, so if we limit our hysteresis to, say, 50mV that'll
cause less than a 0.5° error, but let's see how it works out.

Just like last time, if we want 50 mV of hysteresis we'll have to make
the parallel combination of the 10.7k resistor and and the feeback
resistor change the + input voltage to the comparator by the amount we
want, which will be 50mV in this case.

We really only have four cases to consider:

The hysteresis when the temp is rising and falling through 15°C, and
the hysteresis when the temp is rising and falling through 35°C.

Looking at falling through 15°C first, we'll have:

12V 12V
| |
[10.7K] [Rf]
| |
+-------+--->E2
|

|
GND

Since the resistance of the thermistor is increasing as it gets
colder, the voltage at E2 will be increasing also. Without feedback
E2 would be 6.98V when the thermistor got to 15°C (14482 ohms), and
what we want to do with the feedback is to make it seem like it's a
little bit colder than it really is when E2 gets to 6.98V, so that
would mean making E2 jump a little more positive when the comparator
output goes open collector.

We can do that by paralleling the 10.7kohm resistor with a resistor of
a suitable value and, using the procedure outlined earlier, we find
that for a 50mV jump (from 6.98V to 7.03V) the parallel combination of
the 10.7kohm resistor and the feedback resistor (Rf) needs to be 10522
ohms, with Rf being equal to 632502 ohms. The closest 1% resistor is
634kohms, which will give us an E2 of 7.02V as the temp falls through
15°C, about 40mV of hysteresis over the non-feedback case.

With the temp rises through 15°C and the comparator's output
transistor turns on, our circuit becomes:

12V
|
[10.7K]
|
+-------+--->E2
| |
 [634K]
| |
GND GND

and E2 will now become 6.91V, giving us 70mV of hysteresis.

When the temp falls through 35°C, the circuit will become:

12V 12V
| |
[10.7K] [634k]
| |
+-------+--->E2
|

|
GND

Without feedback, E2 would be 4.666V, but with feedback it'll be
4.714V, giving us about 48mV of hysteresis.

Finally, When the temp rises through 35°C, the circuit will become:

12V
|
[10.7K]
|
+-------+--->E2
| |
 [634K]
| |
GND GND

and E2 will go to 4.636V, giving us about 30mV of hysteresis.

So, here's the final schematic, and barring any fuzzy thinking, math
errors, trypos, etc., all that's left to do now is to recalculate the
padding resistors around the pot for the new voltage range and trim
things up if you want/need more or less hysteresis, and it should be
pretty much done.

+--- >= 240 ohms
+12>---+--------+--------+-----+-------+ /
| | | |K | / O--> |
[R1] [10.7K] | [1N4001] [COIL]- | - -|
| | | | | | O------>COM
| +-[634K]-------+-------+ |
| | | | +----------->NO
| | +------+ |
| +----|+ C|--+
| | |LM311 |
<-----|----|- E|--+
| | +------+ |
| | | |
[R2] [RT1] | |
| | | |
GND>---+--------+--------+-----+----->GND

Simple, huh?^)

PS...

I've got some schematics for heating-cooling thermostats using
LM393's, and if you'd like I can post them to
alt.binaries.schematics.electronic.

R

#### Robert Baer

Jan 1, 1970
0
------------- SNIPped ------------
.... a *VERY* long-winded paper that might be called a thesis (or
mini-novel?).
If you had a ?questiion? concerning hysteresis, it would have been
nice to make a *BRIEF* synopsis of the problem.
Else, do not waste bandwidth!

W

#### Winfield Hill

Jan 1, 1970
0
Robert Baer wrote...
------------- SNIPped ------------
... a *VERY* long-winded paper that might be called a thesis (or
mini-novel?).
If you had a ?questiion? concerning hysteresis, it would have been
nice to make a *BRIEF* synopsis of the problem.
Else, do not waste bandwidth!

Hah! That's some of the best bandwidth wasting we've seen here
in some time.

Thanks,
- Win

(email: use hill_at_rowland-dot-org for now)

T

#### Tim Auton

Jan 1, 1970
0
Winfield Hill said:
Robert Baer wrote...

Hah! That's some of the best bandwidth wasting we've seen here
in some time.

I concur. I found it a most interesting insight into how I would like
to be able to design circuits. I'd probably have chucked a uC input at
it long ago Perhaps Robert Baer missed the thread in s.e.basics that prompted John
Fields' post. I think it's on-topic here too.

Tim

J

#### Jim Thompson

Jan 1, 1970
0
------------- SNIPped ------------
... a *VERY* long-winded paper that might be called a thesis (or
mini-novel?).
If you had a ?questiion? concerning hysteresis, it would have been
nice to make a *BRIEF* synopsis of the problem.
Else, do not waste bandwidth!

washed out with soap.

...Jim Thompson

J

#### John Fields

Jan 1, 1970
0
------------- SNIPped ------------
... a *VERY* long-winded paper that might be called a thesis (or
mini-novel?).
If you had a ?questiion? concerning hysteresis, it would have been
nice to make a *BRIEF* synopsis of the problem.
Else, do not waste bandwidth!

---
It wasn't a question. As Tim Auton noted, this was a reply, which I
originated on seb.

Sorry you didn't find it at least interesting...

S

#### Spehro Pefhany

Jan 1, 1970
0
Robert Baer wrote...

Hah! That's some of the best bandwidth wasting we've seen here
in some time.

Yup. A lot of effort went into that.

Best regards,
Spehro Pefhany

P

#### Product developer

Jan 1, 1970
0
John Fields said:
---
It wasn't a question. As Tim Auton noted, this was a reply, which I
originated on seb.

Sorry you didn't find it at least interesting...

I sure did as with all your posts. Absolutely brilliant. I love these
exercises and I benefit from nearly all them. This NG is one of the
most valuable sources I have ever found. Many thanks to you and the
few other Titans in here that take the time to educate and advance the

Thanks again!

J

#### John Fields

Jan 1, 1970
0
I sure did as with all your posts. Absolutely brilliant. I love these
exercises and I benefit from nearly all them. This NG is one of the
most valuable sources I have ever found. Many thanks to you and the
few other Titans in here that take the time to educate and advance the

Thanks again!

T

#### Terry Given

Jan 1, 1970
0
Dont thank us John, just keep posting such excellent work Cheers
Terry

J

#### John Fields

Jan 1, 1970
0
Dont thank us John, just keep posting such excellent work W

#### Winfield Hill

Jan 1, 1970
0
John Fields wrote...
What should I do then, ignore a compliment?
I don't think so... We don't want you to get a big head. :>)

Thanks,
- Win

(email: use hill_at_rowland-dot-org for now)

T

#### Terry Given

Jan 1, 1970
0
Winfield Hill said:
John Fields wrote...

We don't want you to get a big head. :>)

Thanks,
- Win

I printed it to a PDF - it will be useful in the future, as I often find
myself working with people who dont understand this sort of thing, and John
kindly saved me from writing it myself - besides, it will frighten the hell out of my year 12 electronics students

cheers
Terry

F

#### Fred Bloggs

Jan 1, 1970
0
What was the question this "paper" answers?

John said:
1. THE THERMISTOR

For a good discussion of how thermistors work, refer to:

http://www.epcos.com/inf/50/db/ntc_02/00170027.pdf

For the purpose at hand, (determining how the change in resistance
affects the voltage into the comparator) refer to the "1006" column
in:

http://www.epcos.com/inf/50/db/ntc_02/01470178.pdf

and you'll notice that at 15°C the value of Rt/R25 for 15°C is 1.4883,
and at 35°C it's 0.686.

What that means is that if the thermistor has a resistance of 10000
ohms at 25°C, then at 15°C it'll have a resistance of 14,883 ohms, and
at 35°C it'll have a resistance of 6860 ohms.

2. THE VOLTAGE DIVIDER

Now, if we connect the thermistor in series with a resistor and apply
a fixed voltage across them, like this:

E1
|
[R1]
|
+---->E2
|
[RT1]
|
GND

Then when temperature increases and the resistance of the thermistor
(RT1) decreases, E2 will also decrease. Conversely, when the
temperature to which RT1 is exposed decreases, E2 will increase.

The exact relationship is:

E1 RT1
E2 = ------
R1+RT1

so, if we make E1 = 12V and R1 = 100kohms, then at 15°C,

12*14883
E2 = ------------- ~ 1.555V
100000+14883

and the power being dissipated in the thermistor will be:

E² 1.555²
P = --- = ----- = 162µW
R 10000

At 35°C, the potput voltage will be:

12*6860
E2 = ------------- ~ 0.7703V
100000+6860

and the power dissipated by the thermistor:

E² 0.7703²
P = --- = ------- = 86µW
R 6860

The power dissipated in the thermistor may be enough to cause a
self-heating error to occur, but you'd need to look at the data sheet
for the particular thermistor you're using to make sure.

In any case, if the self-heating error is negligible with respect to
the accuracy you're looking for, with 1.555V out at 15°C and 0.770V
out at 35°C, that's a spread of 780mV from one end of the temp range
to the other, which is pretty good.

3. THE REFERENCE DIVIDER.

If we now connect our thermistor circuitry to the + input of a voltage
comparator, like this,

+12V>---------+---------+----+
| | |
[100K] | [RL]
| | |
+--------|+\ |
| | >--+----->OUT
| |-/
| |
[RT1] |
| |
GND>----------+---------+---------->GND

and we arrange things so that the voltage on the - input is 0.770V,
then when the voltage on the + input rises to 0.770V or higher, the
comparator's output transistor will switch off and the voltage on OUT
will be pulled up to +V through RL.

We can do that by using another voltage divider, like this:

+V>---+-------+-----+----+
| | | |
E1--+ [100K] | [RL]
| | | |
[R1] +----|+\ |
| | | >--+----->OUT
E2--+-------|----|-/
| | |
[R2] [RT1] |
| | |
GND>--+-------+-----+---------->GND

and selecting R1 and R2 so that the voltage at their junction will be
0.770V. An easy way to do this is to look at the comparator data
sheet to find out what the required input current is and making the
resistances small enough to swamp out that current. For the LM311,
that comes out to about 350nA, so if we make the divider current 350µA
the LM311's input currents will contribute about a 1% error to the
divider's output voltage. Better yet, let's make the divider current
about 1mA and use 1% resistors for the divider. That way, most of the
error will be in the resistors, where we can easily account for it.

Since we've got a 12V supply, and 10kohms is a standard 1% value, and
12V into 10k is about 1.2mA, let's make R1 = to 10k and figure out
what R2 needs to be to get us to 0.770V.

Since our new divider is the same as the old one, we can write:

E1 R2
E2 = ------
R1+R2

and rearrange to solve for R2:

E2 R1
R2 = -------
E1-E2

which gives us:

0.770*10000
R2 = ------------- = 685.66 ohms
12-0.770

681 ohms is a standard 1% value, so plugging that into

E1 R2
E2 = ------
R1+R2

to get the voltage into the comparator's - input gives us:

E1 R2 12*681
E2 = ------- = ----------- = 0.765V
R1+R2 10000+681

That's a voltage error of 5 parts out of 770, which is just a little
over 1/2 a percent, so since the resistor tolerance error will
dominate at this point we have a tentative solution, and our circuit
now looks like this:

+V>---+-------+-----+----+
| | | |
| [100.0K] | [RL]
| | | |
[10.0K] +----|+\ |
| | | >--+----->OUT
+-------|----|-/
| | |
 [RT1] |
| | |
GND>--+-------+-----+---------->GND

4. THE VARIABLE REFERENCE.

Now, we could use the same procedure to figure out a new R2 for a temp
of 15°C, and switch between the two, or figure out a whole bunch of
different R2's and switch them in and out for the different temps we
wanted to set to between 15 and 35°, but a much nicer way to do it
would be to use a pot.

In order to be able to do that, our circuit changes to:

+V>---+-------+-----+----+
| | | |
[R1] [100.0K] | [RL]
| | | |
| +----|+\ |
| | | >--+----->OUT
[R2]<-----|----|-/
| | |
[R3] [RT1] |
| | |
GND>--+-------+-----+---------->GND

Where R1 is a pot and R1 and R3 are 1% resistors used to set the ends
of the pot's resistive element to the voltages corresponding to 15°
and 35°C.

Just to get a feel for things, if we want the end of the pot connected
to R1 to be at the higher endpoint voltage (1.555V) and we keep R1 at
10k,then the series combination of R2 and R3 has to be:

E2 R1 1.555*10000
R2+R3 = ------- = ------------ ~ 1489 ohms
E1-E2 12-1.555

and if we want the lower end of the pot to be at 0.77V, then since
there's

E1 12
I = ----------- = ------------ = 1.04mA
R1+(R2+R3) 10000+1489

flowing in the circuit, and

E
R = ---
I

0.77V
then R3 = ------- = 740 ohms.
1.04mA

Since 750 ohms is a standard 1% value, that leaves
1489ohms - 750ohms = 739 ohms for the pot.

739 ohms is _not_ a standard end-to-end resistance for a pot, so we'll
have to do something to fix that. Since R1R2R3 is a voltage divider,
all we're really concerned with is the ratios of resistances, so let's
scale up the 739 ohms to 1000 ohms, which is a standard end-to-end
resistance for pots, and then scale up everything else and see what
happens.

1000/739 = 1.353, so R1 needs to go to 13530 ohms, R2 will go to 1000
ohms and R3 will need to go to 1000 ohms as well. So now, since the
closest we can get to 13530 ohms with 1% resistors is 13700 ohms, our
string now looks like this:

+12V
|
[13.7K]
|
|
<----Vout
|
|

|
GND

With the wiper at the top of the pot, Vout will be:

12*2000
Vout = --------- = 1.528V
15700

and at the bottom of the pot it will be:

12*1000
Vout = --------- = 0.764V
15700

(1.555-1.528)*100
So, we'll have an error of ----------------- ~ -1.7%
1.555

(0.770-0.764)*100
on the high end, and ------------------- = + 0.78% on the high end.
0.764

Not too shabby, and now, after adding all the resistor values and
introducing the hysteresis resistor, our circuit looks like this:

+12>---+--------+-----+-------+
| | | |
[13.7K] [100.0K] | [RL]
| | | |
| +-------[Rh]--+
| | | |
| +----|+\ |
| | | >-----+----->OUT
<-----|----|-/
| | |
| | |
 [RT1] |
| | |
GND>---+--------+-----+---------->GND

5. HYSTERESIS

Since a comparator has what amounts to essentially infinite gain, if
its input signals are allowed to move through the switching region
slowly, any noise present on the inputs during that time _will_ cause
the output to swing wildly between its limits. If slowly moving
signals _must_ be accommodated, the cure for the problem is to cause
the input(s) to quickly move out of the sensitive region when the
output changes state. This is done by connecting the output to the
non-inverting input so that when the non-inverting input goes more
positive than the inverting input, causing the output to go high, a
little of that high-going output signal is coupled back to the
non-inverting input, causing it to quickly go even higher, moving it
quickly out of the noisy region, thus preventing the "chatter" which
would otherwise surely occur. In this instance, that positive feedback
is called "hysteresis".

The amount of hysteresis intoduced into the circuit can be controlled
by selecting the resistance of the feedback resistor, which is part of
yet another voltage divider.

Looking at the output of the circuit above in a little more detail
shows us that the output stage is a transistor with an open collector
which pulls the putput down to ground when it is turned on and allows
the output to float when it's turned off, and what's important to
remember is that when the non-inverting (+) input is more positive
than the inverting (-) input the output will be turned off, allowing
current to flow from the supply and through RL into whatever is
connected to the comparator's output.

+12>---+--------+-------+-----+
| | | |
[13.7K] [100.0K] | [RL]
| | | |
| +--[Rh]-------+
| | | |
| | +------+ |
| +----|+ C|-+----->OUT
| | |LM311 |
<-----|----|- E|-+
| | +------+ |
| | | |
 [RT1] | |
| | | |
GND>---+--------+-------+-----+----->GND

Since the LM311 can sink 50mA, there's no reason why it can't be used
to dirctly drive a 12V relay with a coil resistance of

12V
R = ----- = 240 ohms
50mA

or greater, so adding that circuitry yields:

+12>---+--------+-------+-----+-------+
| | | |K | O--> |
[13.7K] [100.0K] | [1N4001] [COIL]- | - -|
| | | | | | O------>COM
| +--[Rh]-------+-------+ |
| | | | +----------->NO
| | +------+ |
| +----|+ C|-+
| | |LM311 |
<-----|----|- E|-+
| | +------+ |
| | | |
 [RT1] | |
| | | |
GND>---+--------+-------+-----+----->GND

Checking the sense of the output, we find that as the thermistor heats
up its resistance will decrease until it causes the comparator's +
input to go more negative than its - input, which will cause the
output transistor to turn on, energizing the relay, so this a cooling
thermostat. That is, if it gets hot enough to turn on the relay, the
relay will turn on the A/C, cooling the thermistor until the voltage
on the + input goes more positive than the voltage on the - input,
turning off the output transistor, turning off the relay, then
turning off the AC until it gets hot enough to turn it back on...

Now that we have that all figured out, if we simplify the circuit by
replacing the comparator's input with a resistor and its output with a
switch we'll have what amounts to:

+12>---+---------+
| |
[100.0K] 
| |
+--[Rh]---+-+-------->Eout
| |
| +-> |
Ein---+----+ |
| | O
[RT1] [Rin] |
| | |
GND>---+----+----------+---->GND

If 240 ohms (the relay coil resistance) << than Rh and Rin is >> RT1,
(which they will be) then the circuit further simplifies to:

+12>---+-------------+
| |
[100.0K] |
| |
+--[Rh]---O |
| | |
| O--> |<--O
Ein---+ |
| |
[RT1 |
| |
GND>---+----+

So that with the switch in the rightmost position we have:

+12>---+------+
| |
[100.0K] [Rh]
| |
+------+--->Ein
|
[RT1]
|
GND>---+

And with the switch in the leftmost position we have:

+12>---+
|
[100.0K]
|
+------+--->Ein
| |
[RT1] [Rh]
| |
GND>---+------+

Since, at 15°C, (without Rh in the circuit) we'll have an output
voltage of 1.55V from the thermistor and, at 35°C, an output voltage
of 0.77V, we'll have a 780mV change for a 20° change in temperature,
which is a sensitivity of 39mV/°C. That won't be quite true over
every increment of that range, since the thermistor is a non-linear
device but, for now, it's close enough.

Next, let's say that the accuracy spec's for the thermostat will
allow, after everything else has been accounted for, an extra degree C
to be used up to get the hysteresis we need. That means, since we've
got a sensitivity of 39mV/°C, that we've got 39mV to play around with
to get some hysteresis.

Now, below 15°C our thermistor will exhibit a resistance > 14883 ohms,
and if it warms up to 15°C, our circuit will look like this:

+12>---+
|
[100.0K]
|
+---->1.55V
|

|
GND>---+

When this happens and the comparator's - input is set to 1.55V, the
output will go low and turn on the relay, and what we'd like to do is
to fool the thermostat into thinking that when that happens it's
actually 16° outside so that it'll move the input switching point a
little closer to ground to get away from the noise-susceptible input
transition region.

Since the thermistor resistance decreases when it gets hotter, what we
can do when the output goes low is to parallel the thermistor with
enough resistance to lower the 1.55 volts by one degree, to 1.51V
(rounding the 39mV/°C sensitivity to 40mV/°C).

Looking at the thermistor circuitry like this:

E1
|
[R1]
|
+---->E2
|
[R2]
|
GND

And setting E1 = 12V, E2 = 1.51V, and R1 = 100kohms,

we can solve for R2, the total resistance we need to get 1.51V out by
writing:

E2 R1 1.51*100000
R2 = ------- = ------------- ~ 14395 ohms
E1-E2 12.0-1.51

Since, at 15°, the thermistor will be at 14883 ohms, we'll need to
parallel it with a resistor to make the combination look like 14395
ohms, like this:

E1
|
[R1]
|
+-----+--->E2
| |
[R2] [R3]
| |
+-----+
|
GND

Knowing that the equation for the total resistance of two parallel
resistors is:

R2 R3
Rt = -------
R2+R3

and that R2 = 14883 ohms and Rt = 14395 ohms,

we can rewrite it to solve for R3 like this:

Rt R2 14395*14883
R3 = -------- = ------------- ~ 439kohms
R2-Rt 14883-14395

The closest 1% resistor we can get which won't exceed our 1°C error
budget is 432k, but that'll still give us nearly the 40mV of
hysteresis we're looking for, so let's choose that value tentatively.

Now, let's say the temp starts falling from that point. Since it's
really 15° outside and we've fooled the comparator into thinking that
it's 16°, it's going to have to fall to 14° for the comparator to
think that it's 15° outside, but when it gets there the comparator's
output will go open-collector and the feedback resistor will now be
connected to +12V through the relay coil. If the coil looks like 240
ohms its resistance will be negligible compared to the feedback
resistor's 439kohm resistance, so since the thermistor's sensitivity
is -401 ohms/°C, (assuming it's linear for the sake of this
discusion...) its resistance will rise to 14482 ohms and the circuit
will now look like this:

12V 12V
| |
[100K] [439K]
| |
+-------+--->E2

|
GND

100k in parallel reduces to a total resistance of

100000*439000
Rt = --------------- = 81447 ohms.
100000+439000

So, the circuit further reduces to

12V
|

|
+---->E2
|

|
GND

And the voltage into the comparator's + input, E2, will now be

12.0*14482
E2 = ------------- ~ 1.812V
81447+14482

Since the [15°C] reference voltage on the comparator's -input will be
sitting at 1.555V, that 1.812V represents a hysteresis of about 257mV,
which represents the introduction of about a 6.6°C error. If the
error spec is +/- 1°, that's very, very, bad.

Fortunately, since the reason for the error is the asymmetry of the
thermistor string, we can fix it by making the string symmetrical.
That is, by making the series resistor and the thermistor the same
value at the center of the thermistor's resistance range for the
temperature range it will be sensing.

For our thermistor, with an R of 14883 ohms at 15°C and an R of 6860
ohms at 35°C, that comes out to 10,872 ohms for the series resistor,
so with the nearest 1% resistor installed, our new circuit will look
like:

12V
|

|
+---->E2
|
[Rth]
|
GND

Now E2 will be 6.98V at 15°C (Rth = 14883 ohms) and 4.688V at 35°C
(Rth = 6860 ohms), so the new voltage sensitivity will will be about
115mV/°C.

115mV is a lot, so if we limit our hysteresis to, say, 50mV that'll
cause less than a 0.5° error, but let's see how it works out.

Just like last time, if we want 50 mV of hysteresis we'll have to make
the parallel combination of the 10.7k resistor and and the feeback
resistor change the + input voltage to the comparator by the amount we
want, which will be 50mV in this case.

We really only have four cases to consider:

The hysteresis when the temp is rising and falling through 15°C, and
the hysteresis when the temp is rising and falling through 35°C.

Looking at falling through 15°C first, we'll have:

12V 12V
| |
[10.7K] [Rf]
| |
+-------+--->E2
|

|
GND

Since the resistance of the thermistor is increasing as it gets
colder, the voltage at E2 will be increasing also. Without feedback
E2 would be 6.98V when the thermistor got to 15°C (14482 ohms), and
what we want to do with the feedback is to make it seem like it's a
little bit colder than it really is when E2 gets to 6.98V, so that
would mean making E2 jump a little more positive when the comparator
output goes open collector.

We can do that by paralleling the 10.7kohm resistor with a resistor of
a suitable value and, using the procedure outlined earlier, we find
that for a 50mV jump (from 6.98V to 7.03V) the parallel combination of
the 10.7kohm resistor and the feedback resistor (Rf) needs to be 10522
ohms, with Rf being equal to 632502 ohms. The closest 1% resistor is
634kohms, which will give us an E2 of 7.02V as the temp falls through
15°C, about 40mV of hysteresis over the non-feedback case.

With the temp rises through 15°C and the comparator's output
transistor turns on, our circuit becomes:

12V
|
[10.7K]
|
+-------+--->E2
| |
 [634K]
| |
GND GND

and E2 will now become 6.91V, giving us 70mV of hysteresis.

When the temp falls through 35°C, the circuit will become:

12V 12V
| |
[10.7K] [634k]
| |
+-------+--->E2
|

|
GND

Without feedback, E2 would be 4.666V, but with feedback it'll be
4.714V, giving us about 48mV of hysteresis.

Finally, When the temp rises through 35°C, the circuit will become:

12V
|
[10.7K]
|
+-------+--->E2
| |
 [634K]
| |
GND GND

and E2 will go to 4.636V, giving us about 30mV of hysteresis.

So, here's the final schematic, and barring any fuzzy thinking, math
errors, trypos, etc., all that's left to do now is to recalculate the
padding resistors around the pot for the new voltage range and trim
things up if you want/need more or less hysteresis, and it should be
pretty much done.

+--- >= 240 ohms
+12>---+--------+--------+-----+-------+ /
| | | |K | / O--> |
[R1] [10.7K] | [1N4001] [COIL]- | - -|
| | | | | | O------>COM
| +-[634K]-------+-------+ |
| | | | +----------->NO
| | +------+ |
| +----|+ C|--+
| | |LM311 |
<-----|----|- E|--+
| | +------+ |
| | | |
[R2] [RT1] | |
| | | |
GND>---+--------+--------+-----+----->GND

Simple, huh?^)

PS...

I've got some schematics for heating-cooling thermostats using
LM393's, and if you'd like I can post them to
alt.binaries.schematics.electronic.

J

#### John Fields

Jan 1, 1970
0
What was the question this "paper" answers?

---
Check the same subject on seb.

What the **** is it with some of you clowns, anyway?

I do a guy a favor with a little tutorial to which he refuses to
respond and then I get flak from some fucking idiot about wasting
bandwidth, from you with your snide goddam "paper" bullshit, and from
Givens with his "I was gonna write the same thing myself, but"...

To hell with all of you niggardly sons of bitches.

J

#### Jim Thompson

Jan 1, 1970
0
---
Check the same subject on seb.

What the **** is it with some of you clowns, anyway?

I do a guy a favor with a little tutorial to which he refuses to
respond and then I get flak from some fucking idiot about wasting
bandwidth, from you with your snide goddam "paper" bullshit, and from
Givens with his "I was gonna write the same thing myself, but"...

To hell with all of you niggardly sons of bitches.

Careful there, John, some ignorant Democrat will call you a racist ;-)

...Jim Thompson

R

#### Rich Grise

Jan 1, 1970
0
Winfield Hill said:
Robert Baer wrote...

Hah! That's some of the best bandwidth wasting we've seen here
in some time.

My only criticism is that it might have been more appropriate to
..basics, or even both, since it's ASCII after all. Cheers!
Rich

F

#### Frank Bemelman

Jan 1, 1970
0
John Fields said:
---
Check the same subject on seb.

What the **** is it with some of you clowns, anyway?

I do a guy a favor with a little tutorial to which he refuses to
respond and then I get flak from some fucking idiot about wasting
bandwidth, from you with your snide goddam "paper" bullshit, and from
Givens with his "I was gonna write the same thing myself, but"...

To hell with all of you niggardly sons of bitches.

Well John, there's a bright side, Fred didn't find any errors, he
would have spotted them if there were any I admire your energy
and yes, many can go to hell. But you have to be patient, alas.

R

#### Rich Grise

Jan 1, 1970
0
John Fields said:
---
It wasn't a question. As Tim Auton noted, this was a reply, which I
originated on seb.

Sorry you didn't find it at least interesting...

I found myself trying to figure out what kind of transfer function
would be appropriate to map onto those 3 points ... since it's
essentially impossible to guess, I looked it up from your reference,
http://www.epcos.com/inf/50/db/ntc_02/01470178.pdf
and decided, yup, I never would have got that one, nosireebob!

Cheers!
Rich

R

#### Rich Grise

Jan 1, 1970
0
Product developer said:
I sure did as with all your posts. Absolutely brilliant. I love these
exercises and I benefit from nearly all them. This NG is one of the
most valuable sources I have ever found. Many thanks to you and the
few other Titans in here that take the time to educate and advance the

Yikes! Don't fawn, fer crissakes! None of these weenies deserves it -
they all take their pants off one leg at a time! =:-O

Cheers!
Rich

C
Replies
47
Views
9K
C
Replies
2
Views
1K
Replies
9
Views
2K
Replies
0
Views
780
Replies
12
Views
2K