Please Help Me …..Need AC Voltage Monitoring Circuit with protection

Thread Starter

Balaji Krish

Joined Mar 31, 2021
22
Hi guys,

I have designed a direct AC Main voltage monitoring circuit using a resistor network I am getting around 1.7V AC and I connect to ADC Pin in Microcontroller, I attached my circuit diagram below

My problem is
1. When I Switch ON or OFF my AC Main voltage I am getting a Voltage spike of more than 50V
2. Does it a healthy circuit?

Note: My Main AC Voltage connect also to AC motors


So Kindly give a solution or reference circuit to arrest voltage spike
Voltage monitoring ckt-.png
 

DickCappels

Joined Aug 21, 2008
7,155
That looks like a good, conservative, safe circuit.

I do not understand the need for the ferrite bead unless it is to keep the microcontroller clock from leaking into the power line, but for that to be most effective at attenuating the high frequencies an X capacitor should be placed across the input.

It might be that 100 Ohm ferrite bead between AGND and GND has something to do with the spike. You might try jumpering that out of the circuit and see if that helps.

If the purpose of the ferrite beads is to attenuate EMI getting onto the mains you might want to try this more "classic" circuit:
1617560470100.png
 

Irving

Joined Jan 30, 2016
1,141
Hmmm, I don't like any form of AC mains near my MCUs... I'd prefer to see an optoisolator, which would eliminate any spikes from motors or other inductors. Here's a simple one I've used before. If you want interrupts on zero crossings, reduce or remove C2.

View attachment 234488
 

EE engineer

Joined Jul 10, 2020
1
Could the spike come from the inductance of the motor , because it is connected to the mains . Also how quick is the spike , does it last long ?
As it is powered up, there is no control over the in rushing voltages on the windings and so the voltage rises very quickly. Maybe control this with a motor starter if possible

( I am also learning about this , as an electronics student, and one of myfirst thoughts was to identify if it is either a series or parallel RLC circuit and identify why it has this surge)
Please correct me if I am wrong
 

Thread Starter

Balaji Krish

Joined Mar 31, 2021
22
Hmmm, I don't like any form of AC mains near my MCUs... I'd prefer to see an optoisolator, which would eliminate any spikes from motors or other inductors. Here's a simple one I've used before. If you want interrupts on zero crossings, reduce or remove C2.

View attachment 234488
Hi Irving,

Thanks for your reply
It's a good circuit for eliminating the spikes

1. Could you tell me where I should measure the AC main Voltage because I have to monitor the AC voltage from low to high voltage?
2. Could you tell me C1 is a capacitor dropper?

Note: I used a 15V AC transformer and convert it to DC after it goes to the regulator it converts 5V DC to give MCU power
 

Ian0

Joined Aug 7, 2020
1,567
Do you need to measure the mains voltage or monitor it?
If you need an accurate value, then connect it through a small transformer such as this one
https://uk.rs-online.com/web/p/toroidal-transformers/1243841/
and measure the output with the MCU's A/D converter (sample it and computer the RMS value)
You could also use one of these:
https://www.microchip.com/wwwproducts/en/ATM90E26
which would do the sampling and the maths for you
or if you just want to know if the mains is below or above a certain value then this would do the job, but it's not particularly accurate.
It gives a 100Hz pulses train out if the mains is greater than275V peak (195V rms being a typical voltage at which to determine “mains failed”F4427FB5-7FEB-4134-98B6-A7A562C2CD9D.jpeg
 
Last edited:

Thread Starter

Balaji Krish

Joined Mar 31, 2021
22
Do you need to measure the mains voltage or monitor it?
If you need an accurate value, then connect it through a small transformer such as this one
https://uk.rs-online.com/web/p/toroidal-transformers/1243841/
and measure the output with the MCU's A/D converter (sample it and computer the RMS value)
You could also use one of these:
https://www.microchip.com/wwwproducts/en/ATM90E26
which would do the sampling and the maths for you
or if you just want to know if the mains is below or above a certain value then this would do the job, but it's not particularly accurate.
It gives a 100Hz pulses train out if the mains is greater than275V peak (195V rms being a typical voltage at which to determine “mains failed”View attachment 234530

Hi Ian0,

Thanks for your reply
I need to measure the AC main voltage to control the motor for under-voltage and over-voltage

Reg: This IC ATM90E26
In my product was the very low price so if I use this kind ic I need to spend some more money
So, Kindly suggest me to improve my already circuit and remove the voltage spike
 

Yaakov

Joined Jan 27, 2019
2,358
Hi Ian0,

Thanks for your reply
I need to measure the AC main voltage to control the motor for under-voltage and over-voltage

Reg: This IC ATM90E26
In my product was the very low price so if I use this kind ic I need to spend some more money
So, Kindly suggest me to improve my already circuit and remove the voltage spike
It is the general case that connecting the pin of an MCU to the mains without isolation will have various problems and will likely lead to a lot of failures of MCUs. A transformer to isolate the two is going to be the cheapest safe and reliable method.

Seriously, you are going to kill MCUs with this circuit.
 

Ian0

Joined Aug 7, 2020
1,567
Try the circuit with the opto and the zener.
If you need overvoltage detection as well, make two, one with a higher voltage zener so that it only gives out pulses if the mains exceeds the overvoltage threshold.

Depending on how clever your MCU is, you could determine an approximate value for the mains voltage by measuring the pulse-width using a timer.
 

Ian0

Joined Aug 7, 2020
1,567
It is the general case that connecting the pin of an MCU to the mains without isolation will have various problems and will likely lead to a lot of failures of MCUs. A transformer to isolate the two is going to be the cheapest safe and reliable method.

Seriously, you are going to kill MCUs with this circuit.
If the MCU's power supply is referenced to live or neutral, it should be OK. I have used MCU's with their 5V supply tied to mains live and a 1M resistor to neutral to generate the zero-crossing timing signal, just relying on the CMOS protection diodes for voltage limiting, with no significant failure rate.
EDIT: Just to add - this was in the days before surface mount, when resistors would withstand 500V.
 

Yaakov

Joined Jan 27, 2019
2,358
If the MCU's power supply is referenced to live or neutral, it should be OK. I have used MCU's with their 5V supply tied to mains live and a 1M resistor to neutral to generate the zero-crossing timing signal, just relying on the CMOS protection diodes for voltage limiting, with no significant failure rate.
Well, that's not a naive connection through a stack of resistors with an unknown supply. The TS is trying to reduce the parts count (cost) to less than what is needed to make this work reliably. Isolation is the most sensible use case here.
 

Ian0

Joined Aug 7, 2020
1,567
It is the general case that connecting the pin of an MCU to the mains without isolation will have various problems and will likely lead to a lot of failures of MCUs. A transformer to isolate the two is going to be the cheapest safe and reliable method.

Seriously, you are going to kill MCUs with this circuit.
However, If your MCU is referenced to mains earth, then someone before long with flash-test your product at 4kV, and some of that 4kV will end up in your MCU!
 

Yaakov

Joined Jan 27, 2019
2,358
However, If your MCU is referenced to mains earth, then someone before long with flash-test your product at 4kV, and some of that 4kV will end up in your MCU!
Often customers run destructive testing organizations even if they claim otherwise.
 

Irving

Joined Jan 30, 2016
1,141
1. Could you tell me where I should measure the AC main Voltage because I have to monitor the AC voltage from low to high voltage?
2. Could you tell me C1 is a capacitor dropper?

Note: I used a 15V AC transformer and convert it to DC after it goes to the regulator it converts 5V DC to give MCU power
#1 That circuit only reports if AC is there or not, it doesn't measure it (your original post said monitor not measure!). If you want to measure it then it depends if you want a go/no-go about a certain voltage or voltage bands - then use zener diodes eg in conjunction with my circuit to provide go/no-go above a certain voltage - or want an accurate measurement from 0 to 240v. For the latter, a transformer approach as suggested by @Ian0 will work, but beware the negative cycle as this could damage the MCU which only handles positive voltages. A simple op-amp configured as an ideal diode will work well here (let me know if you need more detail).

#2 C1 is indeed a capacitor dropper. It is chosen so that its impedance Zc = (peak AC voltage minus diode forward voltage)/diode forward current so Zc = (230 *1.4 - 2)/0.01 = 32000Ω, so C = 10E9/(2 π f Zc) nF = 10E9/(2 π 50 32000) = 99.5nF

As regards the comments above on direct AC connection - I personally would never have my MCU anywhere near the live AC terminal unless its a sealed environment with no external connections. For example I have an AC monitor that uses an ESP8266 and WiFi to report voltage and current. There is no external connection for a user to touch so in the event of a component failure its 100% safe. If I wanted to do that in a piece of equipment that has user controls I'd use a transformer or other isolation techniques...
 

Alec_t

Joined Sep 17, 2013
11,981
As a side-note, for simulating a 230V rms mains voltage in Spice your voltage source V1 should have 230 x 1.414 = 325 as the amplitude parameter.
 

Ian0

Joined Aug 7, 2020
1,567
For the latter, a transformer approach as suggested by @Ian0 will work, but beware the negative cycle as this could damage the MCU which only handles positive voltages.
2F25B66D-641C-44F3-8EC3-7CC0322F7F47.jpeg
This is a neat circuit to connect a transformer to a microprocessor A/D. It's neat because it biasses at exactly half supply, but only needs two different values of resistor.
For the popular Myrra 44199, 44200 and 44201 3.2VA encapsulated transformers
R1 = 30k R2 = 10k gives 1V rms output for 230V rms input on the 44199
R1 = 10k R2 = 2k gives 1V rms output for 230V rms input on the 44200
R1 = 39k R2 = 5.6k gives 1V rms output for 230V rms input on the 44201
Other 6V, 9V and 12V 3VA transformers will be about the same.
If you connect anything else (especially a rectifier and smoothing capacitor) to the transformer, the output will be wrong.
The split bobbin transformers are not phase-accurate giving some phase-lead due to the LR high-pass filter formed by Lmag and the primary resistance. If you want phase accuracy, use a toroid, such as the 1.6VA range by Nuvotem Talema.
 
Last edited:

Irving

Joined Jan 30, 2016
1,141
As a side-note, for simulating a 230V rms mains voltage in Spice your voltage source V1 should have 230 x 1.414 = 325 as the amplitude parameter.
Good point... I noticed earlier when showing the calculations that I'd used 230 in the simulation. Just couldn't be assed to go back and change it! Maybe I will now... ;)

edit: Fixed! means the diode forward current is now actually 10mA as intended rather than 8mA. Doesn't affect operation though.
 
Last edited:

Thread Starter

Balaji Krish

Joined Mar 31, 2021
22
@
View attachment 234546
This is a neat circuit to connect a transformer to a microprocessor A/D. It's neat because it biasses at exactly half supply, but only needs two different values of resistor.
For the popular Myrra 44199, 44200 and 44201 3.2VA encapsulated transformers
R1 = 30k R2 = 10k gives 1V rms output for 230V rms input on the 44199
R1 = 10k R2 = 2k gives 1V rms output for 230V rms input on the 44200
R1 = 39k R2 = 5.6k gives 1V rms output for 230V rms input on the 44201
Other 6V, 9V and 12V 3VA transformers will be about the same.
If you connect anything else (especially a rectifier and smoothing capacitor) to the transformer, the output will be wrong.
The split bobbin transformers are not phase-accurate giving some phase-lead due to the LR high-pass filter formed by Lmag and the primary resistance. If you want phase accuracy, use a toroid, such as the 1.6VA range by
View attachment 234546
This is a neat circuit to connect a transformer to a microprocessor A/D. It's neat because it biasses at exactly half supply, but only needs two different values of resistor.
For the popular Myrra 44199, 44200 and 44201 3.2VA encapsulated transformers
R1 = 30k R2 = 10k gives 1V rms output for 230V rms input on the 44199
R1 = 10k R2 = 2k gives 1V rms output for 230V rms input on the 44200
R1 = 39k R2 = 5.6k gives 1V rms output for 230V rms input on the 44201
Other 6V, 9V and 12V 3VA transformers will be about the same.
If you connect anything else (especially a rectifier and smoothing capacitor) to the transformer, the output will be wrong.
The split bobbin transformers are not phase-accurate giving some phase-lead due to the LR high-pass filter formed by Lmag and the primary resistance. If you want phase accuracy, use a toroid, such as the 1.6VA range by Nuvotem Talema.
Hi Ian0,

In my product is going sale at very cheap thus why we have not used transformer for measuring purpose

Thus why I made that resistor network to measure the AC main voltage

As you said, we are also using 44232 Myrra transformer for my main power supply
In that product, we use AC 230V to AC 15V converter using a 44232 Myrra transformer and split the power supply for MCU and LCD Backlight, So we cannot use two transformers in a single product. Thus why I measure to AC main voltage in a resistor network is cheap to compare transformer

If now measuring the AC main resistor network is working fine we can able to measure the value in MCU, But the problem is when I switch ON or OFF state it goes to a higher voltage for microsecond

So now if we arrest the voltage spike it better to measure the value in MCU
 
Top