The Classroom

The LM741 Op-Amp as a Comparator

Daniel Koch

Issue 25, August 2019

A simple tutorial about op-amps and how the popular LM741 can be used in circuits.

Operational Amplifiers are a very useful tool to the hobbyist and engineer alike. They are able to take a small input signal, and give a much larger output signal. They can be configured to do a range of jobs and behave in different ways. In this article, we will examine just some of the characteristics and functions of operational amplifiers, focusing on the LM741 IC.

We aren’t going to delve to the deepest engineering depths with this IC. The aim is to give the maker or hobbyist a functional understanding of what’s going on and how to transfer your working knowledge to a functional project. In future issues, we will cover other characteristics and functions of the operational amplifier using different devices.

WHAT MAKES AN OP AMP, AN OP AMP?

Operational Amplifiers, which are commonly abbreviated to op-amp, gained their name from one of their original uses. Once upon a time, long, long ago, computers were far different to those we know today. Digital computers existed, but were large, complex, and limited in what they could do, usually being built for a specific task.

There were also analogue computers, circuits designed to perform a set task using analogue electronics connected in such a way that analogue inputs would be used by very high-gain, precise amplifiers to perform ‘operations’ and yield a result.

Op-amps are set apart from other amplifiers by their very high gain, their precision, and their stability. These days, they come in Dual Inline Plastic (DIP) packages, the IC footprint most of us recognise. You may also see the surface-mount (SMD) version thereof. Other packages exist but most makers and hobbyists are unlikely to ever see or use them.

The LM741 is an 8 pin device. The LM741 itself is considered by many in the audio world to be outmoded, and indeed many replacements with better noise and distortion figures are available, but it is readily available and perfectly valid for sensors and the like.

OP-AMP GEOMETRY

Unlike a basic amplifier constructed from two or three transistors, where a signal comes in one side and goes out the other, the op-amp has two inputs and one output. In the circuit symbol, one input is marked with a ‘-’ symbol, and is called the ‘inverting’ input. The other input is marked with a ‘+’ symbol and is called the ‘non-inverting’ input. More on these shortly. These inputs are always on the base of a triangle, with the output always coming from the apex of the triangle, and often otherwise unlabelled. There are two power connections on op amps, as with most devices, but instead of being labelled as power and ground connections, they are ‘V+’ and ‘V-’. This is because op amps usually operate from a dual rail supply. Again, more on this shortly. Of the remaining connections, one is not connected, marked ‘NC’, while the other two are ‘offset null’ connections. These are only sometimes used.

These ‘operation amplifier based analogue computers’ were used in engineering, where inputs could be potentiometers, variable voltage sources, or other analogue devices used to vary parameters, such as the stresses on a precast concrete beam. The output from the machine would tell engineers how the beam would behave under those conditions, when it would fracture, or how it would break. Car suspension systems were also designed this way.

INPUTS

One of the things that sets an op-amp apart from other amplifiers is that it does not simply take something at its input, multiply it by a factor, and output it. An op-amp, in fact, measures the difference between its inputs and amplifies that. This means that there could actually be a signal of, say, 3 volts present at both inputs, but the difference between them is still 0 volts, so there is nothing to amplify, though of course we're dealing with a theoretical device here. [1]. This also means that the difference could be positive or negative, regardless of the polarity of the actual signal at the inputs. The inverting (-) input could be at -2.78 volts, and the non-inverting (+) input at -2.54. Both are negative but the difference between the inverting and non-inverting inputs is still 0.26, a positive value [2].

1
2

As a side note, op-amps have a tiny bias current at their inputs which needs a ground path. This current is usually in the order of microamperes but does need to get to ground in order for the op amp to work. As a result, circuits must be designed so that a path exists, but because the current is so small, this path can be quite a high resistance. As many inputs are given via a voltage divider, this occurs anyway.

GETTING TO KNOW OP-AMPS

Op-amps have several characteristics which users focus on. The first is voltage gain, and this will be the characteristic we use the most. A theoretical op-amp with ideal characteristics actually has an infinite gain. That is, a gain so high as to be beyond defining with numbers. Of course, nothing is ideal in the real world, so while a theoretical op-amp could produce an output even while its inputs have a differential of zero, even a very high quality, well designed op amp will not. However, a voltage difference of even picovolts at the input can produce an output in the right op-amp.

This means that the input differential involved may, in fact, be too small to read on many of the measurement instruments available to the maker. Many op-amps have a voltage gain in the order of 200 000 times, or even higher. The LM741’s datasheet lists its voltage gain as 200 volts output per millivolt of input difference. This makes them very sensitive, but too much so for many applications. There is a way to limit the gain, though, and we will discuss feedback circuits another time when we use them.

On a related note, many op-amps will produce a small DC gain even with an input differential of zero volts. This voltage is within a much lower range than the general voltage gain of the op-amp, and while its cause is detailed, knowing why adds no functional advantage. This is called the ‘offset’ voltage, and many op-amps include ‘offset null’ pins.

As the name suggests, these pins are used to ‘nullify’ or render effectively non-existent, the offset voltage. The LM741’s datasheet lists the offset voltage range as +/- 15mV at only 20 nanoamperes. Circuits that use offset will be covered with another op-amp later on, but being familiar with the idea is still useful.

Another characteristic of importance for many makers will be the resistance of the inputs. Note that this is the resistance between the inputs, not between an input and ground, as would often be the case with many other integrated circuits. In a theoretically perfect op-amp, the input resistance is infinite so that no current is drawn. In reality, some current must flow. Because of this, most op-amps have an input resistance of at least 1MΩ, and sometimes as high as 100MΩ. The LM741’s datasheet has its input resistance listed as 2MΩ. That means that even if the input differential was 24V, quite a high figure as far as most maker op-amp circuits are concerned, the current at the input is 12μA, small enough to usually ignore.

This very high input resistance means that makers can confidently construct op-amp circuits that monitor parameters without having any appreciable influence on the circuit. Of course, there are times when you may be working with a circuit that does care, but we will not approach those just yet.

The output of an op-amp also has a resistance, but under theoretical conditions this should be zero. Of course, we know there is no such thing as truly zero resistance (ignoring the physics debates around superconductors), but the lower the output resistance, the better. The LM741 datasheet does not specify an output resistance, but it does specify something else - the output current. At short circuit, the op-amp should have no more than 25mA passing through it. For practical purposes, this should be kept less again. In other words, any op-amp circuit you design will almost certainly be using an output device like a transistor, although for feeding signals into, say, an Arduino, 20mA is ample.

HOW ARE OP AMPS USED?

Op-amps can be used in a variety of formats, the most common being as an ‘inverting amplifier’, a ‘non-inverting amplifier’, as a ‘buffer’, an ‘oscillator’ and as a ‘comparator’. Rather than trying to explain them all at once theoretically, we’re going to introduce each function one at a time, using a different op-amp and a practical circuit. This will occur across several instalments.

The LM741 is somewhat ubiquitous in the realm of op-amps, but it is old. While still manufactured and used widely, it has its limitations for many uses. We are going to use it to explain the comparator.

As mentioned earlier, most op-amps have connections for both negative and positive power connections, with ground being separated [3]. Dual rail power supplies are another story altogether, and not so many of the power supplies around many makers’ workbenches will be dual rail. When building a comparator, however, there is a way to use a single rail supply, using a voltage divider to get the required voltages at the right places.

3

WHAT IS A COMPARATOR?

A comparator takes its name from its role of ‘comparing’ two signals against each other, and giving an output accordingly. While there are differences, and some are quite complex indeed, the majority conform to this model [4]: The non-inverting input is fed with a reference voltage, usually referenced against ground rather than the negative rail. The inverting input is connected to an input, usually from a sensor. The output is connected without any feedback going to the inputs, which means that it will have only two states: Almost the full positive supply voltage or almost the full negative supply voltage, depending on whether the inverting input is more or less positive than the reference voltage.

4

To make life simpler, our comparator uses a single rail supply, and a voltage divider to gain the reference voltage. The principle stays the same. If the voltage at the inverting (-) input is higher than the reference voltage at the non-inverting (+) input, the output stays almost at the lowest limit [5], which in this case is ground, (rather than the negative rail, which we don’t have). As soon as the voltage at the inverting input drops below the reference voltage fed to the non-inverting input from the voltage divider, the output is driven to its highest possible value [6], just below the supply voltage.

5
6

So while similar to the theoretical comparator, our practical example has some differences. In addition, ours has an output stage that can comfortably drive an LED as an indicator of output, and do so independently of the rest of the circuit. The same network could also drive larger loads such as a buzzer or relay. Our circuit uses a Negative Temperature Coefficient Thermistor as a sensor. NTC thermistors have a resistance that varies with temperature. The relationship of resistance to temperature is on a curved scale, rather than linear, but resistance increases as temperature decreases.

Hands On:

The Circuit

Parts Required: JaycarAltronicsCore Electronics
1 × BreadboardPB8820P1002CE05102
1 × Breadboard Wire LinksPB8850P1014ACE05631
1 × 1kΩ PotentiometerRP7504R2223ADA562
1 × 510Ω Resistor*RR0565R7551COM-05092
1 × 1kΩ Resistor*RR0572R7558COM-05092
1 × 4.3kΩ Resistor*RR0587R7573COM-05092
2 × 4.7kΩ Resistor*RR0588R7574COM-05092
1 × 10kΩ Resistor*RR0596R7582COM-05092
1 × 4.7kΩ NTC ThermistorRN3438--
1 × LM741 Op-Amp ICZL3741Z2590-
1 × BC548 TransistorZT2154Z1042-
1 × LEDZD0152Z0800CE05103

Parts Required:

As this is The Classroom and not a project, focusing on theoretical concepts, we don’t have space for step by step instructions. However, this circuit is intended for you to build. As such, we have both the schematic and Fritzing, but if you were to build it to use permanently, transposition to strip or grid protoboard would be recommended.

Taking a close look at the circuit diagram, at the far left is a voltage divider formed by the 3.9kΩ resistor R1, 1kΩ potentiometer VR1 and the 4.7kΩ NTC thermistor R2. Incidentally VR1 is wired here as a rheostat and not as a potentiometer, but let’s not go there. Note that VR1 and R1 are treated here as one item. This is because, while a 5kΩ potentiometer would do, we would only be using a small part of its travel for our adjustment range. Adding a 3.9kΩ fixed resistor to a 1kΩ pot means that much more of the travel is usable range. The junction between VR1 and R2 is connected to R3, a 10kΩ resistor which serves to limit the current to the op amp’s input should VR1 be reduced too far. The other end of R3 is connected to IC1’s inverting input, pin 2.

Next is another voltage divider, formed by R4 and R5, both 4.7kΩ resistors. These serve to give the non-inverting input a reference voltage of half the supply voltage. Generally, resistors vary within the stated tolerance but we were lucky - the two resistors chosen for our prototype where exactly 4668Ω each, not quite 4.7kΩ but at least identical. IC1, the LM741 op-amp at the heart of the endeavour, is shown with its v- terminal connected to ground. This is only because we are using a single rail supply, and have set our reference voltage half way between ground and supply by the voltage divider formed by R4 and R5. Other points to note are that the two ‘offset null’ connections are left floating - with our output going almost completely high and almost completely low, these are not needed.

Finally, an output circuit is to the right of the IC. In consists of NPN transistor Q1, with is base connected to Pin 6, the output of IC1, via a 1kΩ resistor, R6. The collector is connected to the supply rail, while the emitter is connected to LED1 and its current limiting resistor R7.

The circuit really is that simple, and on the test bench, proved versatile. As configured, the LED lights as soon as the set temperature is exceeded. The threshold is set by R1/VR1, which changes the ratio of the voltage divider formed by it and R2. Note that the rating of NTC thermistors is generally for an ambient temperature; that is, a middle point rather than a minimum or maximum. In electronics, ‘ambient’ is often given as 25°C, while in chemistry, it is often 21°C. Check the datasheets for the device you buy to be sure, but the result will be minimal.

HOW IT WORKS

Current flows through the voltage divider formed by VR1/R1 and R2, with the voltage at the junction of these being a ratio of their values. From here, R2 is connected to the inverting input of IC1, at pin 2, which measured 6.03V in our test.

Meanwhile, the two 4.7kΩ resistors gave a measurement of 5.99 volts at pin 3, the non-inverting input (+). This means that the inverting input was 0.04V more positive than the non-inverting input, which means that the output is low, when the inverting input is more positive, the output does the opposite and goes as negative as it can go. In this circuit, that is to ground.

As the temperature at the NTC thermistor rises, its resistance falls. Before testing, VR1 had been turned gently until the LED turned off, then adjusted back and forth until it was on a knife’s edge. Then, heat from a heat gun was aimed at the thermistor. Instantly, the LED turned on. This is because the resistance of R2 fell, which combined with VR1/R1 to give a voltage still a ratio of the two resistors, but lower than the 5.99 volts at the non-inverting input. Now, as the non-inverting input is the one with a higher voltage, the output goes as high as it can go. This is fed to Q1 as noted above.

Calibrating this device means finding a temperature source of known value. If you were using it to test the temperature of shower water, perhaps for an elderly person or child, (where burns are a serious risk and established health issue), you would first turn the taps until the water was the temperature desired. Then rotate VR1 until LED1 lights. Then adjust back until it extinguishes. Whether this is clockwise or anti-clockwise for you depends on which terminals you used on VR1.

OTHER CONFIGURATIONS

It is possible to reverse the operation of this circuit. If the voltage divider formed by VR1/R1 and R2 is connected to the non-inverting input (+) pin 3, and the two 4.7kΩ resistors to the inverting input (-) pin 2, then the LED lights until the temperature is exceeded.

Additionally, it is very interesting to observe what happens when you reverse the positions of VR1 and R1.

That’s all for now, as that’s quite a lot to take in already. Hopefully you can use the example to help you figure out how comparators work using the LM741, and even design your own inputs and task.

IN SUMMARY

While the op-amp can be used in a variety of ways, the comparator is one the maker or hobbyist will use often. The skills you have learned with the LM741 configured as a comparator will transfer to other op-amps as well, albeit with different component values. We will continue to examine the op-amp into the future, although it may not be a continuous series - be ready for a mental break or a different direction to keep things fresh and your mind from wandering!

FOR EDUCATORS:

Voltage Dividers as a Mathematics Engagement Tool

Voltage dividers are an interesting way to engage students interested in science in certain mathematical tasks. Students can calculate what percentage of the voltage drops across each resistor, or what fraction.

Using potentiometers to set known values, younger students could work with whole numbers or easy fractions such as thirds and quarters, rather than relying on standard values. Students can also calculate the ratios of the resistors and the voltages involved.

We have included several examples of how to achieve this on our website at the link above.