Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

AC mains fail and zero crossing detector

Status
Not open for further replies.

djc

Advanced Member level 1
Advanced Member level 1
Joined
Jan 27, 2013
Messages
402
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
India
Visit site
Activity points
4,554
HI all,

I want an AC mains fail detection circuit with zero crossing detector. I searched and found an optocoupler circuit. But how to employ zero crossing detector circuit? A rectified DC will be fed to optocoupler LED to get the unsmoothened DC output. How to proceed then.
 

Optocoupler based zero crossing circuits all work in the same way, first use full-wave rectified AC so you maintain the same polarity of half cycles. Then, using suitable current limiting you feed the UNsmoothed voltage to the LED in the optocoupler. This makes it flash, off when the AC is near zero crossing point (below Vf) and on for the remainder of the cycles. The output of the optocoupler is therefore pulses at and close to the zero voltage point.

Vf of the LEDs inside optocouplers is typically around 1.6V which means you get a zero crossing indication between -1.6 and +1.6V of the cycle. It is at the steepest part of the waveform so it will be quite a short pulse but if you need even greater accuracy, consider using the rectified AC to bias a transistor and it's collector current to drive the optocoupler LED. This makes the circuit a bit more complicated because you may need an isolated DC supply as well but it will reduce the zero crossing pulse to around -0.6V to +0.6V.

Brian.
 

Thanx bet,

2nd option seems to be complicated one. I am thinking of using first option. However i am confused that how to detect the power failure. Initially i thought of generating an interrupt for time period (50Hz *2.25) pulses, so that whenever interrupt occurs i wil have the maximum value of ADC, but if mains is not there, ADC read will be zero. But this seems to be wil not work, becoz AC mains frequency is changing in nature so time period for which ADC read is zero will vary. Is there any other way?
 

That seems a complicated way to do it. I wouldn't use an ADC at all unless you need to analyse the mains waveform for some other reason. The easiest way is to use the zero crossing pulses to hold a monostable in reset state. If you set the monostable period to a little more than half mains cycle period it will detect a mains failure in less than one cycle. You can make to period longer of course to make it less senstive to interference at the expense of reaction time. The monostable can be in hardware or software.

If you are measuring the AC mains voltage, bear in mind that there is a direct relationship between RMS and peak voltage so you can rectify it, filter it then scale the resulting DC to be measured by an ADC. It is much easier than trying to sample the waveform and mathematically determine the voltage.

Brian.
 

Hi brian,

Could you please suggest me a logic in C language for zero crossing detection using ADC. I am stuck on that. COuldn,t find reasonable logic yet.
 

I wouldn't use an ADC for zero crossing detection, this is why:

1. You have to attenuate then add a DC offset to the AC so it's positive and negative peaks fall within the range of the ADC.
2. You have to measure the lowest ADC voltage and highest ADC voltage to find their average
3. You have to measure the DC offset (or know it precisely) so you can subtract it from the average.
4. You have to detect when the voltage from step 3 is zero - that is the crossing point.
5. You have to use the crossing detection to reset a timer which will 'time out' after one or more cycle periods have elapsed.

To get any degree of certainty you must sample the ADC and do the math as quickly as possible. The crossing point acuracy depends on you sampling at exactly the maximum and minimum points of the waveform, bear in mind that most ADC are relatively slow to return results.

If you use a digital signal as I suggested in post #2 you do not need steps 1 to 4, you just use the pulse generated by the ZCD hardware to reset the timer. It is MUCH easier that way.

Brian.
 

Thanks for the quick reply brian

However I have been tod to use ADC only. I have no other option instead of using ADC.
 

Kindly refer microchip's application note AN1279 it has got all the details it includes software logic and schematic. Please refer mains sensing section. If you are not able to find AN1279 kindly inform I will post it.
 

I understand. I did not realize you were instructed to use the ADC, in a real application it would not be the first choice.

There are two ways you can do it, the first is as I described in post #6 where you calculate where the zero crossing is within the waveform but if you can use a bridge rectifier and opto-coupler it is much easier.

Full-wave rectify the AC so you have half-sine waves of the same polarity. You can then either measure the voltage directly using the ADC or you can use the unfiltered waveform to power the LED side of the opto-coupler. How you detect zero crossing is like this:

Direct measurement method.
Use a loop in you software, try to avoid any delays so it repeats as fast as possible. Read the ADC each pass of the loop until the reading is zero. This will occur at each zero crossing point. As your ADC will probably have +/- 1 count potential error, it might be best to assume the crossing point is reached when the ADC reading is < 2 rather than zero.

Opto-coupler method.
Do the same except this time the ADC voltage will normally be zero (+/- 1 count) and it will suddenly go to full voltage as the LED is not lit because the AC voltage is below that needed to light it. In this case a high voltage indicates zero crossing is reached. The high voltage will be whatever you use to power the transistor side of the optocoupler.

Brian.
 

Kindly refer microchip's application note AN1279 it has got all the details it includes software logic and schematic.
Thanx nikhil, I got it. Will read it now.

Hi brian.
Yes i am going to use opto coupler method and have been told to compare each value with previous value and divide unregulated DC sine wave in 30 parts for zero crossing detection. I thought about direct value of ADC. However what could be the logic behind method i been told.
 

I understand what you have been asked to do, but the method doesn't make sense.
The output of the optocoupler will be digital anyway which is why I don't thnk the ADC method is worthwhile. If you only sample 30 times per cycle (every 12 degrees) your crossing detection could be unreliable by up to 3.3%, doing it digitally would be far more accurate.

Brian.
 

Kindly refer microchip's application note AN1279 it has got all the details it includes software logic and schematic. Please refer mains sensing section. If you are not able to find AN1279 kindly inform I will post it.
 

If you have an AC signal of suitable amplitude and use a full wave rectifier or use exclusive OR logic on successive delayed samples the transition will produce a zero crossing spike. YOu can choose any polarity of that spike by design in analog or digital and then use it to send pulses to triacs etc. A brown Out or black out condition is better detected by the peak threshold timeout rather than the zero crossing This again can be analog or digital.

Noise or hysteresis filtering may be necessary.
 

Thanx sunny,

However i won't be allowed to increase hardware anymore.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top