# Measuring voltage/current digitally on two separate power supply rails

I'm designing a dual-rail DC power supply, with the two rails completely separate (except for sharing a dual-secondary transformer). The main design should work as-is, only by adding a fuse + mains switch, but I want to add a voltmeter and ammeter to each output (and preferably a voltmeter before the voltage regulators, too).
The problem here is that the "meters" will be a microcontroller's ADC inputs (or external ADCs), and the microcontroller only shares ground with ONE of the two rails. I need some way to safely connect the µC to both rails, perhaps opto-isolation or somesuch, while keeping the rails separate.

Don't look too closely at the exact schematic (below), though, as it isn't 100% correct: I couldn't find a dual-secondary transformer in MultiSim; the LM317 package is incorrect and the µC will be AVR-based.
This is just to give the general picture.

Now, the problem: I want to measure output voltage and output current for both rails, from the shared microcontroller, which is powered by one of the two rails.
It would also be great to have a voltage probe just before the LM317s as well; that way, I can both monitor the input voltage, and also calculate and display the approximate LM317 heat dissipation.

The voltage measurement would be easy, if it weren't for the floating rails... A voltage divider, perhaps followed by an opamp voltage follower to take care of any impedance troubles, connected to an analog input on the µC.

As for current, I'm not quite sure. An opamp would surely be needed to amplify the tiny voltage across the 68 mOhm shunts (68 µV - 102 mV for 1 mA - 1.5 A), but I'm not sure how to wire it up, since neither side of the shunt is ground. There's also the issue of offset voltage, not to mention the galvanic isolation issue.

Priorities are simplicity and cost, though needless to say some accuracy is also needed. It would be great to have 10 mV / 1 mA resolution, though something like 25 mV / 5 mA might be OK too.

Any advice on how to solve this? I'm unsure about much of it. I've considered external ADCs (shunt -> opamp -> ADC -> optoisolator -> µC), or shunt -> opamp -> optoisolator -> µC, but that doesn't appear to be a good idea since the optoisolator might muck with the analog reading. Frankly, I don't quite know what I'm doing (though I do feel safe about my knowledge about the PSU in itself), but I'm certainly willing to read up a little to learn.

EDIT: related to a previous question "Dual polarity vs dual rail power supply"

• Doesn't solve the isolation issue, but see this Maxim app note for concepts (or chip choices) on how to measure the voltage across the shunt resistor: maxim-ic.com/app-notes/index.mvp/id/746 – The Photon Feb 16 '12 at 17:07

In addition to stevenh's answer, I'd like to suggest 2 more alternatives:

1. You can have a separate ADC in each of the floating channels. The ADCs would be linked to the PIC through serial bus (such as SPI). The bus goes to the floating channel through digital optocouplers, which are cheaper than analog optocouplers. Once you have an ADC inside the channel, you can make as many measurements as the ADC has got channels without needing additional optocouplers. This approach was already mentioned in kenny's comment.
2. Each channel could have a dedicated PIC. Each channel with its PIC (and its display, if there are displays) would all float together, and independently of the other channel. You wouldn't need to install a an analog optocoupler for each signal you want to measure. Furthermore, the PICs could talk to each-other through serial link (UART for example). The serial link would go through digital optocouplers.
• I haven't implemented this yet, but unless something changes, I've decided to go with the separate ADC + digital isolator route. 12-bit ADCs are pretty cheap, as are the 150 Mbps(!) isolators which simply take 5 V in and give 5 V out, no extra components needed. They're also available in 3/1 channel versions, which fits SPI like a glove. – exscape Feb 28 '12 at 14:18

The optoisolator -> $\mu$C is a viable path if you pick the right optoisolator. The IL300 is an analog optocoupler which, thanks to a servo mechanism, achieves a 0.01% servo linearity.

• +1 another option is to put a serial ADC on the hot side and opto the serial lines which might be lower cost. – kenny Feb 16 '12 at 17:00
• @kenny - In my solution you can use the on-chip ADC of the $\mu$C; you won't need an external one. – stevenvh Feb 16 '12 at 17:05
• A nice product. – Russell McMahon Feb 16 '12 at 17:11
• Hmm nice, but it appears rather complex - three ICs (IL300 + 2 opamps?) for the current measurement, not to mention the coupling for the voltage. Also, I'm a bit uncertain, but does this really use the full 0-5 V range? My understanding is that the max voltage is the LEDs forward voltage, but that might be wrong. – exscape Feb 16 '12 at 19:04
• @exscape - The second opamp is just a voltage follower, so you may not need it if your impedance is high. The LED's voltage has nothing to do with it, the opamp will pump as much current through it as is needed to make the voltage over R1 equal to the input voltage. – stevenvh Feb 17 '12 at 7:14

Along the line of stevenh's answer, another choice is an isolation amplifier, like the HCPL-7840-000E. It is a little more expensive at around \$6, but I think you would end up with fewer parts since you wouldn't need the extra op amps. It is available in a 8-DIP package, The input and output sides are designed to be powered off of separate supplies. It is designed to measure small voltages, so you would need a voltage divider for measuring the output voltage of the PSU.