Friday, July 22, 2022

0000 0000 1001 1111

LM339 Quad Comparator

It is useful to both display and be able to react to analog inputs. A microcontroller such as the ATTiny13 or PFS154 is fine for this, but you could also go a bit "old school" and use a comparator such as the LM339.


The scenario is that a 12V battery is "green" above 9V, fine from 3V-9V and "red" below 3V.

Using the LM339 a "window comparator" can be made according to the following circuit diagram.


The first voltage divider (two resistors) simulates voltage changes for an analog input to be tested, whilst the second one with the three resistors "sets" the cutoffs for the window comparator.


The input to be tested is tied to the inverting input of one comparator and the non-inverting input of another comparator. The cutoffs are fed to the remaining inputs, and then the output will reflect where the testing voltage has landed.

Two weird things about the LM339 which caused me pause during the build. One is the unusual position of VCC/GND compared to a lot of CMOS chips, and the other is the fact that it does not source current from it's "outputs" - but rather sinks current. That was a bit unexpected!



I built up the circuit on a breadboard using 1206 components on my own breakout PCB (comes in handy!) - and it all worked as expected.

Here is the resulting circuit and video.



No comments:

Post a Comment