# Function of inverting op-amp

#### KKAMIN

Joined Sep 23, 2017
13
Hello all,

I have a linear displacement sensor that outputs voltages from -10v to +10v based on displacement of millimeters. My goal is to invert the -10V to +10v, and any time the sensor outputs a positive voltage, just curb it to 0v / GND. The inverted signal then will be read by an arduino.

To do this I've designed a normal simple inverting op-amp circuit with a gain of -1, but I'm not getting the results I'm hoping for on the output voltage. This is the circuit with corresponding pin out for the op amp IC, an NTE 928M.(Ignore the TL081 marking). In simulation, it operates as I would expect.

I'm finding that no inversion is going on, nor is the value output corresponding to the input and I'm not sure why. If I remove the resistors entirely, I would expect to get inverted output but essentially only be at 10V due to the gain of the op amp. When doing this, I still get no inversion and the output voltage is still allowed to go negative when I'm reading it with my multi-meter.

I considered the function of the op amp might be bad but I've tried with two separate amps and am having the same result. Is the concept I'm trying to do applicable to an op amp? Maybe this isn't the best topology for what I'm trying to accomplish.

Am I understanding the fundamentals of the op amp correctly?

#### Attachments

• 19.8 KB Views: 9
Last edited:

#### wayneh

Joined Sep 9, 2010
17,476
As I understand your drawing, you are feeding the amp negative voltages below the lower power rail of the amp? No can do.

#### KKAMIN

Joined Sep 23, 2017
13
As I understand your drawing, you are feeding the amp negative voltages below the lower power rail of the amp? No can do.
That's what I was hoping to do yeah.

So if I don't have a means to produce a -12V source for the lower rail, what is the best strategy going forward where I can convert the voltage?

#### AlbertHall

Joined Jun 4, 2014
12,293
The circuit looks good to me. -10V input should produce +10V at the output.
Also you say that it works correctly in the simulator.
It would seem you have connected incorrectly, maybe you could post some pictures so we can see if we can see anything wrong.

#### AlbertHall

Joined Jun 4, 2014
12,293
That's what I was hoping to do yeah.

So if I don't have a means to produce a -12V source for the lower rail, what is the best strategy going forward where I can convert the voltage?
Because of the two 100k resistors the -10V will not get to the IC pin - it will be at zero.

#### AlbertHall

Joined Jun 4, 2014
12,293
Just looked up the data on the NTE928M and the only problem I can see is that it might struggle to get to 10V output with a 12V supply but it should at least get close.

#### ericgibbs

Joined Jan 29, 2010
18,283
hi KK,
This is what LTSpice shows. OK
E

#### Attachments

• 29.5 KB Views: 15

#### AnalogKid

Joined Aug 1, 2013
10,800
As I understand your drawing, you are feeding the amp negative voltages below the lower power rail of the amp
Not exactly. As long as the output is not saturated and the feedback loop is closed, the inputs are within the common mode voltage range on the datasheet. For example, if V2 is -8 V, then the output is +8 V (ish) and pin 2 is a few millivolts below GND.

Be sure to add decoupling capacitors near the opamp power pins. Simulations don't care, but the real world does.

KK - What are the actual input/output voltages?

ak

#### wayneh

Joined Sep 9, 2010
17,476
Not exactly. As long as the output is not saturated and the feedback loop is closed, the inputs are within the common mode voltage range on the datasheet. For example, if V2 is -8 V, then the output is +8 V (ish) and pin 2 is a few millivolts below GND.

Be sure to add decoupling capacitors near the opamp power pins. Simulations don't care, but the real world does.

KK - What are the actual input/output voltages?

ak
I knew I responded too quickly. It seems like about 90% of the opamp problems we see here are out-of-range and I assumed this was another one without really looking at it much. My bad.

#### ebp

Joined Feb 8, 2018
2,332
The amp in question may actually be an LM358. As far as I know, NTE just puts their house number on standard parts and actually manufactures nothing.

If the output is actually swinging negative there is something wrong with the power to the amplifier, probably a misconnection on a breadboard. Probe the amp right at the pins, not at adjacent holes in the breadboard. Probe all used I/O pins, pin 8 and pin 4. A power supply problem is also consistent with failure to invert, since the input signal simply appears at the output via the input and feedback resistors. [EDIT] Another possibility is that the amp has been damaged such that neither input nor output load the signal - possible, but unlikely.

The output will not be able to go fully to zero under any circumstances and the higher the (positive) input voltage the worse it will get, since the output must try to sink the current from the input. A pull-down resistor on the output will help with that problem, but also impair the positive swing. However, since the input of the Arduino won't be able to handle 10 V, taking a gain of -0.5 is probably the most sensible thing to do anyway, removing any need to swing to the positive rail, assuming the 10 V supply is used. No real amplifier will perform well at the limits if the output must swing fully from 0 V to 5 V and it runs on a 5 V supply. A good rail to rail amp will get close, but not actually to either rail without pull-up or pull-down loading, which helps one way and compromises the other.

#### KKAMIN

Joined Sep 23, 2017
13
Below are some pictures I've taken to maybe clarify some of the issues here. I've removed the resistors entirely to avoid anything being more complicated than it needs to be, and then I'll build from there.

Given there are no resistors, my expectation (albeit not necessarily correct), is the voltage to the inverting input (pin 2) should just invert the voltage linearly. As I'm typing this I'm not certain that's the case, rather the gain might just amplify to the highest rail voltage capable. Regardless, there should be at least some inversion which I am not seeing.

1 - +12V Power supply
2 - GND from sensor controller
3 - GND from 12v power supply
4 - Multi-meter probe 0V
5 - Multi-meter probe +
(In this configuration I'm getting -6.05v from the analog out, and reading -0.7v on the multi-meter.)

Input voltage to op amp is -9.09, reading -1.06.

Adjust sensor displacement doesn't change the reading on the multi-meter. Also of note there is no inversion of voltage polarity.

Above: Taking the op amp out and hooking the multi-meter up directly yields voltages corresponding to the Vout of the analog output.

I'm taking into consideration that the analog signal out might have some issues. The rear of the analog out has ports for +, -, and GND. I'm currently hooked up to + and GND, rather than + and -. I don't see why this would complicate things, but it's more information.

As far as the idea to change the gain to -0.5, I prefer the idea instead of inverting and then clamping with a zener, so thank you for that.

Last edited:

#### ebp

Joined Feb 8, 2018
2,332
You cannot apply a voltage to the inverting input and use no feedback resistor. It turns the circuit into a voltage comparator that will make the output swing to the positive supply for a negative input of a few millivolts and to the negative supply for a positive input ot a few millivolts. The only reason I say millivolts is because the "input offset voltage" makes the actual behavior unpredictable. In reality, there will be a voltage level somewhere within a few millivolts of zero where an input voltage change of a fraction of a millivolt will cause the output to switch. However, even this depends on the amplifier and it may not cope with signals below or even a little above "ground" when operated with a single supply.

You must use both resistors. If the input resistor is omitted, the input signal must be a current, not a voltage. The current must be very small.

You have probably destroyed the amplifier by trying to operate it without the input resistor.

#### KKAMIN

Joined Sep 23, 2017
13
Hmm. I initially had been using the resistors up until the photo I took in which I took them out to simplify it, but had been getting the similar results. To be 100% sure, I've got another op-amp that hasn't left the package yet, so I'll rewire it accordingly to rule out any ruining of the op amp.

Thanks for the input

#### ebp

Joined Feb 8, 2018
2,332
Before you go any further, please post a schematic of the way you intend to actually build the circuit. As long as you are using resistors of at least 10k or so (so the maximum current from the signal would be a miliamp or less), you are unlikely to do damage unless you hook up the power supply in the wrong polarity.

One thing to watch out for on plug-in breadboards: Sometimes a pin of a IC will get bent up under the body of the IC instead of going into a hole. It can be hard to see this.

Here's what to expect for voltages with the original circuit arrangement:

[EDITED to fix sloppy description]
For any signal voltage from -7 to around -0.2, the voltage at the non-inverting input should be zero and at the inverting input within a few millivolts of zero. This might hold up with the signal a bit more negative than -7 and/or a bit more positive than -0.2, but it is hard to predict with the limited datasheet for the amplifier.
For any signal voltage that is positive with respect to ground, pin 2 will be at around half of the signal voltage. Pin 1 will likely be within a few tens of millivolts of zero, rising a little bit as the signal voltage becomes more positive. The amplifier has lost control under these circumstances and is simply trying to make the output voltage as low as possible.

Last edited:

#### AnalogKid

Joined Aug 1, 2013
10,800
Given there are no resistors, my expectation (albeit not necessarily correct), is the voltage to the inverting input (pin 2) should just invert the voltage linearly.
Ummm ... no.
OK, *technically* yes, but good luck with that.

According to the datasheet, the open loop gain is approx. 100 V/mV. That's 100 volts per millivolt, or a gain of 100,000. So, as the difference between the two inputs goes from 0.000000 V to 0.000030 V (30 microvolts), the output will go from 0.00 V to 3.00 V.

Without a negative feedback loop, the device is running "open loop", and acts as a comparator rather than a linear amplifier.

ak

#### KKAMIN

Joined Sep 23, 2017
13
So I went out and picked up an entirely new op-amp. Wired it for a -1 gain. No problems whatsoever. I must have fried the other two op amps I was using at some point without realizing that I was doing it. The signals now put through a 16 bit ADC and zener to an arduino to readout the voltage. I went with the zener option rather than the -0.5 gain on the amp because of the error in tolerances of the resistors giving me some readouts that were slightly off. Works like a charm!

Thank you for all the insight on this one, it was a big help

#### ebp

Joined Feb 8, 2018
2,332
Beware of zeners. 5 volt devices are "true" zener diodes (above something around 6 V they are actually "avalanche" diodes that work by a different mechanism, but everyone calls them zeners anyway) which will begin to conduct significant current well below nominal voltage. This usually makes them unsuitable for clamping precision signals unless there is substantial voltage margin between "full scale" and the clamping voltage, e.g. full scale is perhaps 3-4 V and clamping limit is 5 V.

Managing errors at 16 bits is far from easy.

Resistor tolerance is always a problem in precision circuits. Selecting fixed resistors that don't make a total mess of your 16 bit resolution system is difficult and expensive. 0.1% (1 least significant bit in 10 bits) tolerance surface mount resistors are readily available and quite cheap. Unfortunately, the cheap ones also have a typical temperature coefficient of resistance of ±25 ppm/°C. To get good ones with ±10 ppm/°C or better you can be in the range of a dollar per resistor in small quantities. Very high precision and stability can get you into the \$5+ range very easily.

The op amp you are experimenting with has a maximum input offset voltage error of ±7 mV. That is about ±92 counts for 16 bit resolution at 5 V full-scale. The typical performance is ±2 mV, for about 26 counts.

Tempco really should be expressed with kelvins as the denominator (e.g. ±10 ppm/K) but degrees Celsius is commonly found in spec's.

#### KKAMIN

Joined Sep 23, 2017
13
The op amp you are experimenting with has a maximum input offset voltage error of ±7 mV. That is about ±92 counts for 16 bit resolution at 5 V full-scale. The typical performance is ±2 mV, for about 26 counts.
Could this have something to do with the fact that as I'm approaching 5V, the output voltage begins to stray a bit from the reading?

i.e. In my case at around 4.67V, my readings will start to deviate (which is ok for my case, I'm only interested in the 0-3V range for this situation) and ultimately wind up as 4.80 when the output should be reading 5V. I tested out different resistors to the zener circuit and this was the best approximation I could get to at this range for the 5V zener I'm using.

#### ebp

Joined Feb 8, 2018
2,332
I don't know how the zener clamp is configured, but it would be the first thing I would suspect at the high voltages.

Input offset voltage affects the output under all circumstances, but it shows up mostly at low input voltage. In an ideal op amp, the voltage between the inverting and non-inverting inputs is zero. The whole function of an op amp circuit revolves around maintaining that voltage at zero - a "virtual short circuit" between the two inputs. In real op amps, there is always a little bit of difference between the two inputs. Some of this is due to finite gain - you have to have a little difference to make the output "move" at all, but that error is usually pretty small in most applications (a concern in high precision circuits). The bigger difference in most op amps is the "offset voltage" which is due to imperfect matching of parts of the internal circuitry. Input offset voltage acts as if it were a small, more or less fixed voltage in series with one of the inputs. For example, in the amp you are using, the "typical" figure of ±2 mV would mean that when the non-inverting input is at exactly 0 V and the circuit is operating as a normal inverting amp, the output voltage will be
-(Vin + 2 mV) x gain OR -(Vin - 2mV) x gain
The offset can be either positive or negative. In a dual amp like you are using it might be positive for one of the amps and negative for the other.
The maximum input offset voltage for that amp is ±7 mV, which is fairly big error.
With higher performance amplifiers you can get offset voltages well under a millivolt, but the amp will be more expensive. There are types that have input offset voltages in the tens of microvolts range, usually accomplished with a fairly elaborate internal circuit that continuously automatically adjusts the offset to reduce it.

I have to go do something for a bit. If no one else does it before I get back, I'll link to some free info at Texas Instruments and other amp manufacturers that discusses sources of error in op amp circuits.