Comparator Behaviour
A comparator compares two input voltages. These are usually a reference voltage
and a signal from a sensor. The output switches state when the the signal input
crosses the reference voltage.
The comparator relies on the very high open loop gain of the op' amp'.
For a real-life op' amp' this gain will be between 105 and 107.
This means that a potential difference between V1 and V2 of only a few microvolts is sufficient to saturate the op' amp'.
- If V1 is greater than V2 then Vout will go
high (close to the + supply voltage)
- If V1 is less than V2 then Vout will go
low (close to the
- supply voltage).

Comparator Example
The task is to have an indicator light come on when the light level drops below
some chosen value. The circuit could be scaled up to turn on room, car or street
lights when it gets dark.
Here is a system diagram of the system.
- Input - The light dependent
potential (input from from an LDR).
- Process - The comparator
- Output - The driver and output
to the indicator light.

If the op amp needs to drive a load, a driver circuit might be needed. Here
is an example.
- R1 limits the trasistor base current to a safe level.
- R2 limits the LED current to a level less than 20mA
- Since Vout might never go below 2V (MOSFET Op Amp), the two diodes
are needed to ensure that the transistor turns right off when the comparator
output is low.
- Each diode has 0.7V across it. The transistor needs 0.7 volts to turn on.
(2.1V total).

V1 is a reference voltage. This can be provided with a potential
divider. (A potentiometer could be used to make the reference voltage adjuatable.)
R3 and R4 form a potential divider.

V2 is the measured voltage from the light sensor. This is also a
potential divider circuit. R5 and the LDR form a potential divider.
As the light level increases, the LDR resistance decreases. This reduces V2. Once V2 is less than V1, the op amp output goes high.

Explanation
- The resistor R5 and the light dependent resistor RLDR
form a potential divider. The potential V2 depends on the current
flowing through the LDR and R5. It is safe to assume that the current
flowing into the op amp is negligable. The value of R5 might need
to be changed depending on the properties of the LDR.
- The resistors R3 and R4 form another potential divider.
V1 is the voltage produced here. V1 will be half the
power supply voltage. This is assuming R3 and R4 are
equal. Again it is safe to assume that the current flowing into the op amp
is negligable.
- If V1 is greater than V2, the op amp will turn on
and VOut will be just less than the PSU supply voltage. (PSU voltage
- 2 Volts)
- If V1 is less than V2, the op amp will turn off and
VOut will be close to zero. (+2 Volts)
- If VOut is high the NPN transistor will turn on. If VOut
is low (0 to 2 volts), the NPN transistor will turn off. If VOut
is high, just under 1mA will flow through the resistor R1. This
is sufficient to saturate the transistor so the light emitting diode will
turn fully on. The 741 op amp can easily provide 1mA to drive the transistor.
- R1 limits the current through the LED and transistor to a safe
level less than 20 mA.
Tasks
Think of ways to improve this circuit.
- Could the threshold light level be made adjustable? How? Draw the circuit
diagram.
- Could the power consumption be reduced? How?
- Instead of truning on an indicator light, could a high power circuit be
turned on? How? Draw the circuit diagram.
- When driving room lights, the circuit flashes the lights on and off rapidly.
How could this be prevented?