Comparator Circuits

Introduction

An operational amplifier, or Op-Amp, can be used to compare two input voltages and decide which is bigger.

This is very useful, for example, when using input transducers to detect when the temperature has exceeded a certain value or the light level is above a certain brightness. An analogue input transducer is usually used with a comparator if a digital output is required. A comparator takes an analogue input and has a digital output (either ON or OFF) and is therefore a very simple Analogue to Digital Converter (ADC).

Basic Functionality

An Op-Amp (such as the 741 IC) has two inputs:

• The Non-Inverting Input - this is labelled V+
• The Inverting Input - this is labelled V
When the Non-Inverting input is a bigger voltage than the Inverting input, the output will be as big as possible (i.e. ON). This can be written as:
if V+ > V then Vout > 0
Similarly, when the Non-Inverting input is a smaller voltage than the Inverting input, the output will be as low as possible (i.e. OFF). This can be written as:
if V > V+ then Vout ≤ 0
(assuming the Op-Amp has normal power supply arrangements).

Important Note: The maximum and minimum output voltages are usually about 2V less than the power supply voltages. For an Op-Amp connected to a 0V and 9V supply (i.e. a battery) the highest output voltage will be 7V and the lowest will be 2V. For an Op-Amp connected to ±15V supplies the maximum and minimum output voltages will be ±13V.

Several Examples

The Non-Inverting input is bigger than the Inverting input

The output will be as big as possible

The power supply is 9V, therefore

Vout = 7 Volts

The Non-Inverting input is smaller than the Inverting input

The output will be as small as possible

The lower power supply is 0V, therefore

Vout = 2 Volts

The Non-Inverting input is bigger than the Inverting input

The output will be as big as possible

The power supply is +12V, therefore

Vout = 10 Volts

The Non-Inverting input is smaller than the Inverting input

The output will be as small as possible

The lower power supply is −12V, therefore

Vout = −10 Volts

In Summary (using technical language):
An op-amp, used without any limiting feedback, will amplify the difference between the inputs by the open loop gain. As the open loop gain is assumed to be very large then even a very small difference between the inputs will result in the output saturating. The output saturating means that the output voltage gets as close to the supply voltage as it is able to. For example, if a standard 741 is used with ±15V power supplies then the output voltage will either be +13V or −13V unless the inputs are within a few microvolts of each other. In effect the op-amp is comparing the two inputs and giving an output that shows which of the inputs is bigger ... hence the op-amp is acting as a comparator.

The output voltage is given by the equation:

Vout = A0 (V+ − V)
Where A0 is the open loop gain. A0 is approximately 106 for standard Op-Amps

Using LDRs, Thermistors and Potentiometers

When comparators are used as an input subsystem with an analogue transducer (such as an LDR) one of the inputs is held at a fixed reference voltage. The other input is connected to a potential divider containing the input transducer. The output of the comparator will either be ON or OFF.

The two 10kΩ resistors form a potential divider and hold the Inverting input at 4.5V, this is the fixed reference voltage.

The LDR and the unlabelled resistor form a potential divider that determines the voltage at the Non-Inverting input, V+.

When it is DARK the resistance of the LDR is high and therefore V+ is a low voltage. The Non-Inverting input is smaller than 4.5V and the output is LOW or OFF.

When it is LIGHT the resistance of the LDR is low and therefore V+ is a higher voltage. The Non-Inverting input is bigger than 4.5V and the output is HIGH or ON

The fixed potential divider has been replaced with a potentiometer so that the reference voltage (Vref) at the Inverting input can be changed.

The thermistor and the unlabelled resistor form a potential divider that sets the voltage (V+) at the Non-Inverting input.

When it is COLD the resistance of the thermistor is high and the voltage at the Non-Inverting input is bigger than the reference voltage at the Inverting input. The output is HIGH or ON.

When it is HOT the resistance of the thermistor is low and the voltage at the Non-Inverting input is smaller than the reference voltage at the Inverting input. The output is LOW or OFF.

The potentiometer sets the temperate at which the output changes from HIGH to LOW or LOW to HIGH. At the point where the output changes state the voltages at the Inverting and Non-Inverting inputs are virtually the same.

The potentiometer provides a variable reference voltage (Vref) at the Inverting input.

The thermistor and the unlabelled resistor form a potential divider that sets the voltage (V+) at the Non-Inverting input.

The ±15V power supply means that the output will be either +13V or −13V.

When it is COLD the resistance of the thermistor is high and the voltage at the Non-Inverting input is bigger than the reference voltage at the Inverting input. The output is +13V and the Red LED is forward biased. Current flows from the Op-Amp through the resistor, through the Red LED and down to 0V.

When it is HOT the resistance of the thermistor is low and the voltage at the Non-Inverting input is smaller than the reference voltage at the Inverting input. The output is −13V and the Green LED is forward biased. Current flows from the 0V supply, through the Green LED and the series resistor and into the Op-Amp down to the −15V supply.

Range Detector

It can be very useful to know when an input is within a certain range of values. For example, a bath thermometer should tell you if the temperature is too hot or too cold or when it is within a given range and just right. This is achieved by connecting the input voltage to a pair of Op-Amps.

The three 10kΩ resistors form a potential divider that divide the 9V supply equally into three parts so that the Non-Inverting input of Op-Amp 1 is at 6V and the Non-Inverting input of Op-Amp 2 is at 3V.

The input voltage (Vin) is connected to the Inverting inputs of both Op-Amps

When Vin is less than 3V: The Non-Inverting inputs of both Op-Amps are larger than the Inverting inputs. Output 1 = +13V and Output 2 = +13V. There is no potential difference across the LED and the LED is therefore OFF.

When Vin is between 3V and 6V: The Non-Inverting input Op-Amp 1 is larger than the Inverting input and Output 1 = +13V. The Non-Inverting input Op-Amp 2 is smaller than the Inverting input and Output 2 = −13V. There is a potential difference of 26V across the LED and the series resistor. Current flows from Op-Amp 1 (source), through the resistor and LED and into Op-Amp 2 (sink). The LED is therefore forward biased and will be illuminated.

When Vin is more than 6V: The Non-Inverting inputs of both Op-Amps are smaller than the Inverting inputs. Output 1 = −13V and Output 2 = −13V. There is no potential difference across the LED and the LED is therefore OFF.

The LED is only lit when the input voltage is between 3V and 6V. The range of voltages can be changed by using different resistors for the potential divider or by using potentiometers to individually set each Non-Inverting input.

Inputs and Output Combinations

Different input and output combinations can achieve the same result. The output of the Op-Amp can source and sink current and the Inverting and Non-Inverting inputs can be either way round.

When the temperature rises, the resistance of the thermistor goes down. The voltage at the Non-Inverting input goes down. When it becomes less than the reference voltage the output voltage goes from 7V to 2V and the LED goes OFF.

When the temperature goes UP, the LED goes OFF.

Thermistor and resistor swap places. When the temperature rises, the resistance of the thermistor goes down. The voltage at the Non-Inverting input goes up. When it becomes more than the reference voltage the output voltage goes from 2V to 7V and the LED comes ON.

When the temperature goes UP, the LED comes ON.

Non-Inverting and Inverting inputs swap places. When the temperature rises, the resistance of the thermistor goes down. The voltage at the Inverting input goes down. When it becomes less than the reference voltage the output voltage goes from 2V to 7V and the LED comes ON.

When the temperature goes UP, the LED comes ON.

Non-Inverting and Inverting inputs swap places and Thermistor and resistor swap places. When the temperature rises, the resistance of the thermistor goes down. The voltage at the Inverting input goes up. When it becomes more than the reference voltage the output voltage goes from 7V to 2V and the LED goes OFF.

When the temperature goes UP, the LED goes OFF.

When the temperature rises, the resistance of the thermistor goes down. The voltage at the Non-Inverting input goes down. When it becomes less than the reference voltage the output voltage goes from 7V to 2V. The potential difference across the LED is now (9V − 2V) 7V and the LED comes ON. Current flows from the 9V rail, through the LED and resistor and into the Op-Amp which is acting as a current sink.

When the temperature goes UP, the LED comes ON.

Thermistor and resistor swap places. When the temperature rises, the resistance of the thermistor goes down. The voltage at the Non-Inverting input goes up. When it becomes more than the reference voltage the output voltage goes from 2V to 7V. The potential difference across the LED is now only 2V and the LED goes OFF.

When the temperature goes UP, the LED goes OFF.

Non-Inverting and Inverting inputs swap places. When the temperature rises, the resistance of the thermistor goes down. The voltage at the Inverting input goes down. When it becomes less than the reference voltage the output voltage goes from 2V to 7V. The potential difference across the LED is now reduced to 2V and the LED goes OFF.

When the temperature goes UP, the LED goes OFF.

Non-Inverting and Inverting inputs swap places and Thermistor and resistor swap places. When the temperature rises, the resistance of the thermistor goes down. The voltage at the Inverting input goes up. When it becomes more than the reference voltage the output voltage goes from 7V to 2V. There is a 7V potential difference across the LED and the LED comes ON.

When the temperature goes UP, the LED comes ON.

Important Note: All of the above examples assume that the LED needs more that 2V to conduct and that when the potential difference is 2V then the LED is in actual fact OFF. There are some LEDs where this is not the case and 2V is sufficient to turn them ON. In this case, placing a normal diode with a 0.7V forward bias voltage drop in series with the LED is usually sufficient to make the circuits behave as expected. Alternatively rail to rail Op-Amps can be used.