Mains Voltage Versatile Detector

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I design a mains voltage (220V, 50Hz) detector to provide, via an optoisolator as 4N35, the real time status of the mains voltage to the MCU interrupt pin (as of ATmega8A that I got lately).

 

It should provide:

[1] The AC voltage polarity.

[2] Less than 0.5ms delay to signal the OFF state that may occur at any phase of the mains cycle.

[3] signal a low voltage limit (as being an off state, below it) with a suitable hysteresis (for restart).  

 

Naturally, it could also be used as a zero-crossing detector (at times when polarity is reversed).

 

My first topology worked on the LTspice simulator but I prefer testing it on a breadboard first before uploading its circuit file, so that I can be sure it works as expected.

 

Meanwhile, some of you who have already worked on such a detector may like sharing their experience on it.

Thank you.

 

Kerim

Last Edited: Tue. May 10, 2016 - 05:11 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Several thoughts:

 

The spec's are what the spec's are...

 

The spec's sited are significantly "harder" to meet than a typical UPS power supply.

If this was for a uC project, then one typically builds the uC's power supply to be able to handle a couple of mSec of lost Vin.

 

To detect within 0.5 mSec of Vin loss means that you have to track the Vin to detect the Vin dropping out of the expected Voltage range for that part of the cycle.

 

That is doable, but more involved that just detecting that the next 1/2 cycle didn't occur.

 

Is the project going to be attached to live Mains?

If so, then be very careful with your breadboard, and with your O'scope!

If that is the case then besides attenuating the Mains, you will need to level shift it for the ADC input, as the Tiny/Mega/Xmega ADC's don't accept negative voltages.

 

You will also have to voltage clamp and filter the Mains.

There are Many transients on the Mains, and you don't want to fry your input circuitry, or falsely trip your lost Vin detector.

The trade off, however, is that the filter might phase shift your Vin a few degrees.

Probably not an issue for this project, but still something to be aware of.

 

If you feed the Mains through a step down transformer then the Vin to your PCB is isolated, a very good thing.

It also, (arguably), makes the clamping easier.

With the opto on the output of the system, you now have TWO levels of isolation.  This is a good thing.

 

Regardless of your final approach, while working on the breadboard I would definitely use a step down transformer.

Use its output to feed the rest of your circuit while you work on your code and debugging.

 

Then focus on the live Mains input attenuator / filter once the rest of the project works as desired.

 

Standard Mains warnings apply.

Keep one hand in your pocket at all times.

Don't work on it when you are tired.

Keep the Mains circuitry away from everything else on your bench

Know that a mistake can be fatal.

 

JC

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you, JC, for your detailed reply and care.

 

It happened that the first controllers (using logic ICs in the 70's) that I designed for my small private business were for controlling light bulbs (220V) using triacs.

So the first thing I did is to supply my desk by 220V/220V isolating transformer so that the two hot lines on the desk are, practically speaking, floating and touching one of them is safe. I also added an autotransformer to vary the AC voltage when necessary.

But, as you said, one should be very careful when a test should be done with relatively high voltages.

 

I design this detector for a UPS inverter that I like to add as a new model to my actual quasi-UPS inverters (1000W/12V, 2000W/24V, 5000W/48V).

 

My first idea is to supply this small detector (consuming a couple of mA) by the Mains directly (voltage may be up to 250V, 50Hz), via a 2W resistor (with capacitors and zener... etc.).

The main controller board is isolated from the output of this detector thru 4N35 (opto-coupler).

 

The first trick in its design is to generate a relatively high frequency pulses (as 8 KHz, about 125us period) with a duty cycle D_C not equal to 50% (say 60%). When the polarity of the AC voltage changes, the pulses are inverted (by using a XOR gate, for example) making the duty cycle (1 - D_C = 40%). So the low state at the output of the 4N35 at the zero-crossing and in the worst case is about 125us.

 

The second trick is to stop the transmitted pulses at the exact moment of mains cut-off, also by using a XOR gate which is biased so that it changes its output state at near zero voltage of the mains.

 

Finally, by using a schmitt trigger gate as CD4093 (and with a feedback resistor to decrease its hysteresis range as necessary), the oscillator could be stopped at a certain low voltage of the mains and released at a higher voltage (the starting level).

 

So I use only two ICs: 74HC86 and CD4093 (because I already have a lot of them ;) ) in my circuit.

On LTspice, its first version works fine. But I believe, from my long experience in applying out of the box ideas in my designs, many better versions will follow it till it reaches its relative perfection (saturation, as in charging a capacitor) or it will be rejected/cancelled for one reason or another.

 

I am not able building its prototype (though simple) this week since I have other projects that I am working on and are more urgent.

  

Last Edited: Tue. May 10, 2016 - 10:01 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sounds like an interesting project.

 

If you end up using both a micro and discrete logic know that the XmegaE5 series has a programmable logic unit.

That may or may not save you some parts and board space.

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

KerimF wrote:

So I use only two ICs: 74HC86 and CD4093 (because I already have a lot of them ;) ) in my circuit.

 

Interesting approach, if you wanted to shrink this for volume production,  a 74AUP2G58 (MSOP10) should be able to operate at lower voltage, and do the Duty Cycle and pulse handling to a reasonable precision, and well under that 2mA power budget, & you can probably remove 'with capacitors and zener', and use the Opto VF to clamp-regulate the lower voltage logic supply.

 

Last Edited: Wed. May 11, 2016 - 03:57 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:

If you end up using both a micro and discrete logic know that the XmegaE5 series has a programmable logic unit.

That may or may not save you some parts and board space.

JC

 

Sorry, what about isolation (electrical)?

 

On the other hand, I can use ATmega8(A) only (Let us remember than engineers in the world don't have the same privileges ;) ) .

 

In the near past, I had AT89C2051 only to fulfil all special functions of the inverter/charger I produce; as slow start (by increasing the duty cycle), output Vrms regulation (for battery voltages greater than nominal), over battery-current protection, sensing the status of mains (and its voltage zero-crossings) and charging current regulation (by controlling the on-state phase of the active triac; there are 3 triacs).

 

But since I got ATmega8 now, new doors are opened for me to add new functions and update the previous ones with the advantage of using fewer parts and smaller board space. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you, Who-me, for your interesting hint.

 

Unfortunately, NXP doesn't allow me getting its datasheet of 74AUP2G58 (actually of any other one, so I see myself fortunate for being a member here ;) ). And getting special/new ICs is even harder from where I live and on these days. But I saved a note about it, just in case.