Suggestions for a simple SAFE opto-isolated 230VAC voltage measurement circuit - Page 1
Forum section: electronics / projects

author: bsodmike
author_rank: Regular Contributor
timestamp: June 25, 2021, 08:15:25 am
content: Hi all,This topic will make most eyes-roll, but hear me out please.I want to be able to measure mains-AC voltagesafely. This means, not looking at the cheap options on Aliexpress.I found thisgreat Hackaday articledetailing an opto-isolated solution with a LM331. Full details can beread here.This has an input limit of 1V - 5V and reconstructs this as a frequency from 1 - 5kHz.One of the comments mention:QuoteAll I'm looking for is a nice ADC with isolation, of course, I have no issues adding opto-isolation myself (here'san 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.

author: Ian.M
author_rank: Super Contributor
timestamp: June 25, 2021, 08:42:00 am
content: 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!

author: bsodmike
author_rank: Regular Contributor
timestamp: June 25, 2021, 08:59:04 am
content: 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 fuseinstall a in-rush current limiterAny 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?

author: bsodmike
author_rank: Regular Contributor
timestamp: June 25, 2021, 09:04:34 am
content: 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 frequencyAccuracy (Voltage): 0.01VACAccuracy (Frequency): 0.01HzIsolation: typical 4000 KV is fine

author: Zero999
author_rank: Super Contributor
timestamp: June 25, 2021, 09:12:08 am
content: 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.

author: Ian.M
author_rank: Super Contributor
timestamp: June 25, 2021, 09:17:05 am
content: Quote from: bsodmike on June 25, 2021, 08:59:04 amIf 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.Quote from: bsodmike on June 25, 2021, 09:04:34 amYour 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 . . .

author: penfold
author_rank: Frequent Contributor
timestamp: June 25, 2021, 09:46:07 am
content: 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)

author: uer166
author_rank: Super Contributor
timestamp: June 25, 2021, 11:40:07 pm
content: 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.

author: nctnico
author_rank: Super Contributor
timestamp: June 26, 2021, 01:10:30 am
content: 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!

author: bdunham7
author_rank: Super Contributor
timestamp: June 26, 2021, 02:08:21 am
content: Quote from: Ian.M on June 25, 2021, 09:17:05 amI'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.

author: bsodmike
author_rank: Regular Contributor
timestamp: November 12, 2021, 09:32:45 am
content: 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.

author: bsodmike
author_rank: Regular Contributor
timestamp: November 12, 2021, 10:02:13 am
content: 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 drawkWh Energy tracking(Optional) Power factorThanks!!

author: fchk
author_rank: Frequent Contributor
timestamp: November 12, 2021, 10:31:25 am
content: Look here:https://d3uzseaevmutz1.cloudfront.net/pubs/proDatasheet/CS5490_F3.pdfDigikey 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.

author: bsodmike
author_rank: Regular Contributor
timestamp: November 12, 2021, 10:44:05 am
content: Thanks! That’s exactly what I’m looking for. Now to see if I can source a few chips.

author: bsodmike
author_rank: Regular Contributor
timestamp: November 12, 2021, 10:57:32 am
content: Here’s one optoisolator that looks decent enoughhttps://www.digikey.com.au/en/products/detail/skyworks-solutions-inc/SI8422AB-D-IS/4901110

author: fchk
author_rank: Frequent Contributor
timestamp: November 12, 2021, 12:05:11 pm
content: Quote from: bsodmike on November 12, 2021, 10:57:32 amNot decent enough. You should use this one:https://www.digikey.com.au/en/products/detail/analog-devices-inc/ADUM242E1BRIZ-RL/6072256You 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

author: bsodmike
author_rank: Regular Contributor
timestamp: November 12, 2021, 12:08:43 pm
content: Thanks!!

author: fchk
author_rank: Frequent Contributor
timestamp: November 12, 2021, 12:28:06 pm
content: Quote from: bsodmike on November 12, 2021, 12:08:43 pmAnd this DC-DC to power the HV side:https://www.digikey.com.au/en/products/detail/gaptec-electronic/1S7B-0505S6UP/13692011You 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

author: Psi
author_rank: Super Contributor
timestamp: November 12, 2021, 12:36:05 pm
content: Quote from: Zero999 on June 25, 2021, 09:12:08 amI 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 linkOnce 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.

author: ledtester
author_rank: Super Contributor
timestamp: November 12, 2021, 12:50:29 pm
content: 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/#msg3788729There is an extensive video review of the PZEM module.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: November 12, 2021, 12:52:14 pm
content: 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.

author: NiHaoMike
author_rank: Super Contributor
timestamp: November 12, 2021, 01:19:50 pm
content: 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.

author: fchk
author_rank: Frequent Contributor
timestamp: November 13, 2021, 07:17:27 pm
content: This was my solution.fchk

author: Terry Bites
author_rank: Super Contributor
timestamp: November 13, 2021, 09:34:44 pm
content: 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.

author: floobydust
author_rank: Super Contributor
timestamp: November 13, 2021, 09:50:59 pm
content: 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.

author: bsodmike
author_rank: Regular Contributor
timestamp: November 14, 2021, 05:06:24 am
content: Thanks Fchk. I’ve got some questions.On X1, I assume that the load is connected before pin 6, which has the live line just before the shunt. Then, pin 1 is the return Neutral line (hence GNDA is the Neutral line).X1’s pins 2 & 5 are a bit confusing. I would expect the live line connected at the C2 X2 class safety capacitor, with GNDA anyways being the Neutral return.What does PL_OGD mean for the fuse? You’re using a 4A fuse, any particular specs on this, I.e fast blow?Please correct me where my assumptions are incorrect!!Thanks M

author: fchk
author_rank: Frequent Contributor
timestamp: November 14, 2021, 07:58:34 am
content: PL_ODG is the type of fuse holder I used. The current measurement resistor R6 is sized for 4A, so the fuse must be 4A.X1: You connect your load to 1(L)/2(N)/3(PE) and your power plug to 6(L)/5(N)/4(PE). PE and N are directly connected, and L goes through the current shunt R6. If you swap 1/2/3 and 6/5/4 then your current and power readings would be negative..You may as well swap L and N. GNDA is the internal reference ground for the CS5490 for measurements. If yo swap L and N, you would measure current through N.C1 (the X2 capacitor) is connected between L and N - which side is GNDA doesn't matter since everything is isolated anyway.fchk

author: Alti
author_rank: Frequent Contributor
timestamp: November 14, 2021, 10:23:10 am
content: Quote from: bsodmike on June 25, 2021, 08:15:25 amWhat is wrong with measuring AC mains voltage via resistor divider? The overvoltage category applies to installation location and a voltage divider for 1500V (CAT I) is not much different than the one that deals with 2500V (CAT II), just more resistors. Why MELFs? Standard resistors also come with adequate voltage ratings so for 2500V you just need to use 5 x 1206, nothing crazy. If you need CAT IV - use even more resistors. MELFs shine when you need high pulse power, this application doesnotrequire any pulse power.Then just put adequate count of resistors in series and use an opamp with adequate biasing current. If you want 80M divider then use biasing current that is just much lower than 3uA. Of course the capacitance is going to shift 50Hz response - I am just pointing you won't receive output that is perfectly in phase with input with high value resistors stretched along PCB that form RCRCRCRCRC filter.Mind opamp differential amplifier has two inputs so you need two strings of resistors actually. If you can solve a problem with 10 resistors and jelly bean opamp then don't overdo with optoisolation. And don't use CAT I equipment in CAT IV environment.

author: bsodmike
author_rank: Regular Contributor
timestamp: November 21, 2021, 09:10:32 am
content: The requirement changed to full energy monitoring and therefore we chose a proven IC solution.