EEVblog Electronics Community Forum

Electronics => Projects, Designs, and Technical Stuff => Topic started by: JJalling on June 18, 2015, 06:21:12 pm

Title: Isolated voltage detector (AC mains)
Post by: JJalling on June 18, 2015, 06:21:12 pm
Hi all,

How would you detect mains AC with a microcontroller? It needs to be isolated, so i'm thinking of just using an opto-couple and a couple of resistors.
Can anyone suggest a better solution?

BR Jonas
Title: Re: Isolated voltage detector (AC mains)
Post by: Fungus on June 18, 2015, 07:02:18 pm
Connecting an optocoupler directly to the mains is risky.

But... a very similar way is to connect one of those little neon mains indicator bulbs to the mains wires then detect the light from it with a phototransistor.

Those neon mains indicators are very robust against mains spikes, etc. Much more so than a LED.

Title: Re: Isolated voltage detector (AC mains)
Post by: LukeW on June 18, 2015, 11:45:19 pm
You could use a zero-crossing detector, something like this.

http://www.dextrel.net/diyzerocrosser.htm (http://www.dextrel.net/diyzerocrosser.htm)

This gives you galvanic isolation and a sensible driver circuit on the AC side powering the LED, efficiently.

Alternatively, how about using an ordinary cheap, off-the-shelf small switchmode power supply to supply 5V or so to one of the microcontroller inputs from the AC mains circuit?
Title: Re: Isolated voltage detector (AC mains)
Post by: jeroen79 on June 18, 2015, 11:52:31 pm
Or a small transformer, perhaps with a rectifier.
Or a mains operated relay.

What do you want to use it for?
Title: Re: Isolated voltage detector (AC mains)
Post by: AlfBaz on June 19, 2015, 12:02:17 am
What am I missing?

Take the ubiquitous 4N25 opto. The first line in the data sheet under applications "Mains Detection"
Title: Re: Isolated voltage detector (AC mains)
Post by: c4757p on June 19, 2015, 01:42:17 am
What am I missing?

Take the ubiquitous 4N25 opto. The first line in the data sheet under applications "Mains Detection"

This. I'm not sure why you'd want any of the other solutions, they're all rather over-complicated in my opinion.
Title: Re: Isolated voltage detector (AC mains)
Post by: codeboy2k on June 19, 2015, 02:00:46 am
Connecting an optocoupler directly to the mains is risky.

What?  While I like your neon idea, it's not necessary and it's not risky to connect the opto to mains.  You can do it with a protection diode and a 220k resistor.  100k for 110V AC.

I just whipped this (untested) circuit  up.  You don't need the MOVS or the spark gap, I just put it there to fully protect the opto from line transients and alleviate any fears of connecting the opto to the mains.   If your AC lines are already protected or you otherwise don't care, then you can leave it out.  It's a complete (and good) solution with them in there, though.

(http://i.imgur.com/SpQP2ZGm.png) (http://imgur.com/SpQP2ZG.png)

EDIT: updated with V2 schematic and LTSpice file.  Adds peak detector and logic level output, 3.0V when AC is on, 0V when AC is off.
EDIT: updated with V3 schematic: Adds 100mA fuse for ultimate protection with the MOVs.
Title: Re: Isolated voltage detector (AC mains)
Post by: JJalling on June 19, 2015, 08:19:24 am
Thanks for all your suggestions.
I need to detect if the fuse is blown on 50 mains lines, so it needs to be small and efficient. I think I will give the circuit that codeboy2k suggests a try.

BR Jonas
Title: Re: Isolated voltage detector (AC mains)
Post by: Gyro on June 19, 2015, 10:26:32 am
If you've got as many as 50 to sense then it might almost be worth designing some mains referenced logic to sense them directly (resistively) and transmitting serial status to your ground referred micro via a single opto.

It would need designing with care of course but might end up smaller and cheaper - depends how many you're making.
Title: Re: Isolated voltage detector (AC mains)
Post by: Psi on June 19, 2015, 11:27:46 am
an opto darlington will have plenty of gain so you can turn it hard one with a small amount of LED current, which is useful if your dropping 230V down to 3V with a resistor
Title: Re: Isolated voltage detector (AC mains)
Post by: Zero999 on June 19, 2015, 11:31:16 am
If you've got as many as 50 to sense then it might almost be worth designing some mains referenced logic to sense them directly (resistively) and transmitting serial status to your ground referred micro via a single opto.

It would need designing with care of course but might end up smaller and cheaper - depends how many you're making.
Whether that can be done, depends on whether the channels need to be isolated from one another.
Title: Re: Isolated voltage detector (AC mains)
Post by: Kleinstein on June 19, 2015, 03:02:35 pm
If efficiency is important the resistor to set the current could be replaced by a capacitor to a large extend (e.g. 10 nF and 1 K in series). Also a more sensitive opto coupler, that can work with something like 0.1 mA helps.

Usually mains voltage fuses are in the hot side, with the other side at neutral. So a common circuit could be connected to the mains neutral side and detect different lines even if they use different phases or voltages. Still an opto coupler at the output is a good idea.
Title: Re: Isolated voltage detector (AC mains)
Post by: eneuro on June 19, 2015, 08:52:50 pm
Connecting an optocoupler directly to the mains is risky.
... unless you and additional diode anti-parallel to PC817 optocoupler input diode and a few resistors  >:D
(https://www.eevblog.com/forum/projects/inverse-parallel-scr-driver-circuit-with-moc3041ac-mosfets-switch/?action=dlattach;attach=156247)
https://www.eevblog.com/forum/projects/inverse-parallel-scr-driver-circuit-with-moc3041ac-mosfets-switch/msg691833/#msg691833 (https://www.eevblog.com/forum/projects/inverse-parallel-scr-driver-circuit-with-moc3041ac-mosfets-switch/msg691833/#msg691833)

Update: Ups, now noticed that @codeboy2k  send something similar ;)
Testing my circuit with 100k total series resistance @ 230VAC, but I have four 0.25W 100k which gives from calculation ~0.13W for each of them and I have them soldered to 0.5m copper wires, so heat is transfered additionally to wire-probably using ~200k @ 230VAC could be better idea, however didn't notice they got hot in final assembly like this below:
(http://s17.postimg.org/z7y0wakpn/proacvzc_100k_1_N4007_EL817_assembled_forum.jpg) (http://postimg.org/image/z7y0wakpn/)
Title: Re: Isolated voltage detector (AC mains)
Post by: gogoman on June 28, 2015, 01:54:29 pm
hi
what was the reason for the choice of 400 volt MOV for the 220ac. for a 250vac would 300volts MOV be the enought?
Why is the spark gap needed.
Title: Re: Isolated voltage detector (AC mains)
Post by: poorchava on June 28, 2015, 02:02:28 pm
A completly non-contact detection is quite easy to do by detecting electrical field. This approach involves an opamp in a non-orthodox configuration and steep bandpass filtering.

Since this is used in a product which my company sells, I can't be more specific than that.

It does not require any bulky or expensive components, can be done using jellybean parts only.

Sent from my HTC One M8s using Tapatalk
Title: Re: Isolated voltage detector (AC mains)
Post by: codeboy2k on June 28, 2015, 03:10:36 pm
hi
what was the reason for the choice of 400 volt MOV for the 220ac. for a 250vac would 300volts MOV be the enought?
Why is the spark gap needed.

250VAC is the RMS value.  250*1.414 is the peak AC voltage, and that is about 355V, so a 300 volt MOV is not going to be acceptable here, so 400V MOV's are usually specified.

I mentioned that all of the protection devices are just there for completeness in my circuit drawing and you can choose to use them or not, depending on your needs.  The spark gap is just "Guilding the Lily" a little bit more, and for most cases, the MOV's alone provide good protection, as you've said yourself.

The spark gap might be needed in a more exposed installation, i.e. one that was outdoors in a hut under a transmitter tower (my own personal experience is here).

So I put it in my circuit and added a caveat that you only use what you need to use.
Title: Re: Isolated voltage detector (AC mains)
Post by: gogoman on June 28, 2015, 06:55:34 pm
MOV are available in different Diameters, is there advantage using a 7mm vs 10mm Vs 20mm.
 

Where in the AC line should they be placed?

thanks
Title: Re: Isolated voltage detector (AC mains)
Post by: codeboy2k on June 29, 2015, 02:29:09 am
MOV are available in different Diameters, is there advantage using a 7mm vs 10mm Vs 20mm.

Where in the AC line should they be placed?
thanks

Choose the MOV by it's voltage rating. The thickness is determined by the chemistry, and some manufacturers are using different chemistries to achieve thinner or smaller MOVs with the same or higher voltage ratings.  It's all about reducing size.

MOV's should be placed just at the line entrance point to your circuit.

Also, you should ideally have a fuse in it at the line entrance point too. The fuse would be placed before the MOVs.  Then, when a transient occurs and  punches through the MOV you want the fuse to blow. This is especially important with a low-current load, such as in this case with the LED inside the opto-isolator being the load.  When a MOV punches through, it creates a low-impedance path that can continue to flow current, bypassing the load (the MOV becomes the new load) and overheating the MOV,  causing it to catch fire.  To counter this possibility (for low current loads) a fuse is used to open the circuit if the MOV shorts out like this.  Since the load is less than 10 mA, I would say perhaps a fuse rated at 100 mA should be ok;  if that blows, something is wrong and you likely need to replace the MOV's then.

*note- for higher current loads, a fuse might be rated too high for a MOV event to blow it.. in those cases you would need to use a TCO (thermal cut-off) in series and placed near the MOV, or a single TMOV, a device with a built-in TCO. This detects the overheating of the MOV and takes the MOV out of circuit before it can catch fire.

This AC mains stuff needs to be put in Dave's Wiki... should I do it :)
Title: Re: Isolated voltage detector (AC mains)
Post by: Circlotron on June 29, 2015, 08:01:16 am
Could use a differential amplifier with the inputs connected either side of the fuse,and with the input resistors about 100 times the size of the feedback resistors.
Title: Re: Isolated voltage detector (AC mains)
Post by: funkathustra on June 30, 2015, 06:45:41 am
If you just need to detect the *presence* of voltage, whack on the classic H11AA1 bi-directional NPN-output photo transistor H11AA1 (http://www.vishay.com/docs/83608/h11aa1.pdf), a series 33k resistor, and a pull-up resistor to your logic voltage (3.3 or 5V).

Totally isolated. Only uses 1 active + 2 passives.

When you see pulses on the output, you know there's AC there. When you don't, the AC is gone. Boom.

[Schematic (http://i.imgur.com/SbiVmKl.jpg)]
Title: Re: Isolated voltage detector (AC mains)
Post by: eneuro on June 30, 2015, 09:23:25 am
If you just need to detect the *presence* of voltage, whack on the classic H11AA1 bi-directional NPN-output photo transistor
This is another option-I've decided to use classic PC817 optocoupler with additional anti parallel diode with builtin PC817 input diode, while I wanted to know when given AC polarity waveform begins, and using this half period AC signal detection still was able compute AC mains period in MCU and offests due to presence of this series resitance 100k-200k.
If someone doesn't need to detect given AC waveform polarity,  than H11AA1 will be even more compact design  :-+
Title: Re: Isolated voltage detector (AC mains)
Post by: DavidAlfa on July 31, 2022, 03:43:14 pm
Let me wake up this thread for the same reason, a friend wants a simple RPM detector for a generator.
Instead using an inductive sensor I'd thought it'd be much easier and cheaper to detect the AC frequency.
How about this? Resistors might need to be smaller, perhabs 75-82K each, but in the simulator it works from 35V or so.
Small cap to filter fast trasients.
Title: Re: Isolated voltage detector (AC mains)
Post by: R_G_B_ on July 31, 2022, 08:28:53 pm
https://www.jameco.com/Jameco/workshop/JamecoFavorites/non-contact-AC-voltage-detector.html (https://www.jameco.com/Jameco/workshop/JamecoFavorites/non-contact-AC-voltage-detector.html)

https://chowdera.com/2021/11/20211113154158785r.html (https://chowdera.com/2021/11/20211113154158785r.html)
Title: Re: Isolated voltage detector (AC mains)
Post by: srb1954 on August 01, 2022, 02:20:43 am
MOV are available in different Diameters, is there advantage using a 7mm vs 10mm Vs 20mm.
 

Where in the AC line should they be placed?

thanks
Larger diameter MOVs can safely absorb more energy. They are usually specified in the number of Joules they can absorb per transient pulse and a larger device will have a greater Joule rating.

Each time a MOV absorbs a transient pulse it is damaged a little; most only rated for absorbing 10 pulses at their specified Joule rating. Eventually, the MOV will be sufficiently damaged that the leakage current increases to excessive levels and it overheats. Consequently, a MOV should be placed downstream of a protective device such as a fuse or circuit breaker, which will prevent this overheating escalating into a fire.
Title: Re: Isolated voltage detector (AC mains)
Post by: DavidAlfa on August 01, 2022, 07:38:35 am
Damn, shouldn't have re-floated it. Don't answer to the 2015 question folks!  :palm: