Practical_Electronics-May_2019

([email protected]) #1

Circuit Surgery


54 Practical Electronics | May | 2019


Regular clinic by Ian Bell


Comparator circuit design


R


ecently, there have been a
few posts about comparators on the
EEWeb forum (www.eeweb.com/
forum/). Qasim Ahtesham asked: ‘Has any-
body worked with an LM741 and used it
for voltage comparison? I am trying to use
one to compare two voltages, and use this
as a thermostat. The issue is that once V+



V– the output voltage is 1.3 to 1.6V, but
not 0V. Do I need to add offset? I am only
using the 5 pins at the moment. Any help
on this, or a precise design for comparing
the voltages will be highly appreciated.’
Graham Rounce posted: ‘I’d like a simple
way to determine if a voltage is outside of
a certain band. Say, from +2V to +3V. I’d
like a circuit with an output that goes high
(5V) if the input voltage is =<2V or =>3V.
Ideally, I’d like two separate outputs, one
for =<2V and the other for =>3V. Op amp(s)
will no doubt fi gure in the answer some-
where, but I get a bit confused when using
them with a single (5V) supply.’
So, our next topic is comparators. We
will look at their basic principles of op-
eration, including the ‘Schmitt trigger’,
or hysteresis, behaviour which is often
set up in comparator circuits, and which
has also been discussed in recent forum
threads. Both initial posts mentioned op
amps (the LM741 is an op amp), rather
than comparator chips, although later in
the discussion on Graham’s question spe-
cifi c comparator ICs such as the LM393
are mentioned. Thus, one of the things
we will look at is the difference between
op amps, which can be used as compara-
tors, and dedicated comparators. We will
use LTspice simulations to illustrate cir-
cuit operation. In a recent series of Circuit
Surgery articles (October 2018 to January
2019) we covered some basics of LTspice,
but here we’ll need some operations not
covered there, such as simulating op amps
that are not in the library. We will look at
this separately next month, rather than ex-
plaining all aspects of the simulations here.



Basic confi gurations
In many applications, comparators are
used to compare an input signal with a
reference voltage generated within the
circuit. In such cases we can confi gure
either inverting or non-inverting operation
depending on which of the comparator’s
inputs is connected to the reference and
the input (see Fig.3). A non-inverting
comparator has a high output (logic 1)
when the input is greater than the ref-
erence. For an inverting comparator the
result is a high output when the input is
below the reference.
Graham’s requirement for a compara-
tor circuit with two outputs, indicating if

Defi nitions
A comparator is a circuit that compares
one analogue signal with another and
outputs a binary signal based on the
result of the comparison. In effect, it is a
one-bit analogue-to-digital converter. An
op amp used without negative feedback
(open loop) has very high gain, so for all
but a small range of input voltage differ-
ences the output will be at the lowest or
highest voltage available from the device
(saturation), typically close to the supply
rails. These two saturated output volt-
ages may represent Boolean 0 and 1. An
op amp used in this way behaves as a
comparator. However, its performances
may differ from that of a circuit specifi -
cally designed to act as a comparator. To
compare the two it helps to fi rst defi ne
comparator characteristics and see how
these relate to op amps.
The circuit symbol for a comparator
is shown in Fig.1 – at its most basic it is
the same as an op amp’s symbol. A com-
parator’s output voltage may be written
mathematically as follows:

Where vp and vn are the input voltages, as
shown on Fig.1 and VOH is the logic 1, or
high output voltage, and VOL is the logic
0, or low output voltage.
The above equation implies infi nite gain
and zero offset, VOS. This means that an
infi nitely small voltage change around
vp = vn will cause the output to switch
(infi nite gain), and that this switching
will occur exactly at vp = vn (zero offset).
Fig.2 shows the effect of fi nite gain and
offset on a comparator’s transfer char-
acteristic (relationship between input
voltage difference and output voltage).
The effect of the offset and fi nite gain
is to reduce the resolution of the com-
parator, so that the difference between
the inputs must be larger than a certain
minimum to give reliable detection. Fig.2
represents the situation for static inputs,
where the resolution is approximately
VOS + VIH = VOS + VOH/gain, but typically
the resolution will get worse for chang-
ing input signals.

Simulation fi les


The LTSpice fi les discussed in
Circuit Surgery are available for
download from the PE website.

+

vn –
Vout
vp

Ideal comparator
 Zero offset
 Infinite gain

Real comparator
 Non-zero offset
 Non-infinite gain

VOut

VOL

vp – vn

VOut









VOH

VOH

VOS

VOL

VIL VIH vp – vn









+


  • Vout


Vin

Vref Inverting comparator

+


  • Vout


Vin

Vref Non-inverting comparator

Fig.1. The symbol for a comparator – the
same as for an op omp.


Fig.2. Comparator transfer characteristics.

Fig.3. Inverting and non-inverting
comparator confi gurations.




< ⇒

> ⇒
=
if logic 0

if logic 1

OL p n

OH p n
out V v v

V v v
V^

␀!"=


᐀!


᐀!+᐀!


␀!"#+


᐀!


᐀!+᐀!


␀!


␀!"=


᐀!


᐀!+᐀!


␀!"#−


᐀!


᐀!+᐀!


␀!


␀"=␀!"−␀!"=


2 ᐀!


᐀!+᐀!


␀!


᐀!


᐀!+᐀!


␀!"


␀!"=


᐀!


᐀!+᐀!


␀!"


᐀!!"=


᐀!᐀!


᐀!+᐀!


␀!"=


᐀!!"


᐀!!"+᐀!


␀!!


᐀!!"=


᐀!᐀!


᐀!+᐀!


␀!"=


᐀!


᐀!+᐀!!"


␀!!

Free download pdf