Go Down

### Topic: Op-amp subtractor (Read 7922 times)previous topic - next topic

#### Wawa #15
##### Jun 03, 2015, 04:30 amLast Edit: Jun 03, 2015, 04:30 am by Wawa
Thanks for the detailed explanation.
I picked 8k2, because rail2rail out opamps are almost rail2rail.
Leo..

#### raschemmel #16
##### Jun 03, 2015, 07:18 amLast Edit: Jun 03, 2015, 07:37 am by raschemmel
@Archibald,

The circuit you described (SEE ATTACHED)  has the following values:

R1 =18k
R2 = 5k
R3 = 4.7k
R4 = 4.7k
R5 = 8.46k

This results in a voltage divider with an output = 0.217*Vinput (as you stated)

This also results in the -V pin biased midpoint (2.5V).
The amplifier gain is given as:
Vo =  VIN * [1+R5/R4]
=  VIN * [1+8.46k/4.7k]
=  VIN * [1+1.8]
= VIN * [2.8]

Since input voltage divider gain = 0.217,

Overall gain (as you put it)
= 0.217 * 2.8
= 0.6076
which is biased at (or added to) 2.5V (since R3=R4)

Clearly one of us in wrong, (probably me).
If you could explain how you arrived at your conclusion I would appreciate it.

Maybe I am being too simplistic but I just see an input voltage divider [A=0.217] followed by a non-inverting amplifier [A=2.8] biased at 2.5V.
Non-Inverting Amplifer

I have to say the part that confuses me most is this:
Quote
R5 gives the required deviation of 9-14volt by changing the virtual ground (-input).
R5 in Wawa's circuit is the feedback resistor for the amplifier.
Are we talking about the same schematic ?

#### michinyon #17
##### Jun 03, 2015, 07:27 am
Why not just divide the voltage by 3 and feed to an ADC ?  I am having trouble understanding why an op-amp is really beneficial here.

#### Wawa #18
##### Jun 03, 2015, 08:44 amLast Edit: Jun 03, 2015, 08:45 am by Wawa
Why not just divide the voltage by 3 and feed to an ADC ?  I am having trouble understanding why an op-amp is really beneficial here.
Resolution goes down when you use a voltage divider.
A 1:2 divider (so you can measure to 15volts), and only using 1/3 of it (9-14v) drops resolution to ~15mV/digital step, and  ~330 steps.
Fine if you're happy with that.
Using an opamp like this changes resolution to ~5mV/step, and ~1000 steps.
Leo..

#### Wawa #19
##### Jun 03, 2015, 08:56 amLast Edit: Jun 03, 2015, 09:02 am by Wawa
@ raschemmel.

Vo =  VIN * [1+R5/R4]

I think you're forgetting that R3 AND R4 are both attached to a fixed point.
So from a dynamic point of view (opamp output), R3 and R4 are in parallel (2K35).
Leo..

#### Archibald #20
##### Jun 03, 2015, 09:39 am
If the Vcc of the operational amplifier is 14V, it may be important to connect a resistor in series with the Arduino's input to protect it in case the output of the amplifier goes above 5.5V.

Alternatively place a potential divider between amplifier and Arduino's input so 14V from the amplifier gives 5V into the Arduino. It would then be necessary to increase the gain of the amplifier and adjust resistor values to give 0V to 14V swing at the amplifier's output.

#### Wawa #21
##### Jun 03, 2015, 10:14 am
If you look at the diagram, you see that this is a rail2rail output opamp that runs on the 5volt supply of the Ardino.
Input voltage is first scaled down to 2-3volt, and then amplified just enough to use the whole range of Arduino's A/D.
Leo..

#### Archibald #22
##### Jun 03, 2015, 10:32 am
If you look at the diagram, you see that this is a rail2rail output opamp that runs on the 5volt supply of the Ardino.
Input voltage is first scaled down to 2-3volt, and then amplified just enough to use the whole range of Arduino's A/D.
The diagram I was looking at does not show what supply is connected to the operation amplifier.  I was aware of this in the original post:
Q2) I don't have a symmetric power supply (+/- 14v) on my motor, can I put the Vcc- to GND and the Vcc+ to 14v ?

#### raschemmel #23
##### Jun 03, 2015, 03:44 pmLast Edit: Jun 05, 2015, 04:45 am by raschemmel
Quote
I think you're forgetting that R3 AND R4 are both attached to a fixed point.
So from a dynamic point of view (op amp output), R3 and R4 are in parallel (2K35).
I guess I'll have to take your word for why two resistors that are clearly in series should be treated as in parallel. I'm having a little trouble wrapping my head around that. If we use an example for a given input voltage instead of a range, then I can calculate the current through R1 and the balancing current through R5 (since no current goes in either -V or +V inputs) . Since R3 = R4, I think it is safe to assume the current (531uA) is the same through both of those. I will do an example later (have to go to work now) and look at it.

From what I can tell , the amplifier gain appears to be too high. Even for an input of 10V, which, after
the voltage divider , is 2.17 V, times the gain I calculated of 2.8 ( treating R3 & R4 as Series instead of parallel), results in an output that is more than 6V ( not to mention it's biased at 2.5V)

It would be interesting to breadboard this circuit and record the output values using the Min, midpoint, and Max possible input values. I would be surprised if the op amp output was not pegged at the + rail for any input greater than 9V. Is this designed for a single supply op amp. I'll try to find time to do that tonight after work and post the results. If you swap R4 & R5 (making the feedback resistor 4.7k and the input resistor 8.46 k and then change R3 to match R4, then the output for a 9V input would be about 3V and for a 14V input would be about 4.7V. (if you Remove R3, which would seem to only be necessary if the op amp had a +/- supply (FCC, -Vee), which based on the following is not likely to happen:

Quote
Q2) I don't have a symmetric power supply (+/- 14v) on my motor, can I put the Vcc- to GND and the Vcc+ to 14v ?
Quote
Resolution goes down when you use a voltage divider.
A 1:2 divider (so you can measure to 15volts), and only using 1/3 of it (9-14v) drops resolution to ~15mV/digital step, and  ~330 steps. Fine if you're happy with that.
Using an op amp like this changes resolution to ~5mV/step, and ~1000 steps.
Or you could use a  16-bit ADC

BTW,
Is it just me or does anyone else think the post title is a misnomer since the circuit does not SUTRACT V_in-A from V_in-B ?
I found this in the OP's second post:
Quote
Q1) In my circuit, the output will be Vout = (V2 - V1), where V2 = my signal 9v-14v and V1 = my 9v reference. Like that when my signal is at 14v the output will be 5v and when the signal is at 9v my output will be 0v. Is it correct ?
Technically, an op amp Subtractor is a Differential Amplifier.

It would be nice to hear back from the OP about what his results were.

#### Wawa #24
##### Jun 03, 2015, 11:32 pm
I guess I'll have to take your word for why two resistors that are clearly in series should be treated as in parallel.
Imagine a 5volt square wave on the opamp's output.
The left hand side of R5 must have a lower square wave, because R5/R4 is a voltage divider.
But R3's other side is also attached to a fixed point, so the square wave is reduced even more.

You could say R3 and R4 are in series for DC, and parallel for AC signals.
Don't loose any sleep over it...
Leo..

#### Paul__B #25
##### Jun 04, 2015, 12:00 am
I guess I'll have to take your word for why two resistors that are clearly in series should be treated as in parallel. I'm having a little trouble wrapping my head around that.
That was where my original explanation tailed off - at the time, I did not fancy making the inverse calculations of such a parallel combination.

You could say R3 and R4 are in series for DC, and parallel for AC signals.
No, that is not the point.  The said two resistors are in series across the power supply (also the reference voltage).  But when you look at them from the perspective of something else connected to their common point, they are in parallel.

If you have delved into Thévenin network theory, you can see them as a single resistance connected to a virtual voltage point which is a proportion of the supply voltage.  That voltage is given by their ratio, and that resistance is their parallel equivalent.

#### raschemmel #26
##### Jun 04, 2015, 12:27 amLast Edit: Jun 05, 2015, 02:54 am by raschemmel
Thanks for taking the time to explain that.
I think the Thevenin explanation is easier to
grasp.

Op Amp = LT1215
Observations:

With R3 REMOVED, the op amp operates normally as a non-inverting amplifier.
With my resistor values:
R1=17.56k
R2=4.99k
Voltage Divider Gain(A) = 4.99/(4.99+17.56) = 0.221
R3=NOT PRESENT (Can't think of any reason to use it)
R4=4.64k
R5=8.45k

VIN_Max=6.95V = 1.538V at op amp +V input pin (with given resistor values amplifier saturates with Vin >7V)
It seems I was overly optimistic when I said this:
Quote
I would be surprised if the op amp output was not pegged at the + rail for any input greater than 9V
VOut =4.28V   (Vcc= 4.85 and this is not a Rail-to-Rail op amp)
A = Vo/Vi=4.28/1.538=2.78 (calculated gain using actual resistor values
= 2.82)
Calc Gain: 2.82
Actual Gain: 2.78

VinMin=0.123V
Voltage divider Output= 0.028V (Calculated value = 0.027V) @ +V input pin)
Vout = 0.072V
A= Vout/Vin=0.072V/0.028V=2.64 (actual gain lower at small input levels)

Input Voltage  VoltDividerOut  AmplifierOutput
1.016 V                 0.224 V               0.625 V
2.015 V                 0.447 V               1.259 V
2.998 V                 0.663 V               1.867 V

Amplifer Resistors changed to allow Vin range of 9V to 14V
R4=7.35 k
R5 = 2.7k

Calc Gain=> A= (1+ R5/R4) = (1+ 2.7k/7.35k)=(1+ 0.369) = 1.367
Input Voltage  VoltDividerOut  AmplifierOutput
8.93 V (x 0.221)   =1.977 V                 2.698 V
13.95 V (x 0.221) = 3.088 V                4.21 V

Measured (actual) Gain
A=Vout/Vin=2.698/1.977 = 1.364 (Calculated = 1.367)
A=Vout/Vin=4.21  /3.088 = 1.363 (Calculated = 1.367)

Maybe I'll breadboard the differential amplifier (classic subtractor)  next.

#### raschemmel #27
##### Jun 04, 2015, 09:30 pm
Quote
You don't need a 9V reference.  You don't need the op-amp to be powered from 15V.

Let's start with a rail-to-rail op-amp operating at 5V, and a 5V reference.  (This has the great advantage that there is no way it can feed an excess voltage into the Arduino )  OK, let's divide the input voltage by three with a voltage divider - let's say a 22k resistor to ground and a 47k resistor to your voltage to be measured (assuming that connecting a 69k load to that voltage will not cause problems).  This voltage divider feeds the "+" input of your op-amp.

To cause the output of the op-amp to mirror the input, you connect the same divider between the op-amp output and the "-" input (that is, 47k from output to "-", 22k from "-" to ground).  The op-amp will now keep its output at the same voltage as the input to the circuit.

But you want an offset.  OK, let's not connect the 22k that is part of the voltage divider at the "-" input of the op-amp to ground, let's instead connect it to, say, 4.2V.

Now when your input voltage is 9V, there will be 2.87V on the "+" input of the op-amp and in order for the "-" input of the op-amp to be the same voltage, it will have to pull its output to ground - which is where you desire it to be when you have 9V on the input.

On the other hand, when you have 14V on the input, the "+" input to the op-amp will be at 4.46V and to match the "-" input, the op-amp will have to output 5V - again, exactly what you want!

The only remaining problem is deriving that 4.2V reference.  To do this you replace the 22k resistor to the op-amp "-" input with two resistors, one to ground and one to your 5V (or any other) reference such that their parallel resistance is 22k.  I leave you to figure out that calculation!
@Paul,
Is this what you meant ?
(see attached)

#### Wawa #28
##### Jun 04, 2015, 10:28 pm
R3=NOT PRESENT (Can't think of any reason to use it)
?? Don't quite follow all of this.

R3 is a key part.
It lowers opamp gain AND it adds DC offset.
Leo..

#### raschemmel #29
##### Jun 04, 2015, 11:01 pm
Quote
R3 is a key part.
It lowers opamp gain AND it adds DC offset.
Alright. I'll try it and see what happens.

Go Up