opamp non-inverting gain, wrong in spice sim

Thread Starter

spookydd

Joined Aug 12, 2013
45
I'm making a super simple spice sim with ltspice for a non-inverting opamp with a gain of 10, and the simulation doesn't give the expected results with the resistors values calculated.
For the gain of 10, if the resistor going from in- to ground (R1) is a 10k, then calculations say the feedback resistor (Rfb) should be 90k. Normal, with a gain of 1+Rfb/R1, should be exactly 10.
That is what I tried in sims, and it doesn't set the gain at 10.
To obtain that gain of 10, I tweaked the feedback resistor to get very close to the wanted gain of 10, and that required a feedback resistor value of 95k1625, which obviously isn't quite like the 90k as calculated.
Why? This shouldn't happen. The opamp used in the sim is the TL071, so with the JFET inputs very high impedance, input currents shouldn't cause any noticeable interference in the gain.
Is the sim wrong and it can't get this right? Or I am missing something else?
 

Attachments

eetech00

Joined Jun 8, 2013
3,820
I'm making a super simple spice sim with ltspice for a non-inverting opamp with a gain of 10, and the simulation doesn't give the expected results with the resistors values calculated.
For the gain of 10, if the resistor going from in- to ground (R1) is a 10k, then calculations say the feedback resistor (Rfb) should be 90k. Normal, with a gain of 1+Rfb/R1, should be exactly 10.
That is what I tried in sims, and it doesn't set the gain at 10.
To obtain that gain of 10, I tweaked the feedback resistor to get very close to the wanted gain of 10, and that required a feedback resistor value of 95k1625, which obviously isn't quite like the 90k as calculated.
Why? This shouldn't happen. The opamp used in the sim is the TL071, so with the JFET inputs very high impedance, input currents shouldn't cause any noticeable interference in the gain.
Is the sim wrong and it can't get this right? Or I am missing something else?
Post your .asc file
 

Papabravo

Joined Feb 24, 2006
20,996
One thing I can tell you is that using "Gear" as the integration method will produce less accurate results. Try using "Modified Trap" and see if you like the result better. There are other opamp effects that may contribute to this like "input offset" voltage and "input bias" currents.
 
Last edited:

Thread Starter

spookydd

Joined Aug 12, 2013
45
More than just less than ideal. The difference isn't negligible, especially since I'm trying to use this on a current sensor and need to scale it 10 times exactly.
Anyway, modified trap makes no difference. I left the same "wrong" value for the feedback res and got the exact same result.
Now with the 90k res as calculated, the gain is barely over 9.5, which is far from less than ideal.
Is this due to the simulation getting this wrong? Can the calculated values in real life provide the expected calculated results?
This isn't usable with the calculated values, and obviously the tweaked res value can't be obtained to get the wanted result.
So, what to trust?
 

Attachments

Thread Starter

spookydd

Joined Aug 12, 2013
45
I want my gain properly calibrated at 10. The current sense shunt res gives 200mV full scale, and I need to get 2V from that. The 1.9V just won't cut it. Not close enough, by a long shot.
 

Papabravo

Joined Feb 24, 2006
20,996
All right. So where did you get the TL071 model from?
I tried several models, and they all give different results. They are close, but not exact. This is what I would expect with models that supposedly exhibit the behavior of real parts. Do you possess information to the contrary?

It may be instructive to look at the voltage difference across the inverting and non-inverting inputs. In an ideal device it should be close to zero. In a less than ideal device it will be non-zero.
 
Last edited:

Thread Starter

spookydd

Joined Aug 12, 2013
45
I used the tl071 model from the ltspice library.
but obviously this isn't the most appropriate opamp for the job.
specifically, most of the issue may just be due to that opamp not being well enough suited for single supply use.
I tried the lt1001 and that was even worse.
then I tried the lt1006 and that one was much better, although still a bit wrong, but not too bad. but what's really bad about the lt1006, is its price. No way. gotta find an alternative that won't break the bank
so I've been digging for a model of the lm358. I found one from bordodynov, and I'm hoping his models are good enough.
it does work somewhat better with that lm358, but the resistor values need to go down to get better result.
obviously the choice of opamp makes a world of difference, as long as we get a model that works well enough. remains to be seen how this will actually perform for real, so I will breadboard something real soon
 

eetech00

Joined Jun 8, 2013
3,820
I want my gain properly calibrated at 10. The current sense shunt res gives 200mV full scale, and I need to get 2V from that. The 1.9V just won't cut it. Not close enough, by a long shot.
Then you'll have to use a model that provides offset null pins to remove the output offset voltage.
And dual supplies so the offset adjustment has a negative reference.
 

Papabravo

Joined Feb 24, 2006
20,996
I used the tl071 model from the ltspice library.
but obviously this isn't the most appropriate opamp for the job.
specifically, most of the issue may just be due to that opamp not being well enough suited for single supply use.
I tried the lt1001 and that was even worse.
then I tried the lt1006 and that one was much better, although still a bit wrong, but not too bad. but what's really bad about the lt1006, is its price. No way. gotta find an alternative that won't break the bank
so I've been digging for a model of the lm358. I found one from bordodynov, and I'm hoping his models are good enough.
it does work somewhat better with that lm358, but the resistor values need to go down to get better result.
obviously the choice of opamp makes a world of difference, as long as we get a model that works well enough. remains to be seen how this will actually perform for real, so I will breadboard something real soon
The standard LTspice library does not have a TL071 model. The one I have is from @Bordodynov .
You can understand why neither Linear Technology nor Analog Devices would have any interest in promoting a competitor's parts.
 
Last edited:

Thread Starter

spookydd

Joined Aug 12, 2013
45
I've been running ltspice for many years, and I guess that tl071 model must've been added long ago to the library, and it does show up as part of it, for simplicity.
I don't suppose that model would be bad, but rather it's probably more due to it not being well suited for single rail operation. and dual rail just isn't an option in the design I'm working on.
So I'm investigating alternatives, like the lm358 which doesn't work quite as well as the lt1006, but it surely doesn't carry the heafty price. however, I'm looking into a single opamp instead of the dual lm358. I would prefer not having an unused opamp in it, if I can help it. so I'm trying to find one that works at least as well as the lm358, or perhaps like the lt1006, but as a single opamp, single rail and without a heafty price tag.
and I should have some lm358 on hand soon and I will breadboard something to confirm things and compare with the sims
 

Thread Starter

spookydd

Joined Aug 12, 2013
45
by the way, I'm still running the last available version of ltspice IV, and I didn't like the newer one, so I stuck with the old
 

WBahn

Joined Mar 31, 2012
29,857
I'm making a super simple spice sim with ltspice for a non-inverting opamp with a gain of 10, and the simulation doesn't give the expected results with the resistors values calculated.
For the gain of 10, if the resistor going from in- to ground (R1) is a 10k, then calculations say the feedback resistor (Rfb) should be 90k. Normal, with a gain of 1+Rfb/R1, should be exactly 10.
That is what I tried in sims, and it doesn't set the gain at 10.
To obtain that gain of 10, I tweaked the feedback resistor to get very close to the wanted gain of 10, and that required a feedback resistor value of 95k1625, which obviously isn't quite like the 90k as calculated.
Why? This shouldn't happen. The opamp used in the sim is the TL071, so with the JFET inputs very high impedance, input currents shouldn't cause any noticeable interference in the gain.
Is the sim wrong and it can't get this right? Or I am missing something else?
Look at the data sheet for the part you are using:

https://www.ti.com/lit/ds/symlink/t...TL071%26DCM%3Dyes%26gclsrc%3Dds%26gclsrc%3Dds

The input common mode range only goes down to 1.5 V above the negative supply. So you can't expect good results with an input that is only 0.2 V above the negative supply.
 

WBahn

Joined Mar 31, 2012
29,857
I've been running ltspice for many years, and I guess that tl071 model must've been added long ago to the library, and it does show up as part of it, for simplicity.
I don't suppose that model would be bad, but rather it's probably more due to it not being well suited for single rail operation. and dual rail just isn't an option in the design I'm working on.
Then you need to use a part that is suitable for rail-to-rail operation -- or at least one whose common-mode input range includes the negative rail.

Another alternative is to shift your signals up an order to get them into the specified range for the part you are using. That's going to complicate the circuit, but it's simply unrealistic to expect parts that are operated out of their specified range to behave well.
 

Thread Starter

spookydd

Joined Aug 12, 2013
45
What I'm designing works off a 12V battery, so no negative rail possible.
There is a shunt tied to ground/minus (negative rail?), and I need to read that drop on the shunt and "magnify" it times 10, then it's fed to a PIC, and so the +rail for that opamp is the 5V supply given to the PIC, which derives from the 12V battery.
The TL071/081 won't work for this, but either the LM358 or a similar one with a single opamp preferably should do the trick.
I tried just in case, with the 741, but it's pretty bad too.
I chose a TL071/081 for an other purpose in this design that gets the full battery supply for its top rail, and that worked fine in sims. but I'd like to find one of those single supply type, NOT SMD, rail-to-rail I suppose, similar to the lm358 but with only one opamp in it.
There is no way to shift the reading from the shunt, and I don't want to turn this into a rube goldberg contraption, so there must be a sensible solution. If I can avoid an unused opamp, I would prefer.
I took a look at what TI has, such as the TLV27L and whatever, but it's only SMT, so it's not an option.
So then what is there left?
 

Papabravo

Joined Feb 24, 2006
20,996
I've been running ltspice for many years, and I guess that tl071 model must've been added long ago to the library, and it does show up as part of it, for simplicity.
...
The TL071 model was never added to the library by Linear Technology nor Analog Devices. Why, because they did not make the part and would have little to no information on how to construct or verify a model. Your obstinacy does you no credit.
 

WBahn

Joined Mar 31, 2012
29,857
What I'm designing works off a 12V battery, so no negative rail possible.
There is a shunt tied to ground/minus (negative rail?), and I need to read that drop on the shunt and "magnify" it times 10, then it's fed to a PIC, and so the +rail for that opamp is the 5V supply given to the PIC, which derives from the 12V battery.
The TL071/081 won't work for this, but either the LM358 or a similar one with a single opamp preferably should do the trick.
I tried just in case, with the 741, but it's pretty bad too.
I chose a TL071/081 for an other purpose in this design that gets the full battery supply for its top rail, and that worked fine in sims. but I'd like to find one of those single supply type, NOT SMD, rail-to-rail I suppose, similar to the lm358 but with only one opamp in it.
There is no way to shift the reading from the shunt, and I don't want to turn this into a rube goldberg contraption, so there must be a sensible solution. If I can avoid an unused opamp, I would prefer.
I took a look at what TI has, such as the TLV27L and whatever, but it's only SMT, so it's not an option.
So then what is there left?
The opamp has two rails -- a positive rail and a negative rail. Whatever the negative rail is connected to, that is the negative supply voltage, regardless of what the actual voltage is on it. Remember, the opamp has no idea what the voltages are on its pins relative to some arbitrarily defined 0 V reference, it only knows what the voltages are relative to it's supply pins.

https://www.ti.com/lit/ds/symlink/lm358.pdf?ts=1696847234548

While the LM358 has an input voltage range that includes the negative rail, be aware that if there is much of a load on the output that it will not be able to pull particularly close to rail. So take a careful look at what the lowest output voltage is that you need it to accurately deliver and determine how much load current you can support to achieve that.
 
Top