This is only a preview of the March 2001 issue of Silicon Chip. You can view 32 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Articles in this series:
Items relevant to "Big-Digit 12/24-Hour Clock":
Items relevant to "A Sun-Seeking Sunflower":
Items relevant to "Parallel Port PIC Programmer & Checkerboard":
Items relevant to "More-MIDI: A Simple MIDI Expansion Box":
Purchase a printed copy of this issue for $10.00. |
More fun with comparators
This month we try stacking two comparators to make a “window”
comparator, a very commonly used circuit in all sorts of control
applications. We generate an “input” signal using a potentiometer
fed from DC and demonstrate how the window comparator
responds to a varying DC signal.
Pt.5 By LEO SIMPSON
OK; what’s a “window” comparator? We’ve had a look at two variations
of standard comparator circuits in the
December 2000 issue and saw how
they switch their outputs when the
input goes above or below a reference
voltage. Typically, a comparator’s
output might be made to switch high
when its input goes above +6V and a
circuit for this is shown in Fig.1 on
p75 of the December 2000 issue.
As it happens, there were two
comparator-based circuits in last
month’s issue. Firstly, the Li’l Pulser train controller is based on two
comparators connected to generate
a PWM (pulse width modulated)
waveform and secondly, the Bass
Blazer frequency display has a whole
bunch of comparators driving LEDs
in four columnar arrays. There is no
reason why you could not hook up
the key parts on these circuits on your
Protoboard and then, if you have an
oscilloscope, see if you can duplicate
the example waveforms.
Back to “window” comparators: say
we wanted to produce a comparator
circuit which would indicate when an
input was above +6V and below +9V;
ie, within a 3V range. We would need
two comparators, one inverting and
one non-inverting and they could be
hooked up as shown in Fig.1. Notice
that each comparator drives its own
LED and that each comparator has its
reference voltage derived from the
same string of three resistors; after all,
why have two voltage divider strings
when we can do it with one? So pin 5
The circuit is fairly simple and should only take you about 10 minutes to wire
up. The pot at far right is not used in this circuit.
is connected to a (nominal) reference
of +6V and pin 2 is connected to +9V.
We also derive the input voltage
from the same potentiometer, VR1,
and as we wind the pot up and down,
the LEDs will tell the story.
The Protoboard layout for Fig.1 is
shown in Fig.2.
When we wind up VR1 so pin 6
of IC1b is above +6V, LED2 lights.
And when pin 3 of IC1a is below
+9V, LED1 lights. What we find is
that when the input from VR1 is between +6V and +9V, both LEDs will
be alight – this is the condition we
wanted to detect.
Furthermore, when pin 3 of IC1a is
above +9V, LED1 will be off but LED2
will be on, because pin 6 of IC1b will
be above pin 5. And when pin 6 of
IC1b is below pin 5 (ie, below +6V),
LED2 will be off and LED1 will be on.
So we see that the two comparators
together give an indica
tion when
an input voltage is above +6V and
below +9V (both LEDs on) but it is
a bit “mickey mouse”: both LEDs
need to be on to indicate the wanted
condition and if just LED1 or LED2
is on, then the wanted condition is
not there.
What we really need is a combination circuit which will drive just one
LED to indicate the wanted condition
where the input voltage is within the
range of +6V and +9V.
MARCH 2001 81
Fig.1: both of these comparators drives its own LED and each comparator has its
reference voltage (9V or 6V) derived from the same string of three resistors. The
input voltage for both comparators comes from the same potentiometer, VR1.
Let’s try the new circuit of Fig.3. It
still uses two comparators, one inverting and one non-inverting, but now
they both have their outputs joined
directly together and they just drive
the one LED. Normally, connecting
the outputs of two op amps together
would cause serious problems but
we are using comparators with “open
collector” outputs which require a
pullup resistor.
Open collector outputs
In reality, an “open collector”
output is an NPN transistor with its
collector connected to the output pin,
as shown in Fig.4 which is the sim-
plified schematic for one comparator
in an LM393. Because nothing is connected to this collector, we say it is
“open collector” (as in open-circuit).
For the transistor to work, it must
have a “pullup” resistor to the positive supply rail (in this case +12V).
When the transistor is “off”, the pullup resistor “pulls” the output high.
And naturally, when the transistor is
“on”, the output will be pulled low.
Now the point about comparators
with open collector outputs is that
you can connect two or more comparator outputs in parallel without
any chance of damage and they can
all drive a common load. Even more
to the point, if one comparator output
is on and all the others are off, the
common output is still low.
Some designers like to think of
this as an OR gate function whereby
all the comparator outputs are ORed
together. Personally, I don’t think this
helps in understanding the principle. It is quite simple – they’re all in
parallel and if one switches low, the
common output is low and that is
that; it doesn’t matter what the other
comparators do.
By the way, in some data books you
will see “open collector” outputs referred to as “uncommitted”. It means
the same thing.
The other point of difference between Fig.3 and the first circuit of
Fig.1 is that we have swapped both
sets of comparator inputs. If they’re
not swapped, you will find that the
single LED stays on all the time. If
you think about the circuit of Fig.1,
where at least one LED is on all the
time, then it stands to reason that if
we now use a common LED it will
be on all the time; hence the need to
swap the comparator inputs.
Oh and there is one other difference
between the circuits of Fig.1 & Fig.3.
In the latter diagram we have substituted “real world” values of 4.7kΩ for
the 5kΩ resistors and these change the
reference voltages slightly.
So now what happens as we vary
VR1? This will swing the input voltage to the two comparators over almost the full supply range. When the
input voltage is at its lowest (ie, with
Fig.2: use this diagram to wire up the circuit of Fig.1. Winding
VR1 up and down will cause the LEDs to light independently.
82 Silicon Chip
Truscott’s
•RESELLER FOR MAJOR KIT
RETAILERS
•PROTOTYPING EQUIPMENT
•COMPLETE CB RADIO
SUPPLY HOUSE
•TV ANTENNA ON SPECIAL
(DIGITAL READY)
•LARGE RANGE OF
ELECTRONIC COMPONENTS
Professional Mail Order Service
Fig.3: this circuit is similar to Fig.1, using two comparators, one inverting and
one non-inverting, but now they both have their outputs joined directly together
and they just drive the one LED. This is permissible because they have “open
collector” outputs.
VR1 set for maximum resistance),
pins 2 & 5 will be at around +2V; ie,
well below the reference voltages for
both comparators. As a result, IC1a’s
output will be high (ie, off) and IC1b’s
output will be low (on). Therefore
LED1 will light.
When the input voltage from VR1
is between +6V and +9V (say +7.5V)
both outputs (of IC1a and IC1b) will
be high and the LED will be off. And
when the input from VR1 is above
+9V, IC1a will be low (on) and IC1b
will be high (off), so LED1 will be
on again.
Wrong result
But this is exactly the reverse result
to what we wanted! We wanted LED1
to light only when the input voltage
from VR1 was between +6V and +9V.
What to do?
The easy approach would be to
use another comparator to invert the
common outputs of IC1a & ICb and
that is what you often see when a
window comparator is called for –
the design uses three comparators.
But there is a simpler way. Merely
by moving LED1 so that it is now between the commoned pins 1 & 7 and
0V, as shown in red on Fig.3, we get
the right result. LED1 now lights for
input voltages between +6V and +9V.
So that’s the window comparator:
two comparators driving a common
LED to indicate inputs between two
SC
separate voltage thresholds.
Fig.4: this is the
simplified schematic
for one comparator in
an LM393. It shows
the output as an
“open collector” NPN
transistor (Q8). This
requires a pullup
resistor for the NPN
transistor to work.
(National Semicon
ductor Linear Data
Book).
Truscott’s
Amidon
Stockist
ELECTRONIC WORLD Pty Ltd
ACN 069 935 397
Ph (03) 9723 3860
Fax (03) 9725 9443
27 The Mall, South Croydon, Vic 3136
(Melway Map 50 G7)
email: truscott<at>acepia.net.au
www.electronicworld.aus.as
P.C.B. Makers !
•
•
•
If you need:
P.C.B. High Speed Drill
3M Scotchmark Laser Labels
P.C.B. Material – Negative or
Positive acting
•
Light Box – Single or Double
Sided – Large or Small
•
•
Etch Tank – Bubble
•
•
Prompt and Economical Delivery
Electronic Components and
Equipment for
TAFEs, Colleges and Schools
FREE ADVICE ON ANY OF
OUR PRODUCTS FROM DEDICATED
PEOPLE WITH HANDS-ON
EXPERIENCE
We now stock Hawera Carbide Tool Bits
KALEX
40 Wallis Ave E. Ivanhoe 3079
Ph (03) 9497 3422 FAX (03) 9499 2381
ALL MAJOR CREDIT CARDS ACCEPTED
MARCH 2001 83
|