Analog voltage - relative to absolute - Page 1
Forum section: electronics / projects

author: Loz Collins
author_rank: Newbie
timestamp: June 25, 2023, 03:26:40 am
content: Hi all, first post so here goes.I'm an industrial electrician so no problems with ohms law / power / wiring / other electrical stuff, but only have a rudimentary knowledge of electronics.I need to convert a pair of DC voltages to a single voltage that is the difference between them, referenced to ground. For example, if one of the outputs is 9V above ground and the other is 11.5V, I need to convert this to a voltage of 2.5V above ground.The source device has two outputs, A and B. They can both vary from 0 to 20V, but output B is never below A. Output B varies from equal to voltage A at its lowest, and 5V above voltage A at its highest. These need to be fed into my proposed circuit to produce a voltage from 0 to 5 volts, referenced to ground. The voltage will then be fed to the second device.Speed and current requirements are very low. The two outputs from the source device can supply 100mA, the second device draws less than 1mA.Highest frequency of change will be in the 2 to 3 Hz range, so I'd like to also limit the rate of change of the output to 10Hz or so to eliminate and spikes or other glitches giving silly short term variations.Accuracy is not critical, 5% is ample. The second device is more concerned with the direction of the change, not the exact differential voltage.I'm assuming I need an op-amp differential amplifier circuit of some description, but no idea what opamp to use or what other components are needed in addition to it.Thanks in advance to anyone that can help us out or point us to a suitable circuit.Loz!

author: Buriedcode
author_rank: Super Contributor
timestamp: June 25, 2023, 04:15:52 am
content: Yup, an opamp as a difference amplifier with 4 resistors. The 5% accuracy requirement means that precision differential amplifiers with built-in matched resistors aren't needed.Specs used to choose an opamp are usually, but not limited to:- Bandwidth - highest frequency of the signal in question, roughly gain x bandwidth (frequencies approaching the limit of the amplifier can't be amplified much etc..).- Input common mode range - how close to the power rails the input can sense.- Output range - how close the output can get to the power rails. "rail-to-rail" rarely means actually very close to the rails unless the current requirements are very low.- Power supply range: Modern CMOS opamps usually have a 5.5-6V limit, JFET and bipolar opamps can go up to 32V ish, sometimes higher.Given the loose requirements I can see why you're a bit overwhelmed, a lot of opamps will fit the bill. But you can narrow it down with the low bandwidth (say <2MHz GBWP required) and the input voltage range being 0-20V - which will marrow it down a far bit.Reallyold opamps like the 741 are meh, the LM358 is a common dual opamp that can sense down to the negative rail (0V if you're powering it with 0 - 30V). Very cheap, and its output canapproachthe negative rail, but only within about 100mV.A dual opamp is handy because if one of your signals can only supply ~1mA then you can buffer that signal with the other opamp to prevent the signal being loaded by the difference amplifier inputs.If you want to buffer both inputs, then a quad opamp like the LM324 is very cheap, similar specs, and available pretty much everywhere.First link on google:https://www.electronics-tutorials.ws/opamp/opamp_5.htmlNote it doesn't show the power connections to the opamp, but if your signals are 0-20V, then a single supply of >24V would be fine (higher than the 20V, since many opamps can only sense inputs about 2V lower than its supply voltage, same goes with outputs). If you really want a nice 0V out when both inputs are the same voltage, then you may need a negative supply for the opamp - just to get the output to be true 0V, rather than getting near. That means instead of using GND/0V, you could have -1 or -2V, but its a hassle if you just have a single supply.

author: ArdWar
author_rank: Frequent Contributor
timestamp: June 25, 2023, 07:03:55 am
content: What supply voltages are available to the circuit? If it has a negative supply (say -5V, GND and 24V), it'll greatly simplify the selection as almost any modern wide-supply OpAmp can fulfill your requirement.If it only got single rail (say 24V and GND), you'll need rail-to-rail (both in and out) OpAmp. Please note that rail-to-rail OpAmp while can get closer, still never quite able to go to exactly zero output. Check first if that's okay for your application.

author: Loz Collins
author_rank: Newbie
timestamp: June 25, 2023, 09:54:00 am
content: The box this is mounted in has a separate power supply: +5V at a few amps, and split +/- 12V rails at a few hundreds of mA.Looking around, it looks doable within that range by using resistors as voltage dividers on the two inputs (say to divide by 4 to keep them well within the +12V positive supply rail) and have the opamp multiply by the same ratio to return it to the original difference ratio. Value of the multiplication is not so critical, as we are mostly looking at the direction the 0-5V output moves, not the exact value. Even a 10% error is not going to be critical here.It's also OK if the output goes slightly below zero volts or slightly above 5V, the second device the voltage is being fed to will ignore it without any damage or other adverse effects.Loz

author: ch_scr
author_rank: Frequent Contributor
timestamp: June 25, 2023, 02:49:25 pm
content: What you want is an "Op-Amp differential amplifier". I've attached an circuit that should work for you, with some practical tips for implementation. V3 / V4 are the inputs, with the values as shown (20V / 15V) it would give 4.975V on the output. Use 1% resistors or better. With the circuit like this, a 10V difference would give a 10V output! If you want to have a 5V output for that case, make R1 / R4 equal to R2 / R3.

author: Loz Collins
author_rank: Newbie
timestamp: June 26, 2023, 12:16:10 pm
content: Many thanks for that, I'll build it in the next few days and see how it goes.One question - how critical is is to use the OP07 opamp, as opposed to a more common type? I have some LM324, LM358, LM833, and TL071 types here. I can order some OP07 if that's critical, but this will throw us back a week or so while they are in the post.Thanks again.Loz!

author: ch_scr
author_rank: Frequent Contributor
timestamp: June 26, 2023, 01:21:33 pm
content: TL071 should be fine. The pinout is the same, so you could switch to OP07 later if need be.

author: Terry Bites
author_rank: Super Contributor
timestamp: June 27, 2023, 03:21:26 pm
content: To accomodate a 20V differential you'd need a positve supply typically >22V for the opamp and for a typical opamp a few volts of negative supply as well if you need it to read zero difference.See opamp max values for power supply and back off somewhat. 36-44v for old school opamps. In an industrial or commercial setting, its vital you protect your circuits from over voltage events. If you can live with a scaled output say 0.1V/V life is lot easier.