Author Topic: Suggestions for a simple SAFE opto-isolated 230VAC voltage measurement circuit  (Read 9634 times)

0 Members and 1 Guest are viewing this topic.

Offline bsodmikeTopic starter

  • Regular Contributor
  • *
  • Posts: 225
  • Country: lk
Hi all,

This topic will make most eyes-roll, but hear me out please.
I want to be able to measure mains-AC voltage safely.  This means, not looking at the cheap options on Aliexpress.

I found this great Hackaday article detailing an opto-isolated solution with a LM331. Full details can be read here.

This has an input limit of 1V - 5V and reconstructs this as a frequency from 1 - 5kHz.

One of the comments mention:

Quote
This is quite an old-school approach – technology is starting move in a different direction. They are not very cheap (unless you are buying by the million) but you are starting to see isolated ADC chips appearing – ADC plus isolation built in – this is being driven by the energy metering market – this will give 14 to 16 bits ENOB with a couple of kV of isolation. Also now that there are digital isolators with built in isolated DC-DC converters you can stick a nice ADC and perhaps a micro to perform scaling and compensation on the isolated side. Cost is getting to be competitive with a discrete analogue approach.

All I'm looking for is a nice ADC with isolation, of course, I have no issues adding opto-isolation myself (here's an example of a simple option) say onto the I2C lines.

Have you come across a more recent IC that can be used for this purpose or do you have a better suggestion, keeping that Simple(r) is always better, in mind!

Ultimately, 230V mains input will be fed to MCU (Arduino/ESP32 etc) and I want to make this 100% safe (including ground potential lightning strikes etc).

Thanks!
Cheers M.
« Last Edit: June 25, 2021, 08:38:11 am by bsodmike »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12856
First you need to specify *WHAT* you need to measure e.g. mains input RMS voltage, peak voltage, frequency or waveform, and to what accuracy.   Then you need to specify how many KV isolation you require.    There's no such thing as 100% safety.

Hint: If you really want to prevent lightning strikes jumping the isolation barrier, the question isn't how many KV of isolation is required, as the strike has hundreds of MV driving it, but how many meters of creepage and clearance distance the isolation light path requires.   Look at fiber optic data links!
« Last Edit: June 25, 2021, 09:19:13 am by Ian.M »
 

Offline bsodmikeTopic starter

  • Regular Contributor
  • *
  • Posts: 225
  • Country: lk
Considering the LM331 approach, where the input range is 1V - 5V.  We would need to pass mains 230VAC through an isolation transformer for galvanic protection (preferred!), then rectify this to DC.

Vpeak=√2Vrms --> Hence, 230VAC ~= 325VAC(pk-pk)

Typical circuits used a 30uF 400V Electrolytic cap on the smoothing end of a FWBR.  So we can expect ~320VDC.  This now needs to be passed through a voltage divider, where we map 320VDC to a set frequency. Let's use 5V as the upper limit.  R1= 630kOhm and R2=10kOhm, will output 5VDC.

On the 5VDC line, it also helps to add a series current limiting resistor of say 5kOhm with a current limit of 5mW (1mA).

On the input end:
  • install a fast-blow fuse
  • install a in-rush current limiter
  • Any other safety options, X2 caps?
  • Common-mode chokes?

Are there any further considerations to be made re. resistor choices if one were to take this approach?
 

Offline bsodmikeTopic starter

  • Regular Contributor
  • *
  • Posts: 225
  • Country: lk
Hi Ian,

To start off, I was thinking of just measuring mains RMS voltage (230VAC), but you've mentioned a few nice to have options too, so lets go with:

  • Mains Vrms (230VAC)
  • Main Vpk-pk (320VAC)
  • Mains frequency
  • Accuracy (Voltage): 0.01VAC
  • Accuracy (Frequency): 0.01Hz
  • Isolation: typical 4000 KV is fine
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19514
  • Country: gb
  • 0999
You could have two circuits: one connected to the mains, via a non-isolated supply, which measures the voltage directly, digitises it and transmits it over an optical, or RF link, to a battery powered receiver.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12856
....  We would need to pass mains 230VAC through an isolation transformer for galvanic protection (preferred!), then rectify this to DC. ....

If you are going to use transformer isolation anyway, you don't need optoisolation  Simply use a precision potential divider network to reduce the signal voltage to a convenient amplitude for your measurement circuit.

Hi Ian,

To start off, I was thinking of just measuring mains RMS voltage (230VAC), but you've mentioned a few nice to have options too, so lets go with:

  • Mains Vrms (230VAC)
  • Main Vpk-pk (320VAC)
  • Mains frequency
  • Accuracy (Voltage): 0.01VAC
  • Accuracy (Frequency): 0.01Hz
  • Isolation: typical 4000 KV is fine
Your accuracy spec is likely to be difficult and expensive to achieve.  You'll need better than 0.01% resistors, a high quality 16 bit or better ADC and careful calibration.   Don't make the mistake of confusing accuracy and resolution . . .
« Last Edit: June 25, 2021, 11:59:11 pm by Ian.M »
 

Offline penfold

  • Frequent Contributor
  • **
  • Posts: 675
  • Country: gb
How do you intend to measure the RMS? Just mentioning because for that level of "accuracy" the crest factor of the mains waveform won't be sufficiently close to sqrt(2). To get a good level of accuracy, you would need to measure the 50Hz + harmonics up to maybe 1kHz?... depends on how distorted your local supply is (could be quite clean at the entry to the building but can get quite horrible in a large building with lots of equipment of varying spec). If you really do need to chase any real level of precision, it would be worth getting some preliminary indication of the level of distortion (DSO plus isolated probe should get close enough to judge the frequency response you'll need)
 

Offline uer166

  • Frequent Contributor
  • **
  • Posts: 890
  • Country: us
A simple potential divider to PE/GND is just as safe as a galvanically isolated option. Simply attenuate both L1 and N (or L1 and L2 if split phase) to GND via 1.6Meg resistor, feed all that to a bipolar input ADC, and voila. No isolation bs and just as safe. This will pass a 5kV hipot test, as long as you rate your divider to appropriate power.

You really haven't defined what you mean by "safe" though so it's hard to give solid advice.
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 26906
  • Country: nl
    • NCT Developments
The solution from eur166 is a good one.

In a circuit where I also wanted to measure the current I have used an I2C isolator from Analog Devices and an I2C ADC + voltage divider & current sensor which where powered using a certified DC-DC converter. Still achieving 16 bits of accuracy won't be easy!
« Last Edit: June 26, 2021, 01:13:10 am by nctnico »
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline bdunham7

  • Super Contributor
  • ***
  • Posts: 7842
  • Country: us
Your accuracy spec is likely to be difficult and expensive to achieve...

I'll say.  Unless I've miscalculated, the HPAK 3458A has a specified uncertainty of 0.112V at 230VAC 50Hz, and that is using its most accurate synchronous digital sampllng mode.  So the OP is wanting a device 10X better than that.
A 3.5 digit 4.5 digit 5 digit 5.5 digit 6.5 digit 7.5 digit DMM is good enough for most people.
 

Offline bsodmikeTopic starter

  • Regular Contributor
  • *
  • Posts: 225
  • Country: lk
This sounds interesting. OK let’s assume we reduce the accuracy to 0.1VAC.

@nctnico do you have any schematics/parts chosen to share? I’m keen to get this setup on some perf-board and test it.

@uer166: by safety, a 4K hipot test is sufficient between the high AC and ADC side.
Reducing the ADC to 12-14 bits accuracy is fine too.
 

Offline bsodmikeTopic starter

  • Regular Contributor
  • *
  • Posts: 225
  • Country: lk
See attached. Any recommendation for power ratings on the 4x resistors?

In terms of PCB layout there will be ample clearance and creepage distance between the HV and low side.
Chosen IC is just an example I found online. Feel free to suggest other bipolar to unidirectional ADCs.

Any suggestions for AC power monitoring?
I.e. RMS current draw
kWh Energy tracking
(Optional) Power factor

Thanks!!
 

Online fchk

  • Regular Contributor
  • *
  • Posts: 244
  • Country: de
Look here:

https://d3uzseaevmutz1.cloudfront.net/pubs/proDatasheet/CS5490_F3.pdf

Digikey has stock.

You need to opto-isolate an UART. You can use Optocouplers, digital isolators, TOSLINK cables...

Big Plus: This chip doesn't only measure voltage but also current and power (real/reactive/apparent), and real(active) power is what you pay for. That is what you really want.
 
The following users thanked this post: bsodmike

Offline bsodmikeTopic starter

  • Regular Contributor
  • *
  • Posts: 225
  • Country: lk
Thanks! That’s exactly what I’m looking for. Now to see if I can source a few chips.  :-DD
 

Offline bsodmikeTopic starter

  • Regular Contributor
  • *
  • Posts: 225
  • Country: lk
 

Online fchk

  • Regular Contributor
  • *
  • Posts: 244
  • Country: de
Here’s one optoisolator that looks decent enough https://www.digikey.com.au/en/products/detail/skyworks-solutions-inc/SI8422AB-D-IS/4901110

Not decent enough. You should use this one:

https://www.digikey.com.au/en/products/detail/analog-devices-inc/ADUM242E1BRIZ-RL/6072256

You want 5kV Isolation volatage and at least 7.5mm clearance and creepage between mains voltage and safe low voltage.  2 channels in each direction for TX & Do and RX & RESET.

fchk
 
The following users thanked this post: bsodmike

Offline bsodmikeTopic starter

  • Regular Contributor
  • *
  • Posts: 225
  • Country: lk
Thanks!!
 

Online fchk

  • Regular Contributor
  • *
  • Posts: 244
  • Country: de
Thanks!!

And this DC-DC to power the HV side:
https://www.digikey.com.au/en/products/detail/gaptec-electronic/1S7B-0505S6UP/13692011

You will need a 3.3V LDO at the output for the CS5490 VCC.

You may need an isolation slot between input and outout pins on the DC-DC in order to maintaine safety distances.

fchk
 

Online Psi

  • Super Contributor
  • ***
  • Posts: 9939
  • Country: nz
You could have two circuits: one connected to the mains, via a non-isolated supply, which measures the voltage directly, digitises it and transmits it over an optical, or RF link, to a battery powered receiver.

I was thinking this two, one cheap MCU connected directly to mains with a few parts so it can measure whatever you want on mains. Probably using a capacitive dropper psu for power, this MCU sends the measured data over an optoisolator to the primary MCU.

Bonus points if there's a bootloader on the mains MCU so the primary MCU can reflash it over the same optoisolator link.  This way the mains MCU source can be included in the code for the primary MCU and it can reflash it if the version is different to what it query's at startup.  This way you never have to connect a programming header to the mains side.  Best way to implement this is to pick a MCU for the mains side that has a bootloader built in from factory that is accessible over I2C or serial or whatever protocol you use for the optoisolated link

Once you get the mains MCU working you could even cover the thing in epoxy or potting compound for safety.

Of course, this breaks one of my rules. Never use two mcus in a project if you can get away with 1, it complicates everything. But in this case i think it is justified.  Unless you can figure out a way to measure what you need on the mains side using discreet components.
« Last Edit: November 12, 2021, 12:44:58 pm by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 
The following users thanked this post: bsodmike

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3036
  • Country: us
I list some ready-made modules here with RS485 interfaces:

https://www.eevblog.com/forum/projects/looking-for-module-to-measure-mains-rms-ac-voltage-from-a-microcontroller/msg3788729/#msg3788729

There is an extensive video review of the PZEM module.
« Last Edit: November 12, 2021, 12:53:36 pm by ledtester »
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3353
  • Country: nl
If you want "safe" and want to extend that to (indirect) lightning strikes, then use a few meters of optical cable. Optical cable / receivers / transmitters for audio are widely available and cheap.
Another option is RF.

Maybe you should consider using one of those "energy metering" IC's. These generally have voltage and current inputs and generate pulses for power output. Fixing such an IC so that both inputs are related to the voltage is easy.

Another option is to use a transfomer. A simple way is to put the secondary of two mains transformers in series to keep far away from saturation, but there are special transformers for measurement purposes.
« Last Edit: November 12, 2021, 01:07:36 pm by Doctorandus_P »
 

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 9012
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
A cheap, no programming required option would be to have a FM transmitter connected to the mains via a voltage divider and a FM receiver (e.g. RTLSDR) connected to a PC. That's a surprisingly good option if you're more interested in the waveform and how it varies over time rather than absolute accuracy. (Better than 1% accuracy measuring mains voltage is not that useful anyways...) It could also be possible to hack a cheap Bluetooth headset instead of a FM transmitter.

You can also take a look at smart plugs, the ones that have energy monitoring generally are able to report the mains voltage.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Online fchk

  • Regular Contributor
  • *
  • Posts: 244
  • Country: de
This was my solution.

fchk
 
The following users thanked this post: uer166, bsodmike

Offline Terry Bites

  • Super Contributor
  • ***
  • Posts: 2391
  • Country: gb
  • Recovering Electrical Engineer
Safe is a relative term. You need to stand off from the volts but also consider the leakage currents that flow in the capacitance between your hot and cold sides.
Its not unusual to set an isolation barrier much higher than the peak AC voltage. In medical applications 4Kv and <50uA leakeage of isolation is the norm!
In industrial applications you can get away with a lot less.
There's nothing inherently wrong about V>f, f>V except for a low measurement bandwith. The settiling time of the VCO and the integrator put the mockers on that. Isolated Sigma-Delta modulators are a much faster and easy to implement using anlog or digital reconstruction of the input voltage. Check out the AD7400 series, 5KV and 16bits for $10.
 

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 6972
  • Country: ca
You need an input fuse.
The PZEM and such have no safety or agency approvals, who knows if they have adequate spacings and what Overvoltage Category they might achieve. If you can't use a safe measurement circuit, at least have a fuse to prevent bonfire of the circuit board.

From the smart energy meter house fires, the overvoltages seen at the service panel can be quite high, many kV. Using MELFs for the resistive divider, testing to 8kV impulse or more is good practice in Cat. IV.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf