A comparator is a device that compares two voltages or currents and switches its output to indicate which is larger. A standard op-amp can be used as a comparator as indicated in Figure 1.

Figure 1

VOUT = VDD when V1 > V2
VOUT = VSS when V1 < V2

When the non-inverting input (V1) is at a higher voltage than the inverting input (V2), the high gain of the op-amp causes it to output the most positive voltage it can. When the non-inverting input (V1) drops below the inverting input (V2), the op-amp outputs the most negative voltage it can be.


An op-amp comparator can be used as a voltage level detector. Figure 2 shows a level detector that compares a Direct Current (DC) reference voltage (VREF) of 3 V to VIN with VDD = 10 V and VSS = -10 V

Figure 2

When Vin exceeds 3 V, Vout goes to the 10 V positive rail due to its high gain, open-loop configurations. When it falls below 3 V, Vout flips to the -10 V rail.

Figure 3
© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.