Isolated voltage detector (AC mains) - Page 1
Forum section: electronics / projects

author: JJalling
author_rank: Unknown
timestamp: June 18, 2015, 06:21:12 pm
content: 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

author: Fungus
author_rank: Super Contributor
timestamp: June 18, 2015, 07:02:18 pm
content: 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.

author: LukeW
author_rank: Frequent Contributor
timestamp: June 18, 2015, 11:45:19 pm
content: You could use a zero-crossing detector, something like this.http://www.dextrel.net/diyzerocrosser.htmThis 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?

author: jeroen79
author_rank: Frequent Contributor
timestamp: June 18, 2015, 11:52:31 pm
content: Or a small transformer, perhaps with a rectifier.Or a mains operated relay.What do you want to use it for?

author: AlfBaz
author_rank: Super Contributor
timestamp: June 19, 2015, 12:02:17 am
content: What am I missing?Take the ubiquitous 4N25 opto. The first line in the data sheet under applications "Mains Detection"

author: c4757p
author_rank: Super Contributor
timestamp: June 19, 2015, 01:42:17 am
content: Quote from: AlfBaz on June 19, 2015, 12:02:17 amThis. I'm not sure why you'd want any of the other solutions, they're all rather over-complicated in my opinion.

author: codeboy2k
author_rank: Super Contributor
timestamp: June 19, 2015, 02:00:46 am
content: Quote from: Fungus on June 18, 2015, 07:02:18 pmWhat? 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.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.

author: JJalling
author_rank: Unknown
timestamp: June 19, 2015, 08:19:24 am
content: 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

author: Gyro
author_rank: Super Contributor
timestamp: June 19, 2015, 10:26:32 am
content: 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.

author: Psi
author_rank: Super Contributor
timestamp: June 19, 2015, 11:27:46 am
content: 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

author: Zero999
author_rank: Super Contributor
timestamp: June 19, 2015, 11:31:16 am
content: Quote from: Gyro on June 19, 2015, 10:26:32 amWhether that can be done, depends on whether the channels need to be isolated from one another.

author: Kleinstein
author_rank: Super Contributor
timestamp: June 19, 2015, 03:02:35 pm
content: 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.

author: eneuro
author_rank: Super Contributor
timestamp: June 19, 2015, 08:52:50 pm
content: Quote from: Fungus on June 18, 2015, 07:02:18 pm... unless you and additional diode anti-parallel to PC817 optocoupler input diode and a few resistorshttps://www.eevblog.com/forum/projects/inverse-parallel-scr-driver-circuit-with-moc3041ac-mosfets-switch/msg691833/#msg691833Update: Ups, now noticed that @codeboy2k send something similarTesting 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:

author: gogoman
author_rank: Regular Contributor
timestamp: June 28, 2015, 01:54:29 pm
content: hiwhat 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.

author: poorchava
author_rank: Super Contributor
timestamp: June 28, 2015, 02:02:28 pm
content: 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

author: codeboy2k
author_rank: Super Contributor
timestamp: June 28, 2015, 03:10:36 pm
content: Quote from: gogoman on June 28, 2015, 01:54:29 pm250VAC 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.

author: gogoman
author_rank: Regular Contributor
timestamp: June 28, 2015, 06:55:34 pm
content: 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

author: codeboy2k
author_rank: Super Contributor
timestamp: June 29, 2015, 02:29:09 am
content: Quote from: gogoman on June 28, 2015, 06:55:34 pmChoose 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

author: Circlotron
author_rank: Super Contributor
timestamp: June 29, 2015, 08:01:16 am
content: 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.

author: funkathustra
author_rank: Regular Contributor
timestamp: June 30, 2015, 06:45:41 am
content: If you just need to detect the *presence* of voltage, whack on the classic H11AA1 bi-directional NPN-output photo transistorH11AA1, 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.[]

author: eneuro
author_rank: Super Contributor
timestamp: June 30, 2015, 09:23:25 am
content: Quote from: funkathustra on June 30, 2015, 06:45:41 amThis 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

author: DavidAlfa
author_rank: Super Contributor
timestamp: July 31, 2022, 03:43:14 pm
content: 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.

author: R_G_B_
author_rank: Frequent Contributor
timestamp: July 31, 2022, 08:28:53 pm
content: https://www.jameco.com/Jameco/workshop/JamecoFavorites/non-contact-AC-voltage-detector.htmlhttps://chowdera.com/2021/11/20211113154158785r.html

author: srb1954
author_rank: Super Contributor
timestamp: August 01, 2022, 02:20:43 am
content: Quote from: gogoman on June 28, 2015, 06:55:34 pmLarger 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.

author: DavidAlfa
author_rank: Super Contributor
timestamp: August 01, 2022, 07:38:35 am
content: Damn, shouldn't have re-floated it. Don't answer to the 2015 question folks!