Measuring AC voltage of two different AC sources using micro controller - Page 1
Forum section: electronics / general

author: arslan43711
author_rank: Contributor
timestamp: February 15, 2020, 09:59:39 am
content: Hi,this is the first time I am posting to some kind of forum.I am having trouble with my circuit that I am using to measure the voltage of the AC supply using Arduino.Basically, I want to measure the voltage of two different AC sources using the same microcontroller. I have made a circuit whose picture I have attached with this post. It works perfectly fine when I attach only one AC source but when I evenattach only one wire of the other AC source it displays the voltage of both the lines.Can anyone guide me in the right direction?Thanks.

author: fcb
author_rank: Super Contributor
timestamp: February 15, 2020, 10:16:25 am
content: Are your two AC sources linked in anyway? I.e. not fully floating??

author: arslan43711
author_rank: Contributor
timestamp: February 15, 2020, 10:20:22 am
content: currently, I am using two different phases of AC source to test.

author: arslan43711
author_rank: Contributor
timestamp: February 15, 2020, 10:46:50 am
content: I have attached the picture of my wiro board circuit.

author: fcb
author_rank: Super Contributor
timestamp: February 15, 2020, 11:07:35 am
content: Quote from: arslan43711 on February 15, 2020, 10:20:22 amBut are they linked in anyway?If the sources have some sort of electrical common then you’ll have to look at how the circuit works again.Please provide details of the sources.

author: arslan43711
author_rank: Contributor
timestamp: February 15, 2020, 11:24:41 am
content: I am using 2 phases (and neutral) out of 3 phase ac supply from grid station(220v AC between each phase and neutral).

author: fcb
author_rank: Super Contributor
timestamp: February 15, 2020, 11:50:59 am
content: There’s your problem.The solution is simple (if just as dangerous), but you will end up with half-wave rectified voltage (so only the positive halves/peaks of each waveform.Also, your design intention is only to capture the peak voltage, not RMS?

author: arslan43711
author_rank: Contributor
timestamp: February 17, 2020, 03:48:34 am
content: QuoteI did not get it can you can explain what I am doing wrong. Can you explain/name the phenomena that are causing this issue? Initially, I had the plan to use half-wave rectification but I roll that out because both the phase can be from a single grid station or also can be from different grid stations. I need common GND of both the phases so that I could connect the microcontroller GND. One other reason for full-wave rectification is that if the neutral and phase is interchanged it does not any effect.

author: Helix70
author_rank: Unknown
timestamp: February 17, 2020, 11:44:28 am
content: How is the circuit powered? Is it floating or is the Arduino ground earthed? Without a transformer isolating the AC input, the swing is above *and* below the earth reference. The "ground" from the rectifier is actually negative with respect to neutral.

author: StillTrying
author_rank: Super Contributor
timestamp: February 17, 2020, 01:18:38 pm
content: Quote from: arslan43711 on February 17, 2020, 03:48:34 amFollow where the 220 AC goes through the bridge rectifier and you'll see your 0V/GND gets connected to minus 300V.It's too dangerous, I'm surprised you haven't been electrocuted already. Measuring the AC voltages though 2 small low voltage mains transformers would be better.

author: arslan43711
author_rank: Contributor
timestamp: February 18, 2020, 09:27:15 am
content: QuoteI am powring the circuit with 5v mobile phone charger that has 2 legs (no earth). I have made common all the grounds.

author: arslan43711
author_rank: Contributor
timestamp: February 18, 2020, 09:32:25 am
content: QuoteTill this time I have not got electrocuted. At the out of the voltage measurement circuit, I have dc voltage less than 12v that is not dangerous. I did not want to use the transformer.Reasons, It will increase the cost and size of the circuit.

author: Helix70
author_rank: Unknown
timestamp: February 18, 2020, 10:24:44 am
content: The biggest problem here is that you don't know just how dangerous this circuit is. You have no respect for the danger.

author: StillTrying
author_rank: Super Contributor
timestamp: February 18, 2020, 01:02:55 pm
content: Quote from: arslan43711 on February 18, 2020, 09:32:25 amWhat you think is 0V and 12V is more like -320v and -308V froma real0V/GND/Earth,so quite dangerous.You don't have to believe us, you could just follow where the -Ve mains cycles go through the bridge rectifier on your diagram.Or find out the hard way.

author: Renate
author_rank: Super Contributor
timestamp: February 18, 2020, 01:14:33 pm
content: I'll add my voice to Helix70 and StillTrying.(I can't believe it took until post #8 for the warnings to come out.)This is dangerous shit.You are running a whole floating setup running at over -300V!I hate to even recommend any tests to prove that this is dangerous as the tests would be dangerous!If I were there, I'd hook a solid ground to your so-called "ground" in the circuit.I'd get a fire extinguisher, plug in the circuit and put the flames out that are shooting out of the 100 ohm resistors.That might convince you.Seriously, this is dangerous shit.

author: fcb
author_rank: Super Contributor
timestamp: February 18, 2020, 04:05:01 pm
content: What you are trying to acheive is commonly done throughout the world. How you are doing it is dangerous; not only to you put possibly the end users.In the interests of being helpful and trying to preserve/prolong your life I've drawn up a simple circuit (attached) that will be far less dangerous, more accurate and lower cost.The opamps can be generic rail-to-rail units.Ensure the 1M resistors are have suitable WORKING voltage ratings - so 1210 or 1/2W types please and with careful attention paid to creepage/clearance. Essentially you have 3M between you and the mains with this design which limits peak currents under normal circumstances to less than lethal amounts. The three resistors spread the working voltage across them, before building this - make sure you have understood the potential failure modes of resistors and safe layout!I would digitise the signals at ADC#1 and ADC#2, calculate the RMS/VPK etc.. in the microcontroller, saves the cost of the peak converter opamps etc.. Also you will get Vrms not Vpk (more useful - but we don't know what you are trying to do, so perhaps not).If you increase the size of the intergrator capacitors you'll get a smoother DC (less ripple) but at the expense of slower response (but you might want that).If you are wondering what V4 on the model is an AC source of 500V @1234Hz - just used to prove immunity to some amount of offset's, noise, etc..This design should also work if you use the third phase instead of neutral - you might want to change the gain a bit to give you more headroom.LTspice model attached.mains.asc(8.78 kB - downloaded 62 times.)

author: jesuscf
author_rank: Frequent Contributor
timestamp: February 20, 2020, 06:24:32 pm
content: Quote from: arslan43711 on February 18, 2020, 09:32:25 amYour circuit, as many others had pointed out, is very dangerous. Safety MUST be your #1 priority, before cost and size.

author: johnkenyon
author_rank: Regular Contributor
timestamp: February 21, 2020, 11:14:54 am
content: Feed each phase into a separate transformer then play with low voltages (AC or unsmoothed DC).If you don't isolate then you have to design for phase-phase voltages and faults.If you want to see how it's done with a single phase (along with AC power failure detection) elsewhere have a look at the circuit diagrams for an APC UPSfor example:https://elektrotanya.com/apc_ups_450_620_700.pdf/download.htmlOn sheet 1 they have a centre tapped transformer feeding two diodes. The full wave rectified signal gets sent to sheet 2 ("IN-RECT"), On sheet 1 it gets used to create an AC-OK signal.A further blocking diode then feeds the smoothing capacitors and provides VSTBY to the rest of the device. (the blocking diode prevents the AC-FAIL and AC Input voltage detection from seeing the smoothing capacitor.On sheet 2 IN-RECT gets conditioned with two resistors and a capacitor before being fed into an ADC (IC10).Put another way - with a transformer you can get away with two diodes, two resistors and a capacitor, and a known safe circuit which can give you DC power for free on the side. (Hint feed the smoothed DC output from both transformers via diodes into a regulator and you get safe "redundant" DC power from either phase)Yes the transformers take up real estate, and aren't cheap, but you are trading the known cost of component and PCB space against the costs of designing a solution which can handle unknown failure modes in the face of 400VAC.Also if needs be, you can carry out conditioning of the signal "cheaply" in the analogue domain rather than having to code a solution from scratch.jkPS If you never intended connecting directly to the AC supply, you should have made this clear by showing the two AC sources as being each fed via a transformer... (My crystal ball hasn't worked for years...)