Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Introduction:

The goal of this Confluence page is to explain an application of operational amplifiers, specifically Comparators, in addition to explaining the fundamentals of an Operational Amplifier. This also serves as an explanation to our HW onboarding activities, where we ask people to design a simple comparator circuit. There is an extension question that asks people : What if the values being compared are the same? The solution will be explained in this article. It’s worth noting that Comparators are an application of an Operational Amplifier, however this doesn’t mean you should go buy an off-the-shelf Operational Amplifier to use as a Comparator. There are some reasons for this, but that is beyond the scope of this article.

What is an Operational Amplifier?

An operational amplifier, as the name suggests , amplifies signals. More specifically, it is a voltage amplifier with differential inputs, and usually a single-ended output(there is one output). In the diagram below, Vs+ and Vs- are the supply rails for the amplifier, so usually Vs+ = Supply Voltage and Vs- = Ground.

...

If it wasn’t clear already, op-amps operate on analog inputs, and can be used to amplify/attenuate these inputs and carry out mathematical operation(addition, subtraction, differentiation and integration, yes it can do calculus). Because of this, you’ll see opamps in many circuits and ICs. Ideally, an operational amplifier will only amplify the difference in voltage between the two, which is called differential input voltage. The output Vout is governed by this equation here:

Vout = Avo x (V+ - V-)

Avo is the open loop gain of the amplifier(open loop refers to how there is no external feedback loop from the output to the inputs, this will be discussed later)

Operational Amplifier Models / Assumptions

image-20240901-231115.pngImage Added

If this look intimidating to you, I’ll try to break this down. The top figure shows an equivalent circuit model of a voltage amplifier. If you haven’t been introduced to a circuit course yet, that diamond shaped voltage source is called a Dependent voltage source, where the voltage output depends on certain components of the circuit. For modelling purposes this is used, let’s do some analysis on it. Note that Av refers to Amplifier Gain(In this context, Voltage Out / Voltage In)

By voltage division in figure b on the right loop,

Vo =Avo Vi (RL / (Ro + RL)

Av = Vo / Vi = Avo (RL / (Ro + RL)

So in other for the amplifier to not lose gain when we couple the amplifier output to a load, Ro << RL .

If RL approaches infinity, and R0 is very small(close to 0), Av = Avo . This tells that for an ideal opamp, Ro = 0. In other words, output resistance is very negligible/zero

By voltage division in figure b on the left loop knowing we have some finite input resistance

Vi = Vs (Ri / (Ri + Rs )

So in other for the amplifier to not lose too much of the input signal when we couple the amplifier input to a source, Rs << Ri . In other words, in an ideal opamp, Ri approaches infinity(By Ohm’s Law, Current into opamp terminals is 0)

The open loop gain of an ideal opamp is “infinite', in practice it’s somewhere between 100,000V/V and up. Ideally that would mean a very small voltage swing between the inputs would cause the output to be in the hundreds of thousands of volts, but practically the output is limited by the maximum and minimum values dictated by the supply rail voltages(This is known as saturation, this is how Comparators are used, will discuss more later).

Negative Feedback

As discussed above, because an op-amps gain is so high in an open loop configuration(stability is not really desirable), often we use negative feedback and configure resistor values to achieve a desired gain value. The circuit’s overall gain is determined primarily by the feedback network. We can calculate this out using the assumptions we stated above(of course, they aren’t perfect as these are ideal assumptions).

We must also keep note that in a closed loop the output does whatever is necessary to make the voltage difference between the inputs zero, the two inputs act as an imaginary short

image-20240901-234413.pngImage Added

Above we see an Inverting Amplifier Circuit. Conceptually, any attempt to raise the input voltage at the inverting input produces an inverted and highly amplified output voltage that flows backward, passing through R2 and connecting to the inverted input terminal, thereby suppressing the voltage rise at this terminal. The system stabilises at the output voltage that brings the voltage at the inverting input to 0V, equivalent to the voltage at the non-inverting input.

Using Ohm’s Law and Kirchoff’s Laws of Current, we can show that

ACL = Vout / Vin = (-R2/R1)

The gain is negative because the output waveform phase is opposite(phase shift by 180°), hence the name “Inverting Amplifier”. Notice that by changing values of R2 and R1 we can control the gain.

image-20240901-234937.pngImage Added

This is a non-inverting amplifier, so we can apply our assumptions from above and use KCL and Ohm’s Law to determine that

ACL = Vout / Vin = 1 + (R2/R1)

Note that if R2 = 0 and we remove R1, this becomes something known as a voltage follower/Unity Gain Amplifier). The gain is 1(Vout = Vin ) and it is often used in impedance conversion circuits/buffering circuitry

There’s a lot more circuits we can design such as summation amplifiers(it does exactly as the name sounds, it sums up voltages by a factor of their gain). Now let’s talk about Comparators.

Comparator Circuits :

A Comparator is effectively a specially designed high gain differential amplifier. This is why I mentioned that although Op-Amps could be used as Comparators, there are a few issues with that which I won’t discuss here.

A comparator will compare two voltages and output either a “1”(Often 3.3V or 5V, depends what is the supply voltage) or a “0”(Ground).to indicate which is larger. The way this works is just as I described in the beginning of this article. These circuits have many applications, such as threshold protection(Imagine you wanted a circuit to detect whether a Battery goes Over/Under voltage).

image-20240902-000900.pngImage Added

This is what a Operational Amplifier outputs. Now, you’re also probably asking : “What if the comparison thresholds are the same?”

...

In practice, this will cause oscillation of states(unstable). This is because signal noise at that comparison threshold will mean at undetermined times, the input will transition above and below the threshold. This is undesirable(

...

So, now to the big question : How do we combat this? One of the hints in the onboarding was “Hysteresis”, what is that?

Hysteresis and Positive Feedback

This concept is not isolated to Electrical Engineering, its also fundamental in Control Systems. 'Hysteresis is the dependence of the state of a system on its history.”

In this context, Hysteresis introduces two different threshold voltages to avoid these multiple transitions. The input signal must exceed the upper threshold to transition low or below the lower threshold to transition high. Effectively, the current output is “latched” like a memory circuit. This also goes to show that this has applications in Digital-Logic(Latches and FlipFlops are known as multivibrator circuits). Let’s illustrate this in practice.

Key Point : In Positive Feedback, the amplifier tends to stay in whatever output state its already in. It “latches” between one of two states, saturated positive or saturated negative.

image-20240902-001207.pngImage Addedimage-20240902-001231.pngImage Added

Source : https://www.ti.com/lit/ug/tidu020a/tidu020a.pdf?ts=1725157591056

It should be noted that some Comparator ICs have hysteresis integrated already, so you should always check datasheets/application notes

Note : What I’ve demonstrated above with the Hysteresis Comparator is also known as a Schmitt Trigger, which might be a name you’re more familiar with.