EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: mcoms on February 12, 2015, 08:13:51 pm

Title: Isolated measuring of voltage/current using an Arduino
Post by: mcoms on February 12, 2015, 08:13:51 pm
Hey all,

I'd like to measure a voltage in the range 0-5V using an Arduino, but, I don't want to tie the ground lines of the two circuits. Is that possible?

Background:
I have a Yaesu FT-857 Amateur Radio transceiver which has an output for an Analogue Moving Coil meter (signal + ground).

The radio will output a current varying between zero and 1 milliamp (0–1mA), depending on the signal strength received by the set. This is intended to drive the coil of an analogue meter. 1mA indicates a very strong incoming signal, values below are weaker stations.

The spec doesn't give a voltage, but I've measured that this varies between zero and five volts (0–5V). It does appear that the voltage also varies with signal strength.  I initially wanted to stick to measuring the current, but some responses to this question on Stack Exchange (http://electronics.stackexchange.com/questions/152195/how-do-you-measure-an-output-designed-for-a-moving-coil-meter-using-an-arduino) point out it's probably a voltage source internally, so measuring either current or voltage should work.

What's the best way to measure/sample this signal, while maintaining electrical isolation, so that I can use the value in an Arduino? The project will eventually be a digital 7-segment signal display.

Thanks!
Title: Re: Isolated measuring of voltage/current using an Arduino
Post by: suicidaleggroll on February 12, 2015, 08:17:23 pm
The simplest way is to sample it with an ADC on the local power supply (same gnd as the source), and then isolate the digital comms between the ADC and the MCU using an opto-isolator or similar.
Title: Re: Isolated measuring of voltage/current using an Arduino
Post by: Seekonk on February 13, 2015, 11:57:41 am
An opto isolator is pretty linear, but your meter circuit is probably floating.   T he opto will have to be driven by a differential input op amp.    There is no reason why you can't just float the uno and directly attach it to the meter.   I've been working with the MINI328 boards that are just the same as the UNO but smaller than two postage stamps and cost less than $3.   These can be used in place of a lot of assemblies.   Third, even if the meter is offset from ground there is no reason why both sides of the meter can't be used as inputs to the uno with appropriate voltage dividers and subtract one from the other to obtain a value.
Title: Re: Isolated measuring of voltage/current using an Arduino
Post by: dannyf on February 13, 2015, 12:35:15 pm
Quote
Is that possible?

You can use high-linearity optocouplers - very expensive and not that great.

Alternatively, do the measurement on the common ground side and use regular optocouplers to transmit the data (digitally).
Title: Re: Isolated measuring of voltage/current using an Arduino
Post by: cosmicray on February 13, 2015, 03:01:01 pm
Depending on how low the current is, you may want to look at something that implements one of the Allegro Hall effect-based linear current sensor chips (ACS709, ACS711, etc). The boards that I've seen are implementing the current flow as an isolated circuit on 2-oz copper pad.

Pololu makes a series of these boards, but keep in mind these boards were designed to operate on a larger current flow. Pay special attention to the warnings/disclaimers on each board as to the upper end operating voltage. The chips themselves are spec'ed for a higher isolation, but Pololu doesn't want you going there unless you really know what you are doing.

https://www.pololu.com/search/compare/118 (https://www.pololu.com/search/compare/118)

Have you measured the voltage between this output jack and the frame ground of the unit ?
Title: Re: Isolated measuring of voltage/current using an Arduino
Post by: PeterFW on February 13, 2015, 03:13:17 pm
Depending on how low the current is, you may want to look at something that implements one of the Allegro Hall effect-based linear current sensor chips (ACS709, ACS711, etc).

Measuring <=1mA current with one of the Allegro devices seems not possible with anny significant resolution. At least it looks like that to me.
I only played with a ACS712 and just had a look at the other ICs, none of them looks suited to this task. They do a good job at higher currents though.
But they reference the output against the supply voltage, to me that is a big PIA.

Greetings,
Peter
Title: Re: Isolated measuring of voltage/current using an Arduino
Post by: cosmicray on February 13, 2015, 03:25:29 pm
Measuring <=1mA current with one of the Allegro devices seems not possible with anny significant resolution. At least it looks like that to me.
Agreed. One of the parts had a rating of 185 mV/A, but that would leave a 1 mA current flow generating a change of less than 1 mV on the output, which would put it down in the noise. Too bad the hall effect sensor requires a minimal amount of current.
Title: Re: Isolated measuring of voltage/current using an Arduino
Post by: mcoms on February 15, 2015, 11:09:24 pm
Thanks everyone!

Did a little more experimenting on this... The ground of the meter output does seem to be common with the radio's ground/chassis and PSU, so sampling on the radio side does seem to be a nice/easy option (and probably the most accurate).

I do have an ACS712 module handy, but unfortunately the current (1mA) does seem too low to reliably measure with it.

For fun, I hooked up a PC817 Photocoupler I had laying around, and ended up with the following:

(https://www.dropbox.com/s/jwlby41vj3p32jl/opto-meter.png?dl=1) (https://www.dropbox.com/s/jwlby41vj3p32jl/opto-meter.png?dl=0)

Surprisingly this does seem to work — the current through the 10K resistor does vary according to the input, and the voltage on the test point [relative to GND] is the inverse of the input.

I can't be sure how linear/accurate this actually is with the cheapo meter I have, but will do a bit more testing.

Does this schematic seem sensible?  How about the choice for the resistor values — giving the varying voltage/current on the meter terminals, I was a bit unsure how to choose R2 to protect the PC817's internal diode.  R1's value was more or less arbitrary...

Cheers!
Title: Re: Isolated measuring of voltage/current using an Arduino
Post by: dannyf on February 15, 2015, 11:23:06 pm
Quote
I can't be sure how linear/accurate this actually is

All in the datasheet - CTR.
Title: Re: Isolated measuring of voltage/current using an Arduino
Post by: Seekonk on February 16, 2015, 09:41:46 am
Have you used the MAP function?  An easy way to convert one unit to another.  Even if the output is non linear it is easy to break up the curve to 2 or 3 sections with an IF and use the MAP on them.
Title: Re: Isolated measuring of voltage/current using an Arduino
Post by: langwadt on February 16, 2015, 02:12:34 pm
Quote
I can't be sure how linear/accurate this actually is

All in the datasheet - CTR.

And can be anything between 50x and 600x depending on which one you get, vary nearly 2x from 1mA to 15mA,
changes as the LED ages. As draw it the LED is driven via a resistor, not with  current source so even more non-linear



Title: Re: Isolated measuring of voltage/current using an Arduino
Post by: Zero999 on February 16, 2015, 03:32:19 pm
Opto-couplers are not linear and their characteristics change over time and at different temperatures so are not suitable without compensation.

An opto-coupler can be used but it needs to be one with a pair of matched photodiodes both coupled to the same LED. One of the photodiodes is then placed inside the feedback loop of an op-amp circuit which compensates for the non-linearities.
http://www.jameco.com/Jameco/Products/ProdDS/1548967.pdf (http://www.jameco.com/Jameco/Products/ProdDS/1548967.pdf)
Title: Re: Isolated measuring of voltage/current using an Arduino
Post by: Seekonk on February 16, 2015, 05:04:58 pm
Anything not worth doing is not worth doing right. It's a S meter.
Title: Re: Isolated measuring of voltage/current using an Arduino
Post by: jamesd168 on February 16, 2015, 07:36:36 pm
Thanks everyone!

Did a little more experimenting on this... The ground of the meter output does seem to be common with the radio's ground/chassis and PSU, so sampl (http://mastechpowersupply.com/variable-dc-power-supply.html)ing on the radio side does seem to be a ni (http://mastechpowersupply.com/variable-dc-power-supply/plating-and-anodizing-rectifiers.html)ce/easy option (and probably the most accurate).

I do have an ACS712 module handy, but unfortunately the current (1mA) does seem too low to reliably measure with it.

For fun, I hooked up a PC817 Photocoupler I had laying around, and ended up with the fol (http://mastechpowersupply.com/linear-power-supply.html)lowing:

(https://www.dropbox.com/s/jwlby41vj3p32jl/opto-meter.png?dl=1) (https://www.dropbox.com/s/jwlby41vj3p32jl/opto-meter.png?dl=0)

Surprisingly this does seem to work — the current through the 10K resistor does vary according to the input, and the voltage on the test point [relative to GND] is the inverse of the input.

I can't be sure how linear/accurate this actually is with the cheapo meter I have, but will do a bit more testing.

Does this schematic seem sensible?  How about the choi (http://mastechpowersupply.com/switching-power-supply.html)ce for the resistor values — giving the varying voltage/current on the meter terminals, I was a bit unsure how to choose R2 to protect the PC817's internal diode.  R1's value was more or less arbitrary...

Cheers!


it will be nice to know the transient aspect of the signal, which will help you decide on the correct parameters for the parts used.
Title: Re: Isolated measuring of voltage/current using an Arduino
Post by: Seekonk on February 17, 2015, 04:08:43 am
As far as linearity, surprised no one has noticed that the opto doesn't start conducting till about 1.3V.  That is 1/4 the meter scale. Suppose you could put a battery in series.

Honestly, the requirement for isolation is absurd.  If the meter floats a few volts above ground it can be read differentially with two A/D inputs with well over 100K input resistance.  This would have far less effect than pulling off a couple ma to drive an opto.