# Voltage subtractor

I am building a pulse oximeter, and there is a photo diode that is reversed biased by 4.5 volts. When there is a light shining on the diode the voltage changes between .1-.3V. I need to cubtract off the 4.5 volt bias so the change can be multiplied and analyzed. I tried using a basic differential op amp. but it doesn't do a good job of detecting differences in voltage, in fact I don't think it notices at all. I am using an lm324. Do you have any better ideas on how I can achieve this or insight into what may be wrong with it? I have isolated just the differential part and even when i input the two voltages with a .2 v difference it doesn't out put .2 V.

Related Electrical Engineering News on Phys.org
vk6kro
You would probably already be using something like this:

[PLAIN]http://dl.dropbox.com/u/4222062/opamp%20non%20inv%20bias.PNG [Broken]

You would have to make one or both of the 470 ohm resistors variable so that there is about 4.5 volts across the 10 uF capacitor. A 1 K linear pot would be OK.
This would give you a gain of about 10, but you could vary this by changing the 10 K resistor.

The power supply doesn't have to be 12 volts. 9 V would be OK, but the voltage divider shown would take a fairly large current, (9.6 mA) so it would be better if this was not a 9 V battery.

This circuit is non inverting and high input impedance, so it should not affect your photo diode circuit at all.

Last edited by a moderator:

http://www.national.com/ds/LM/LM124.pdf [Broken]

If you look at page 4 it says at 5 volts the Input Common-Mode Voltage range is Vsupply−1.5V, if your voltage is too your op-amp won't work properly and you need to either change your circuit or get a "rail-to-rail" Op-AMP

Last edited by a moderator:

Otherwise we can only guess.

Im using the set up on this page http://www.electronics-tutorials.ws/opamp/opamp_5.html with all the resistors set = to each other. I have tried 100, 500, 1K 10K but i will always get a diference of 1.x v or 2.x v and if i check the voltages going into the v1 and v2 the difference is only 100mv. Could the problem be i am using a dc powersupply to test this circuit? or is there some other reason this circuit isn't working. I have tried several different opamps adjusting the input voltage to match the specifications but none seem to work.

Im using the set up on this page http://www.electronics-tutorials.ws/opamp/opamp_5.html with all the resistors set = to each other. I have tried 100, 500, 1K 10K but i will always get a diference of 1.x v or 2.x v and if i check the voltages going into the v1 and v2 the difference is only 100mv. Could the problem be i am using a dc powersupply to test this circuit? or is there some other reason this circuit isn't working. I have tried several different opamps adjusting the input voltage to match the specifications but none seem to work.

What do you mean by "a difference of 1.x v or 2.x v and if i check the voltages going into the v1 and v2 the difference is only 100mv"?

If all of the resistors are equal to each other, then the differential gain will be approximately = 1 as stated in the document accessed by the link.

For example, if you connect a 1.5 Volt battery between the V1 & V2 inputs (+ to V2), then Vout should be approximately = 1.5 Volt. Or if you reverse it so the + is connected to V1, then Vout = -1.5 Volt approx.

What supply voltages have you connected to the supply pins? I have attached the data sheet of the LM358 as an example.
I suggest you use +5 Volt & -5 Volt ie. +5 Volt to Vcc (pin 8) & -5 Volt to Vee (pin 4).

You can use higher voltages if you wish. eg. +/- 15 Volt, it won't make any difference to the result - unless the amp is overloaded by too much input voltage.

There is no need to change the Op Amp, they should all work.

#### Attachments

• 160.4 KB Views: 126
Last edited:
what im saying is if i put 1.7 into v1 and 1.8 into v2 i get an output of one and some change or 2 and some change. not the .1V difference it should be. I cant figure out why it stops at some random voltage and won't find the difference of the input. I am aware the gain is 1, which is why the output doesn't make sense to me, and i don't know enough about voltage subtractors to know why it's doing that.

i'm also using a 9V battery as a source, so putting in a +- 5 volts isnt doable.

A picture is worth 1000 words. See attachment.

Use two 9 Volt batteries to give you a + 9V & a -9 V supply.

Note that you also need the 100 nF capacitors for stability.

#### Attachments

• 39.9 KB Views: 483
vk6kro
What you actually need is gain, but you have an inconvenient DC bias voltage present.

If you use the circuit in post #2 above, you can get gain as well as get rid of the 4.5 volts of bias voltage.

In the following, you can see the effect of varying the non inverting input.
[PLAIN]http://dl.dropbox.com/u/4222062/Non%20inv%20amp%202.PNG [Broken]

The output will be 4.5 volts for 4.5 volts in, but variations from this 4.5 volts input will be amplified by about 10, so that 4.6 volts in will give 5.5 volts out, giving a gain of 10.

Last edited by a moderator:
The gain is set by the resistor values & there will be virtually no DC common mode voltage with the circuit I posted.

And the common mode rejection will be quite high provided that the resistors are matched, ie. R1 = R2 & R3 = R4.

Use 1% resistors or select on test from several.

vk6kro
i'm also using a 9V battery as a source, so putting in a +- 5 volts isnt doable.

He wants to use a single 9 V battery.

I don't quite get how this works. You say it will give me 5.5 V out? how is 4.5-4.6 * 10=5.5 shouldn't i be seeing an output voltage of 1V? or is the 4.5V subtracted from that 5 since it is inverted?

What you actually need is gain, but you have an inconvenient DC bias voltage present.

If you use the circuit in post #2 above, you can get gain as well as get rid of the 4.5 volts of bias voltage.

In the following, you can see the effect of varying the non inverting input.
[PLAIN]http://dl.dropbox.com/u/4222062/Non%20inv%20amp%202.PNG [Broken]

The output will be 4.5 volts for 4.5 volts in, but variations from this 4.5 volts input will be amplified by about 10, so that 4.6 volts in will give 5.5 volts out, giving a gain of 10.

Last edited by a moderator:
Could I increase the resistors for the voltage divider to reduce that amps running through it? or would that throw off the circuit? Also, what if i used a voltage regulator before the voltage divider, and put a voltage follower after it leading into the voltage divider, would that help to keep that output at a steady 4.5 V or would that just cause complications in the circuit? would putting a voltage follower in between the voltage divider and the opamp also, help to keep that voltage from fluxuating as well? or would all these things mess up that voltage subtractor. I appreciate all the assistance you have provided me, thank you for your help.

You would probably already be using something like this:

[PLAIN]http://dl.dropbox.com/u/4222062/opamp%20non%20inv%20bias.PNG [Broken]

You would have to make one or both of the 470 ohm resistors variable so that there is about 4.5 volts across the 10 uF capacitor. A 1 K linear pot would be OK.
This would give you a gain of about 10, but you could vary this by changing the 10 K resistor.

The power supply doesn't have to be 12 volts. 9 V would be OK, but the voltage divider shown would take a fairly large current, (9.6 mA) so it would be better if this was not a 9 V battery.

This circuit is non inverting and high input impedance, so it should not affect your photo diode circuit at all.

Last edited by a moderator:
what im saying is if i put 1.7 into v1 and 1.8 into v2 i get an output of one and some change or 2 and some change. not the .1V difference it should be. I cant figure out why it stops at some random voltage and won't find the difference of the input. I am aware the gain is 1, which is why the output doesn't make sense to me, and i don't know enough about voltage subtractors to know why it's doing that.
Bob987, can you show us your circuit as it is? I presume the 4.5V across the photodiode is from a voltage divider from the 9V battery. If you are using 4.5V as a bias, why and how do you put 1.7V into v1 and 1.8 into v2?

Sorry, I was just picking two numbers that were .1v apart. i should have said 4.5 and 4.6. I have actually been running the voltage subtractor at the moment off a DC supply, but just using the voltages i would normally see, since i didn't want to drain my battery and it allowed me to change voltages to see if the voltage subtractor worked at all. It seems the voltage subtractor I showed the schematic for works at higher voltage differences just not at .1V. But I will try the schematic in post 2 and see if that works for me.

I still would like to see your circuit. My guess is that you have a voltage divider across the 9V giving you 4.5V. Then from that 4.5V point do you have a resistor leading to the photodiode, reverse biased. Your two inputs would be across the resistor providing 4.5V to one input and the voltage drop across the resistor to the other input. Is this correct?

In the finished circuit, how will you be measuring the voltage? Will you use a voltmeter or an A/D converter and send the reading off the board? If you're using an A/D, depending on what your circuit looks like, I think you might solve a lot of problems if you could ground your board at the 4.5V point of the voltage divider.

I don't have a scanner near me atm. But for my photodiode circuit there is a voltage divider, the 4.5 from that divider feeds into the - terminal of the opamp. from the + terminal there is a resistor going to the output of the opamp, and the photodiode's - terminal is attatched to the + feed of the op amp, the + is grounded. Ya, I am using an A/D converter. the only problem with that idea, is i need to amplify my signal before it goes into the A/D converter, i want that .1V difference to be read around 1V.

Thanks for the info. What is the + side of the photodiode connected to? Could you possibly draw your circuit in Paint with your mouse? It doesn't have to be neat. Then upload it as a bmp.

Thanks

vk6kro
Could I increase the resistors for the voltage divider to reduce that amps running through it? or would that throw off the circuit? Also, what if i used a voltage regulator before the voltage divider, and put a voltage follower after it leading into the voltage divider, would that help to keep that output at a steady 4.5 V or would that just cause complications in the circuit? would putting a voltage follower in between the voltage divider and the opamp also, help to keep that voltage from fluxuating as well? or would all these things mess up that voltage subtractor.

Yes, you can change the voltage divider.
If the variations in voltage from the photodiode are very slow, though, the increased resistance will affect the gain and you may have to make the feedback resistor bigger to suit your application.

The two resistors in the voltage divider appear in parallel with each other and in series with the 1 K in the orange diagram. So, the 1 K in that diagram is really 1.235 K for slow moving voltage changes.
If you made them both 10 K then the 1 K would become 6 K ( 1k + 5 K ) and the gain would drop to just over 1.
What frequency output would you expect from your photodiode?

It is common to use a spare opamp as a voltage follower, as you suggest. You need the voltage to be variable so that you can adjust it to suit your bias voltage.

Possibly, you could arrange a 9 V power supply when you get it going. If you do that, then a few mA wasted won't matter.

The output will be 4.5 + ((input - 4.5) * 10).
So an input of 4.51 volts will give an output of 4.5 + (4.51 - 4.5) * 10 ..... or 4.6 volts.

I don't have a scanner near me atm.
You could draw a diagram with MS Paint or PowerPoint.

Or you could modify one of the drawings that have been posted to show us how your circuit is wired.

Otherwise, we are working in the dark.

So this is the circuit. the 100k resistors in the photodiode circuit are necessary to produce a .1V change when a light shines through the finger onto the diode. I want my v3 to simply be the difference between the output of the photodiode circuit minus the 4.5v bias. So ideally it would be somewhere between 0 when the photodiode is in the dark and 1.5 the rough peak i get out of it. So, I'm not sure how picture 2 helps if it gives me an output of 4.6, wouldn't i then need to put that output into another subtrator circuit? again thank you guys for your assistance.

#### Attachments

• 16.4 KB Views: 451
May I suggest a starter circuit. I think using two 9 volt batteries instead of a voltage divider is better because if you use low value resistors in the voltage divider you will use up more batteries in the long run than if you use two batteries to begin with. If you use high value resistors, you will lose accuracy.

I am assuming that when light shines on the photodiode its resistance drops slightly. I can't readily model that in spice because I don't know what the reverse current through it is. Instead I used a voltage source (V2) to indicate the voltage across the diode. So the more intense the light shining on the photodiode, the more it conducts, the less voltage across it and the higher the output voltage. Is this close to what you wanted?

Also note that by grounding the junction between the two 9V batteries, the output is referenced to ground instead of 4.5V.

Edit: Removed R3 from the schematic.

#### Attachments

• 19.2 KB Views: 332
Last edited:
vk6kro
The first opamp diagram (in your drawing), shows positive feedback and unlimited gain. It could be very unstable like that.
It would be better to have the 100 K resistor coming from the positive supply and a normal feedback resistor going to the inverting input.

The voltage divider here should be bypassed. Otherwise, there is a possibility of both opamps interacting because they share the same voltage divider.

In the previous circuit, (post 11), if you make the voltage divider variable, you will be able to set the output almost wherever you like.

For instance, if the voltage divider voltage is about 4.85 V then the output would be about 1 V which would suit your A to D converter.
This is because the difference in input voltages is 0.35 Volts and this is multiplied by 10 to give 3.5 volts which will subtract from the input 4.5 volts to give about 1 volt.
Because of the limits of the opamp, you may not be able to get an output of less than 1 volt without a dual supply.