Fig. 1 Window Comparator using LM358
Looking at Window Comparator Circuits
by Lewis Loflin
The circuit above is what is called a "window comparator." This will out a digital "HIGH" at "X" and a digital "LOW" at pin 2 of the 74LS04 covering a preset voltage range. This 74LS04 can be any inverter or buffer such as a 74LS07 which has an open-collector output.
Looking at the 4N29 or similar opto-coupler, we use this to change the analog voltages on the left side of the circuit to a digital logic level on the right side of the circuit. The output at either pin 1 (X) or pin 2 can drive any number of driver circuits to switch on motors fans, etc.
Just what does a window comparator do?
A conventional voltage comparator circuit is simply OFF or ON. A window comparator is ON in a fixed voltage rage and OFF outside that voltage range.This circuit uses an Lm358 dual op-amp. This is a single supply device that operates well at 5-volts and comes in a single 8-pin package. In fact the same circuit will work with 12-volt sensors by changing the supply voltage (only) on the left side of the opto-coupler. The potentiometer connected to pins 3 and 6 simulates the voltage output of an analog sensor.
The voltage dividers at pins 2 and 5 set the upper and lower limits for the comparator. As I adjust the potentiometer LED1 will come on when the voltage is between the points set by the HIGH and LOW reference points at pins 2 and 5. Make sure the voltage at pin 2 is higher than pin 5, otherwise the values can be selected.
In fact the two voltage dividers using fixed resistors can be changed to 10K potentiometers for precise adjustment of the "window" of operation.
Fig. 2 Window Comparator using two Lm311s.
In Fig. 2 I used two Lm311 comparators. The circuit operates in the identical manner as Fig. 1 and the opto-coupler section and the two 5K potentiometers will work just fine in Fig. 1.
To test the circuit adjust the HIGH set control (Tp1) to 4-volts and set the LOW set control (Tp3) to 2-volts. Measure Tp2 and the LED will come on from 2 to 4 volts.
In either circuit above LED1 and its resistor can be replaced with Solid State AC Relays with Triacs or an electromechanical relay or contactor.