It’s easy to forget that most PIC microcontrollers port one or more uncommitted analog comparators. For example, after my article “An Easy Two-Wire LCD” appeared in Nuts & Volts (February 2014, pp.
30-36), all of a sudden it hit me (a slap on the forehead
moment) that the transistor inverter required there could
be completely eliminated — including its two resistors —
and replaced with an internal comparator within the
driving PIC chip. Just like that, the parts count shrinks by
three components, and at no extra cost.
Apart from forgetting to make good use of these
comparators, there’s that business of the datasheet. On
the one hand, I’m delighted Microchip (the manufacturer
of PICs) has given us such comprehensive materials to
work with. Yet, who hasn’t dragged their feet when first
approaching this huge daunting manual?
That’s where this article comes in. Besides reminding
you of the utility of comparators, it will reorganize the
concepts of the datasheets into something more
approachable. We’ll get the big picture in mind first, and
only after that will we proceed to the details.
Along the way, seven experiments give you a chance
to really nail everything down; these are the very tests I
performed to confirm what was going on. With just a
handful of common components at your side and a
couple sessions at the breadboard, you’ll be all set to
design your own PIC circuits exploiting analog
The Big View
As mentioned, just about all of the PIC chips contain
at least one analog comparator available for use in various
modes or configurations. To keep things specific here, let’s
By Thomas Henry
Analog comparators, though not particularly sexy, must surely rate as one
of the more useful building blocks for a wide variety of circuits. They can be
used to generate pulse width modulation, monitor under- or over-voltages,
shape up ugly signals into nice crisp pulse waves, act as logical inverters,
help with interfacing mechanical switches, and more. A comparator has
two analog inputs and a lone output, which can be considered digital since
it can assume only two possible states. If the voltage on what's referred to
as the non-inverting input exceeds that on the inverting input, then the
output snaps high; otherwise, it remains low.
50 February 2015