# Op-Amp calculation confusion

Discussion in 'General Electronics Chat' started by abuhafss, Jul 8, 2013.

1. ### abuhafss Thread Starter Active Member

Aug 17, 2010
155
2
Hi

I am confused with the calculations for Inverting Amp. Please see the attached files and guide me where I am wrong.

Shall appreciate, if someone provide me correct calculations.

Thanks

File size:
4.6 KB
Views:
53
File size:
15.6 KB
Views:
57
2. ### wayneh Expert

Sep 9, 2010
12,154
3,061
Calculation of what, gain? Look here.

3. ### LvW Active Member

Jun 13, 2013
674
100
Abuhafss, just the first line is false. Why 0.7 Volts?
This is not a simple BJT stage!
At first, leave no node open and be aware that single supply operation requires some special considerations.
It seems that you are not familiar with opamps.
Therefore, read some basic introductions and learn/understand why the gain is simply G=-R2/R1 (assuming open-loop gain Aol infinite).

4. ### WBahn Moderator

Mar 31, 2012
17,777
4,805
Please read the OP's work carefully since, if you don't, it can create a huge amount of confusion for them.

The 0.7V comes from the fact that the problem statement explicitly says:

Problem no. 1: Vi=0.7V Vr=1V

His analysis of the problem, though sloppy and setting him up to make mistakes at some point, is correct.

The non-inverting node of the opamp is at 1V. The input to the circuit is 0.7V. This results in a voltage of Vi=-0.3V across the input resistor (with the polarity assigned such that positive current would flow from input to opamp). The means that a current of I=-0.3V/1.2kΩ=-0.25mA will flow through the feedback resistor from inverting input to output (of course, since the value of the current is negative, the actual current is flowing from output to input). The voltage drop across the feedback resistor will be Vrf=I*Rf=-0.25mA*47kΩ=-11.75V. The voltage at the output will be the voltage at the inverting input minus the voltage drop across the feedback resistor, or Vo=1V-(-11.75V)=12.75V.

To the OP:

The other thing you need to do is to start carrying units throughout your work. Consider the fact that I did so above. If I can be bothered to do it, then you should be able to do it. But tracking your units you will have the ability to check them as you go to make sure they are still consistent. Most mistakes you make will affect your units and allow you to catch and correct mistakes early in your work.

As for why the output voltage didn't follow the canned formula, that is because the canned formula does not apply to this circuit. For this reason, you need to make sure that you truly understand what each of the formulas you use mean, where they came from, and what their limitations are.

Go back and redo your analysis but don't plug in any numbers. Just keep it as Vi, Vr, Ri, Rf, and Vo. What happens if you set Vr=0V?

5. ### LvW Active Member

Jun 13, 2013
674
100
Sorry - I didn`t recognize the first line with the input voltages.
WBahn, Thank you for the correction.

6. ### LvW Active Member

Jun 13, 2013
674
100
Abuhafss, you have made two fundamental errors:
1.) You have applied the inverting gain formula without consideration of the fact that there is also an input voltage at the non-inverting input node;

2.) You have calculated output voltages also for the case that the output goes negative (when Vi exceeds Vr). However, your opamp can go to positive voltages only because you didn`t use split supply (as mentioned in my first reply). This is the reason for the surprising simulation results.

7. ### abuhafss Thread Starter Active Member

Aug 17, 2010
155
2
WBahn

First of all, I am just an electronics hobbyist with a limited background of analog circuits. I had done my calculations on the basis of various tutorials about op amps. Since, my answers does not tally, it is clear that I haven't fully understood the subject. I shall appreciate if you can provide me some suitable tutorial links.

Currently, I am working on a project in which I am using a dual op amp chip.

Supply is 30V single.
One of the two op amps, I am using as integrator.
The other as inverting amp.

Earlier, I used LM393 but the integrator did not worked. Even I replaced the chip but no result. Since the integrator did not worked, I could not check the operation of the inverting amp because the output of the integrator was to be used indirectly as non-inverting input of the inverting amp.

Then I got another chip labeled K..358, maybe some version of LM358. The integrator is working perfectly but the inverting amp is giving odd results.

As discussed in my first post,

Vref = 1V
Vin > 1V
Vo = 0V ........ That is OK.

But when

Vref = 1V
Vin = 0.7V
Vo = 1.4 - 1.5V..............whereas, it should be about 12.7V

I have gone thru all the tutorial stuff I have, to see why the results are incorrect or where I am wrong. The chip is working fine, I have checked it in other circuits. I am really confused, why it isn't working.

8. ### WBahn Moderator

Mar 31, 2012
17,777
4,805
Remember that I said that being sloppy would bite you? Well, in your second problem it bit you.

You got a current of 0.00275A but paid no attention to what direction is was flowing and have no indication that you are aware that it is flowing in the opposite direction of the current in the first problem. You then calculate a voltage drop across the feedback resistor and, again, work with only the magnitude and ignore the polarity. Then, for some reason that makes no sense, you that the output voltage is the voltage drop minus the reference voltage. In fact, it is the reference voltage minus the voltage drop and so you should (supply voltage limitations notwithstanding) have an output of -128.25V. With your answer, you should expect the output to be near 30V, but with the correct answer, you would expect it to be near 0V.

You make the same mistake in Problem #3.

You need to stop being sloppy. It doesn't matter if you are a hobbyist or engineer (well, it does -- if you continue being sloppy you will probably only kill yourself, whereas an engineer that is sloppy can kill people in job lots).

9. ### LvW Active Member

Jun 13, 2013
674
100
Abuhafss, may I give you a small hint regarding the integrator?

You cannot test (hardware) or simulate an opamp (real model) that has a only a capacitor in the feedback path. That means - you cannot operate such a device without a suitable dc feedback loop. This is because the offset voltage will drive the device into saturation (large dc gain). In most cases, an integrator is used as part of a stabilizing overall feedback loop (filters, AGC circuits, control loops, oscillators) - thus avoiding any problems like this. If this is not the case - e.g. for testing purposes - you must connect a relatively large resistor across the capacitor. This resistor limits dc gain and allows operation within the linear range of the opamp.

10. ### WBahn Moderator

Mar 31, 2012
17,777
4,805
I must have missed something. I don't see you saying anything about it being okay that Vo=0V when Vin>Vref. In fact, your pdf file made it pretty clear that there was a huge descrepancy between what you calculated and what the simulator showed.

And this is the first I have seen anything regarding an output of 1.4V to 1.5V instead of something close to 12.7V when you apply Vr=1V and Vin=0.7V.

Which opamp are these with? The LM358 (or what you think is basically a 358)?.

Take a voltmeter and measure the actual voltages at Vi, Vr, Vo, and the inverting input of the opamp. Also, measure the actual resistor values (out of the circuit).

There are non-ideal opamp effects such as input bias and input offset currents and voltages, but I think that the descrepancy you are seeing is well outside those effects. Your resistor current is about two orders of magnitude greater than the input bias currents and the voltage error is nearly that much larger than the input offset voltage.

This is also the first time you've mentioned the actual parts you have been using. The reason why the LM393 wouldn't work is because it is not an opamp. It is an open-collector comparator.

11. ### abuhafss Thread Starter Active Member

Aug 17, 2010
155
2
WBahn

I am sure, I am not sloppy but definitely I didn't the clear idea of the calculations. I have to study them more thoroughly. And as requested earlier, recommendations for good tutorial links shall be appreciated.

Yes, I am using KA358A. Right now, I am bit far from the circuit but I will rush to it and get you the fresh readings.

LvW:
The integrator is generating ramp as expected, though bit slower. Maybe, I need to change the capacitor value but definitely, after getting the inverting amp working.

12. ### LvW Active Member

Jun 13, 2013
674
100
A real opamp as well as a real opamp model (including an input offset) will NOT work as a stand-alone integrator. Either your opamp is an ideal model or the observed ramp is due to integration of the offset voltage - rather than the input.
More than that, I recommend to post a new circuit diagram showing all connected voltages (for a non-working case) including power supply, of course.

13. ### WBahn Moderator

Mar 31, 2012
17,777
4,805
You are more than welcome.

No, you are definitely being sloppy.

As I pointed out earlier, for example, you give absolutely no indication what direction the current is flowing in R1. In your first problem you say that the current through R1 is 0.00025A and in the second problem you say that the current in R1 is 0.00275A. Now, regardless of what direction you have defined the current in R1, can we at least agree that both of these currents have the same sign and, therefore, that they are flowing in the same direction? Yet the first one is a current flowing right-to-left and the second is flowing left-to-right. So one of them should be negative. That's sloppy.

You also don't track your units. That's sloppy. Though, admittedly, it is unfortunately very common and it has gotten people killed and has sent very expensive space probes slamming into other planets instead of entering orbit about them.

Try the E-book on this very site, though I am hesitent to recommend it for this material because it primarily uses electron flow instead of conventional flow and, as far as I'm concerned, uses electron flow incorrectly (but, again, it a way that is very common). So I'm concerned that it may confuse you more than it helps. But at least take a look at it.

Look forward to seeing the data.

14. ### abuhafss Thread Starter Active Member

Aug 17, 2010
155
2
WBahn

Here is the fresh data:

R1 = 1.18K Rf = 46.5K (Both out of circuit)

INITIAL VALUES:
Vin = 4.20 - 4.25V
Voltage at inverting input = 4.05 - 4.10V
Vref = 1.0V
Vo = 0V

FINAL VALUES:
Vin = 735 - 745mV
Voltage at inverting input = 745 - 755mV
Vref = 1.0V
Vo = 1.38 - 1.45V

15. ### LvW Active Member

Jun 13, 2013
674
100
If you read again my post#6 (point 2) you will immediately see what has happened: The opamp output, OF COURSE, cannot go negative for positive single supply!

16. ### abuhafss Thread Starter Active Member

Aug 17, 2010
155
2
Perhaps you misunderstood, I don't want negative output!!!!

INITIAL VALUES:
Vin = 4.2V
Vref = 1.0V
Vo = ZERO V --->>>> That is correct.

Problem is with the final values:
Vin = 0.7V
Vref = 1.0V
Vo = 1.4V -------->>>> This should be around 12.7V

17. ### WBahn Moderator

Mar 31, 2012
17,777
4,805
Could you provide a table of input/output values, say ten, that are roughly evenly spaced between Vo=0V and Vo=30V (or the point at which it saturates)? Take a few additional points near the ends, particularly the low end.

18. ### LvW Active Member

Jun 13, 2013
674
100
OK - I realize that you "don`t want" negative output voltages.
But in this case, you shoudn`t say "That is correct" - because it isn`t.
This was the cause of misunderstanding.
And the question arises: Why did you show us these voltages, which cause latch-up at ground potential?

19. ### abuhafss Thread Starter Active Member

Aug 17, 2010
155
2
I do not have a scope therefore, it might not be possible in the circuit because as I mentioned in my earlier post, the ramp generated by the integrator (the first half of KA358A) is fed into an external voltage cut-out device (VCO) which trips at some preset voltage. The output from the VCO is proportional to the ramp input until it trips. When the ramp reaches the preset value, the output is dropped to 735 - 750mV.

This output from the VCO is fed into the inv. amp (the 2nd half of KA358A). As long as this VCO-output is below the preset value, the output of the inv. amp is 0V. And when VCO-output is dropped to 750mV, the output of the inv. amp should rise to 12.7V (instead of 1.4V).

20. ### abuhafss Thread Starter Active Member

Aug 17, 2010
155
2
I did not provided the values from my mind.
With reference to my above post, I have three points to collect data:

START-UP:
The ramp starts from 5V (Output of the integrator).
VCO-output is 4.2V (Input to the Inv. Amp)
Vref remains constant 1.0V
Vo is ZERO

RAMP:
Output of the integrator 5 - 29V
VCO-output is 0.8V less than 5 - 29V
Vref is 1.0V
Vo is ZERO

END (the ramp reaches the preset value of VCO):
Out of the integrator 15.2V
VCO-output is 735 - 750mV
Vref is 1.0V
Vo is 1.4V (instead of 12.7V)