Fork me on GitHub

Project Notes

#412 BJT Comparator

Investigating and testing a comparator design with discrete components.

Build

Notes

Comparators are used to compare two voltages, with a binary output (high or low).

These days, it is common to see OpAmps used as general purpose comparators. There are also specialised comparator ICs such as the LM311 (from the LM111 family - one of the first comparator IC families). Comparator ICs are typically for more demanding applications and may feature:

  • Integrated references
  • High-speed (fast propagation delay, rise and fall times)
  • Low-power

Comparator IC internals are relatively sophisticated; much of the complexity concerns temperature stability and balance adjustment. However at their heart, the basic concept of a comparator is a differential amplifier but with an output that swings between two states.

For this project, I’m going back to basics and attempting to implement a comparator with discrete transistors.

Design Inspirations

It was surprisingly difficult to find examples of BJT comparator circuits. It seems the field jumped very quickly to OpAmp and Comparator ICs.

The most useful references I found were:

  • Electronic Principles which presents a simplified schematic of an IC comparatorin section 22-13, p853
  • Art of Electronics 2.22 Temperature controller, p105 - a circuit that includes a BJT comparator in the control circuit

Design

Q1-4 comprise the differential amplifier with current mirror to provide an active load. Q5,Q6 current mirror limits the emitter current of the differential pair.

In the demonstration mode (which can be disconnected with jumpers), R1 and R2 are 100kΩ potentionmeters that effectively make a Wheatstone bridge for comparing the voltages at the wipers.

The output is tapped at the collector of Q4. In some comparator circuits, this may simply drive the base of an open-collector NPN output stage - however this will normally have a linear region and not a clear-cut on/off.

In this design, I’ve tapped Q4 collector to control high-side PNP (Q7) in turn switching an NPN (Q8) output stage - which presents as an open-collector output stage. An LED and current limiting resistor is the “load”, providing visual switching indicator.

Schematic

I built this up first and testing it on a breadboard..

Breadboard

Comparator_bb_build

Protoboard Construction

This is a nice demonstration circuit, so I made it a little more permanent on protoboard. With jumpers in place, the 100kΩ potentiometers set the input and reference voltage for the comparator.

Pin headers provide a breakout of:

  • Vi - for measuring the input voltage, or applying the input voltage if Vi jumper is removed
  • Vr - for measuring the reference voltage, or applying the reference voltage if Vr jumper is removed
  • Vo - comparator output
  • Power and Ground

Comparator_layout

Comparator_build

Testing

Here’s a scope trace that captures some manual manipulation of the input and reference voltage pots.

  • CH1 (Yellow) - input voltage Vi
  • CH2 (Blue) - reference voltage Vr
  • CH3 (Red) - comparator output voltage Vo

scope_example_1

Credits and References

About LEAP#412 BJTComparator
Project Source on GitHub Return to the LEAP Catalog

This page is a web-friendly rendering of my project notes shared in the LEAP GitHub repository.

LEAP is my personal collection of electronics projects, usually involving an Arduino or other microprocessor in one way or another. Some are full-blown projects, while many are trivial breadboard experiments, intended to learn and explore something interesting (IMHO!).

The projects are usually inspired by things found wild on the net, or ideas from the sources such as:

Feel free to borrow liberally, and if you spot any issues do let me know. See the individual projects for credits where due. There are even now a few projects contributed by others - send your own over in a pull request if you would also like to add to this collection.