• Skip to main content
  • Skip to primary sidebar

Homemade Circuit Projects

Need circuit help? Post them in the comments! I've answered over 50,000!

Blog | Categories | About | Contact | Calculators-online
You are here: Home / Electronics Theory / How to Use an Op amp as a Comparator Circuit

DIY Circuits | Learn Basics | Arduino Coding




How to Use an Op amp as a Comparator Circuit

Last Updated on March 28, 2022 by Swagatam 56 Comments

In this post I will comprehensively explain how to use any opamp as a comparator in a circuit for comparing a input differentials and producing the corresponding outputs.

What is an Op amp Comparator

We've been using an op amp IC probably since we started learning electronics, I am referring to this wonderful little IC 741, through which virtually any comparator based circuit designing becomes feasible.

Here we are discussing one of the simple application circuits of this IC where it is being configured as a comparator, no surprise the following applications can be modified in numerous different ways as per the user preference.

As the name suggests, opamp comparator refers to the function of comparing between a particular set of parameters or may be just a couple of magnitudes as in the case.

Since in electronics we are primarily dealing with voltages and currents, these factors become the sole agents and are used for operating or regulating or controlling the various components involved.

In the proposed op amp comparator design, basically two different voltage levels are used at the input pins for comparing them, as shown in the below diagram.

how to configure op amp input pins for voltage comparison
REMEMBER, THE VOLTAGE ON THE INPUT PINS SHOULD NOT EXCEED THE DC SUPPLY LEVEL OF THE OP AMP, IN THE ABOVE FIGURE IT SHOULDN'T EXCEED +12 V

The two input pins of an op amp are called the inverting (with a minus sign) and the non-inverting pin (with a plus sign) become the sensing inputs of the op amp.

When used as a comparator, one of the pins out of the two is applied with a fixed reference voltage while the other pin is fed with the voltage whose level needs to be monitored, as shown below.

how to add fixed reference to op amp

The monitoring of the above voltage is done with reference to the fixed voltage that's been applied to the other complementary pin.

Therefore if the voltage which is to be monitored goes above or falls below the fixed reference threshold voltage, the output reverts state or changes its original condition or changes its output voltage polarity.

Video Demo

How an Opamp Comparator Works

Let's analyze the above explanation by studying the following example circuit of a light sensor switch.

Looking at the circuit diagram we find the circuit configured in the following way:

We can see that the Pin #7 of the opamp which is the +supply pin is connected to the positive rail, similarly its pin #4 which is the negative supply pin is connected to the negative or rather the zero supply rail of the power supply.

The above couple of pin connections powers the IC so that it can carry on with its intended functions.

Now as discussed earlier, pin #2 of the IC is connected at the junction of two resistors whose ends are connected to the power supply positive and negative rails.

This arrangement of the resistors is called a potential divider, meaning the potential or the voltage level at the junction of these resistors will be approximately the half of the supply voltage, so if the supply voltage is 12, the junction of the potential divider network will be 6 volts and so on.

If the supply voltage is well regulated, the above voltage level will also be well fixed and therefore can be used as the reference voltage for the pin #2.

Therefore referring to the junction voltage of the resistors R1/R2, this voltage becomes the reference voltage at pin #2 which means the IC will monitor and respond to any voltage that might go above this level.

The sensing voltage which is to be monitored is applied to pin #3 of the IC, in our example it is via an LDR. The pin #3 is connected at the junction of the LDR pin and a preset terminal.

That means this junction again becomes a potential divider, whose voltage level this time is not fixed because the LDR value cannot be fixed and will vary with the ambient light conditions.

Now suppose you want the circuit to sense the LDR value at some point just around when dusk falls, you adjust the preset such that the voltage at pin #3 or at the junction of the LDR and the preset just crosses above the 6V mark.

When this happens the value rises above the fixed reference at pin #2, this informs the IC about the sense voltage rising above the reference voltage at pin #2, this instantly reverts the output of the IC which changes to positive from its initial zero voltage position.

The above change in the state of the IC from zero to positive, triggers the relay driver stage which switches ON the load or the lights which might be connected to the relevant contacts of the relay.

Remember, the values of the resistors connected to pin #2 may also be altered for altering the sensing threshold of pin #3, so they are all inter-depended, giving you a wide angle of variation of the circuit parameters.

Another feature of the R1 and R2 is that it avoids the need of using a dual polarity power supply making the involved configuration very simple and neat.

Interchanging the Sensing Parameter with Adjustment Parameter

As shown below, the above explained operation response can be just reversed by interchanging the input pin positions of the IC or, by considering another option where we only inter-change the positions of the LDR and the preset.

THis is how any basic opamp behaves when it is configured as a comparator.

To summarize we can say that in any opamp based compartaor, the following operations take place:

 Practical Example#1

1) When the inverting pin (-) is applied a fixed voltage reference, and the non-inverting (+) input pin is subjected to an altering sensing volatge, the output of the opamp remains 0V or negative as long as the (+) pin voltage stays below the (-) refernce pin voltage level.

Alternately as soon as the (+) pin volatge goes higher than the (-) voltage, the output quickly turns positive supply DC level.

Example#2

1) Conversely, when the non-inverting pin (+) is applied a fixed voltage reference, and the inverting (-) input pin is subjected to an altering sensing voltage, the output of the opamp remains supply DC level or positive as long as the (-) pin voltage stays below the (+) refernce pin voltage level.

Alternately as soon as the (-) pin voltage goes higher than the (+) voltage, the output quickly turns negative or switches OFF to 0V.

Basic Comparator Working

The circuit in the below figure operates in a relatively straightforward manner: The combination of R2 and Zener diode D1 produces a fixed reference voltage (VREF). It is applied straight to the op-non-inverting amp's input terminal, pin 3. Via the current limiting resistor R1, the input or test voltage VIN is connected to the inverting input terminal (pin 2). When VIN is less than VREF, the op amp output is high (to positive saturation), but when VIN is greater than VREF, the output is low (to negative saturation).

Op amp Comparator with High Voltage Input

As shown in the below figure, using a VOLTAGE DIVIDER, we can utilize a voltage comparator to provide high-value, variable voltage triggering. There is no regenerative switching in this circuit.

Op Amp Comparator with High Value Input, Regenerative Switching

The next circuit, like the previous one, provides high-value, variable-voltage input switching (0 to 150 V). It has regenerative switching capabilities.

Op Amp Comparator as Over Current Indicator

When the load current reaches a value defined by R6, the output turns high to indicate an over current situation. By inverting the connections to IC1's pins 2 and 3, the output will go low to indicate an over-current situation.

The diagram below demonstrates how a comparator circuit may be configured to operate as an over-current switch, producing a high output when the load current exceeds a given value - which you can set using potentiometer R6. Current sensing resistor RX is set such that it drops around 100 millivolts at the appropriate trip point. As a result, a fixed reference voltage equal to 1/2 the supply voltage is provided to pin 3 of the op amp through the voltage divider comprised of R3 and R4. Pin 2 receives a similar but current-dependent voltage through Rx, R1, R6, and R2.

In fact, the two sets of components form a Wheatstone bridge, with one side supplying pin 3 and the other supplying pin 2, and the op-amp serving as a bridge-balance detector. As a result, the circuit's trip points are unaffected by fluctuations in supply voltage but are very sensitive to changes in load current.

You'll also like:

  • sineDCwaveformdigaramDifference Between Alternating Current(AC) and Direct Current(DC)
  • How To Use And Program ATmega Microcontrollers From Scratch Without Arduino
  • LED structuresLight Emitting Diodes (LED) Explained
  • AND gateHow Logic Gates Work

Filed Under: Electronics Theory Tagged With: Comparator

About Swagatam

I am an electronics engineer and doing practical hands-on work from more than 15 years now. Building real circuits, testing them and also making PCB layouts by myself. I really love doing all these things like inventing something new, designing electronics and also helping other people like hobby guys who want to make their own cool circuits at home.

And that is the main reason why I started this website homemade-circuits.com, to share different types of circuit ideas..

If you are having any kind of doubt or question related to circuits then just write down your question in the comment box below, I am like always checking, so I guarantee I will reply you for sure!

Previous Post: « Homemade 2000 VA Power Inverter Circuit
Next Post: How to Make a Telephone Amplifier Circuit »

Reader Interactions

Comments

Janesh Joshi says:
December 22, 2014 at 7:48 am

Hi Swagatam, I am trying to make a kind of comparator cum voltage level detection circuit. Basically there are two main components to it. First is the strain gauge which gives either NEGATIVE voltage or POSITIVE voltage – only one is present at a time. Now whenever this voltage is present I require an output of 5 VDC from the circuit. This 5volts should be triggered when the input voltage is either 2.5 V and above or -2.5V and above i.e. upto -5 volts. I want to use dual rail 12 volt supply as it is available with my system. Kindly suggest me a circuit design.

Reply
Swagatam says:
December 23, 2014 at 4:56 am

…….The R1/R2 should be referenced to ground and not to (-) of the supply

Reply
Swagatam says:
December 23, 2014 at 4:53 am

Hi Janesh, you can do it by using two 741 IC opamp configured as comparators, as shown in the above diagrams, but the supply will need to be dual not single. It should be dual 5V supply since the required output is 5V

So the supply (+)5v and (-)5v go across the R1/R2 and the pin7/4 rails.

The outputs of the two opamps may then be connected to the input of a bridge rectifier…the output from the bridge will generate the intended 5V for the specified conditioned.

one of the opamps will have its pin3 clamped with +/- via rail via R1/R2 while the other with its pin2.

The free ends of the relevant opamp inputs could be configured with the strain gauges.

The +/- 5V supply can be created with the help of 7805/7905 complimentary pair ICs

Reply
Sravya Sekhar says:
May 27, 2014 at 10:26 am

Hi,thanx a lot for your projects .How do I go about constructing a minute circuit which senses light and create an alarm if the light gets below a particular set value?

Reply
Swagatam says:
May 28, 2014 at 4:16 am

Hi, thanks, you can try the last circuit shown in the folowing article:

https://www.homemade-circuits.com/2012/01/how-to-make-light-activated-day-night.html

You can replace the relay with a small buzzer for getting the required alarm.

Reply
Swagatam says:
October 30, 2013 at 5:19 am

good evening…the image is not opening.

Reply
Back to Newest

Need Help? Please Leave a Comment! We value your input—Kindly keep it relevant to the above topic! Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

circuit simulator image



Subscribe to get New Circuits in your Email



Categories

  • Arduino Projects (93)
  • Audio and Amplifier Projects (133)
  • Automation Projects (17)
  • Automobile Electronics (101)
  • Battery Charger Circuits (86)
  • Datasheets and Components (109)
  • Electronics Theory (149)
  • Energy from Magnets (27)
  • Games and Sports Projects (11)
  • Grid and 3-Phase (20)
  • Health related Projects (27)
  • Home Electrical Circuits (13)
  • Indicator Circuits (16)
  • Inverter Circuits (95)
  • Lamps and Lights (159)
  • Meters and Testers (71)
  • Mini Projects (28)
  • Motor Controller (68)
  • Oscillator Circuits (28)
  • Pets and Pests (15)
  • Power Supply Circuits (91)
  • Remote Control Circuits (50)
  • Renewable Energy (12)
  • Security and Alarm (64)
  • Sensors and Detectors (106)
  • SMPS and Converters (34)
  • Solar Controller Circuits (60)
  • Temperature Controllers (43)
  • Timer and Delay Relay (49)
  • Voltage Control and Protection (42)
  • Water Controller (36)
  • Wireless Circuits (30)





Other Links

  • Privacy Policy
  • Cookie Policy
  • Disclaimer
  • Copyright
  • Videos
  • Sitemap



People also Search

555 Circuits | 741 Circuits | LM324 Circuits | LM338 Circuits | 4017 Circuits | Ultrasonic Projects | SMPS Projects | Christmas Projects | MOSFETs | Radio Circuits | Laser Circuits | PIR Projects |

Social Profiles

  • Twitter
  • YouTube
  • Instagram
  • Pinterest
  • My Facebook-Page
  • Stack Exchange
  • Linkedin



Recent Comments

  • Swagatam on BLDC Ceiling Fan Circuit for Power Saving
  • DANIYA on BLDC Ceiling Fan Circuit for Power Saving
  • Johnny on IC 723 Voltage Regulator – Working, Application Circuit
  • Swagatam on 9 Simple Solar Battery Charger Circuits
  • Karthik B S on 9 Simple Solar Battery Charger Circuits

© 2026 · Swagatam Innovations