Universal main voltage precense detector for MCU

Thread Starter

swedman69

Joined Sep 20, 2019
7
Dear fellow engineers,

I am trying to find a robust & proven design for detecting mains voltage precens for our MCU-board. We need to detect if AC (110V or 230V) is present and present a logic signal accordingly to the MCU. Although there are many suggestions to simply use an opto-coupler and series resistors on the AC-side I am not sure this is robust enough. I am thinking about voltage spikes that can occur on the AC -side and the effects it can have on the LED in the Opto-coupler. Do you have any ideas that is tested and "fool proof"?

All the best
Swedman
 

Thread Starter

swedman69

Joined Sep 20, 2019
7
Hi nsaspook!

Yeah a relay could do the job but I would prefer to avoid something mechanical. Lets see if there is some more suggestions.

Have a nice weekend & Cheers!
 

nsaspook

Joined Aug 27, 2009
13,081
Hi nsaspook!

Yeah a relay could do the job but I would prefer to avoid something mechanical. Lets see if there is some more suggestions.

Have a nice weekend & Cheers!
Sure, that was a rhetorical answer to the statement of tested and "fool proof".

There are just dozens of tried and true solutions to the problem in nice packages that will be more reliable than the external parts needed to operate them.
https://www.onsemi.com/products/opt...ouplers/specific-function-optocouplers/mid400
https://www.onsemi.com/pub/Collateral/AN-3007.pdf.pdf
 

Thread Starter

swedman69

Joined Sep 20, 2019
7
Sure, that was a rhetorical answer to the statement of tested and "fool proof".

There are just dozens of tried and true solutions to the problem in nice packages that will be more reliable than the external parts needed to operate them.
https://www.onsemi.com/products/opt...ouplers/specific-function-optocouplers/mid400
https://www.onsemi.com/pub/Collateral/AN-3007.pdf.pdf
Yeah thats true! Well I am not sure it the opto-coupler solutions have the problem I speak about (Mains spikes etc) but this function is vital to the operation. Surely there must be a "non mechanical" trusted way to do this...
 

KMoffett

Joined Dec 19, 2007
2,918
Last edited:

Thread Starter

swedman69

Joined Sep 20, 2019
7
May we assume that your MCU is powered independently of the mains? A universal ( 100VAC-240VAC) 5 VDC wall wart to the MCU's input is an isolated way to monitor the mains. You can add a resistor and Zener to protect against spikes.
Hello "KM"

Thanks for chipping in on the subject :)

No, its actually powered by the mains but through a switched power supply. So that part is all good and secure. We need this "Mains detection" to determine whether to connect a battery to the internal power bus or not when there is a AC (Mains) failure. So what we are looking for here is something that will go into the PCB design, not an external component. It might add that this is a commercial grade product and not an hobby project. Just to set the bar right :)

Thanks for replying and I wish you a great weekend!
//Swed
 

KMoffett

Joined Dec 19, 2007
2,918
Is the switched mode power supply and/or the battery on or off the PCB? Seems that you could use a "diode OR" from the battery and the SMPS's to select the MCU's power source. And an MCU's input from the SMPS's output to monitor if there is a loss of mains and that you are running on battery.

Ken
 

Reloadron

Joined Jan 15, 2015
7,501
Given the choices I would use either an opto coupler like the Optocoupler, Phototransistor Output, AC Input, with Base Connection such as this one or a solution like Max suggested. Take a Neon lamp like the one illustrated and get a clear plastic bezel. Glue a photo transistor to the bezel and use black heat shrink tubing around the pair. I have used that method years ago with excellent results. A dew I made up were working fine 20 years later. My first choice today would be the H11AA1 suggested, that's what they are designed for.

Ron
 

KMoffett

Joined Dec 19, 2007
2,918
Seems like the H11AA1 would require a 24KΩ resistor that can dissipate 2.4W for 10mA LED current for a 240Vac source. Two Schottky diodes from the existing 5V SMPS and the battery would have a smaller foot print and dissipate very little power. It could also tell the MCU if the 5V SMPS supply died even if the mains remained on.
Ken
 

Reloadron

Joined Jan 15, 2015
7,501
Seems like the H11AA1 would require a 24KΩ resistor that can dissipate 2.4W for 10mA LED current for a 240Vac source. Two Schottky diodes from the existing 5V SMPS and the battery would have a smaller foot print and dissipate very little power. It could also tell the MCU if the 5V SMPS supply died even if the mains remained on.
Ken
Yes, that is the downside. Normally I only need to detect 120 VAC so I would use two 6K 1W resistors, one on each side. Thinking about it further I like your approach better. Should work just fine, smaller footprint and last a long time. I am not sure how the thread starter wants to define "robust". :)

Ron
 

Thread Starter

swedman69

Joined Sep 20, 2019
7
Hello gentlemen!

Thanks for all your suggestions. I found the "Neon/LDR" idea smart and can see the benefits! But component sourcing people and the pick and place machine will scratch their head :) I tried to find a "Neon indicator" in SMD package but gave up after an hour. Its seems as this technology is obsolete and replaced with...yeah you guessed it: LED.

I am quite surprised how difficult it seems to find the "standard" solution to this as it must be used in millions of products. I still believe this is crucial to get right as our equipment sits in all kind of electrical-grids around the world. Perhaps I should try to find out what NASA guys are doing in regards to this :)
 

Thread Starter

swedman69

Joined Sep 20, 2019
7
An LED-Transistor optocoupler followed by a low pass filter should do it.
Hello DickCappels!

Yes it should do it but I doubt the reliability to handle mains-spikes/transients. I have seen many opto-couplers blow up this way. I need something really rugged without designing a pre-conditioning step like MOVs etc.

Best regards
Swed
 

Picbuster

Joined Dec 2, 2013
1,047
Dear fellow engineers,

I am trying to find a robust & proven design for detecting mains voltage precens for our MCU-board. We need to detect if AC (110V or 230V) is present and present a logic signal accordingly to the MCU. Although there are many suggestions to simply use an opto-coupler and series resistors on the AC-side I am not sure this is robust enough. I am thinking about voltage spikes that can occur on the AC -side and the effects it can have on the LED in the Opto-coupler. Do you have any ideas that is tested and "fool proof"?

All the best
Swedman
If you want a stable system you can do the following.
use a cheap transformer 240-12V it will output from 80 to 250V.
This will be used to:
power a pic12F + opamp ( use a big capacitor allowing to work for eq mS.
feed the AC into the opamp make sure that you amplify 1000 x
This will produce a 1/2 period block the length of that block should be one period time.
Result no problem with spikes.
Disadvantage it tales 1/2 a period to detect.
I
Picbuster
 

Thread Starter

swedman69

Joined Sep 20, 2019
7
If you want a stable system you can do the following.
use a cheap transformer 240-12V it will output from 80 to 250V.
This will be used to:
power a pic12F + opamp ( use a big capacitor allowing to work for eq mS.
feed the AC into the opamp make sure that you amplify 1000 x
This will produce a 1/2 period block the length of that block should be one period time.
Result no problem with spikes.
Disadvantage it tales 1/2 a period to detect.
I
Picbuster
Hi Picbuster

Thanks for your suggestion! We already got the power for the project/MCU sorted so the added benefit of the transformers is already sorted out. After thinking about this during the weekend I have come to the conclusion to go this way: We will add extra protection on the AC input side in the form of GDT+TVS+TBU and then go the opto-coupler route after that. It should be good enough.

Cheers
Swed
 
Top