Author Topic: Mains Zero Crossing Detection  (Read 11507 times)

0 Members and 6 Guests are viewing this topic.

Offline BryanTopic starter

  • Frequent Contributor
  • **
  • Posts: 618
  • Country: ca
Mains Zero Crossing Detection
« on: February 17, 2021, 07:10:36 pm »
All:

For a project I am looking for a mains zero crossing detector, zillions of schematics out there, but I have read that only certain optocouplers are suitable due to the LED diode characteristics they are not true zero voltage detectors. Voltage drop of the LED is 1.2 to 1.6v. I suppose with a 120v mains it would not be that critical? . Anyhow any suggestions for a correct opto-isolator or am I down the wrong path and it doesn't matter.



-=Bryan=-
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 27489
  • Country: nl
    • NCT Developments
Re: Mains Zero Crossing Detection
« Reply #1 on: February 17, 2021, 07:13:03 pm »
Get rid of the bridge rectifier and use an optocoupler with anti-parallel LEDs
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline MikeK

  • Super Contributor
  • ***
  • Posts: 1314
  • Country: us
Re: Mains Zero Crossing Detection
« Reply #2 on: February 17, 2021, 07:27:46 pm »
Some PIC's have ZCD built in, you just need a current limiting resistor.
 
The following users thanked this post: tooki

Online Benta

  • Super Contributor
  • ***
  • Posts: 6081
  • Country: de
Re: Mains Zero Crossing Detection
« Reply #3 on: February 17, 2021, 07:36:47 pm »
If you want a real 0 V zero-crossing detector for 230 V, there's a lot more effort in it than what you've shown.

 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13872
  • Country: gb
    • Mike's Electric Stuff
Re: Mains Zero Crossing Detection
« Reply #4 on: February 17, 2021, 07:45:12 pm »
A problem with that circuit is fairly high power dissipation in the resistors.
Here is a better solution, which only fires the LED for a short pulse at the zero crossing
https://dextrel.net/design-ideas-2/mains-zero-crossing-detector.html
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 
The following users thanked this post: felixd, cellularmitosis

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 7299
  • Country: ca
Re: Mains Zero Crossing Detection
« Reply #5 on: February 17, 2021, 07:47:03 pm »
What aspect is important to your design? It's good to simulate these circuits.
With a 120VAC sine-wave, you get get a soft pulse about 2msec wide, +3V to -3V window considered "zero". It will vary with the opto and temperature. So it's not super precise, if you are doing phase-control. But is OK for clocks.
Using a low current opto-coupler 1mA (LED) really cuts down on the heat the dropping resistors dissipate.
« Last Edit: February 17, 2021, 07:49:46 pm by floobydust »
 
The following users thanked this post: Bryan

Online nctnico

  • Super Contributor
  • ***
  • Posts: 27489
  • Country: nl
    • NCT Developments
Re: Mains Zero Crossing Detection
« Reply #6 on: February 17, 2021, 08:31:54 pm »
Another approach is to make a HV diff probe (using a couple of resistors in series + differential amplifier) and feed the signal into the ADC of a microcontroller and do the zero detection in software.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 
The following users thanked this post: Bryan

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4604
  • Country: dk
Re: Mains Zero Crossing Detection
« Reply #7 on: February 17, 2021, 08:49:23 pm »
What aspect is important to your design? It's good to simulate these circuits.
With a 120VAC sine-wave, you get get a soft pulse about 2msec wide, +3V to -3V window considered "zero". It will vary with the opto and temperature. So it's not super precise, if you are doing phase-control. But is OK for clocks.
Using a low current opto-coupler 1mA (LED) really cuts down on the heat the dropping resistors dissipate.

compensating for the width of the windows should be easy in software, just measure the window width
 
The following users thanked this post: Bryan

Offline BryanTopic starter

  • Frequent Contributor
  • **
  • Posts: 618
  • Country: ca
Re: Mains Zero Crossing Detection
« Reply #8 on: February 17, 2021, 09:17:48 pm »
Project would mate to a Arduino, and the mains would be 120v. As I understand it as the LED would shutoff at below a certain voltage (~1.2) so there would not be a zero cross right at 0 and out by a small margin on the phase?

Do anti-parallel leds in a opto have a certain name or specification?
-=Bryan=-
 

Offline BryanTopic starter

  • Frequent Contributor
  • **
  • Posts: 618
  • Country: ca
Re: Mains Zero Crossing Detection
« Reply #9 on: February 17, 2021, 09:19:42 pm »
Any chance you could post the LTspice file?. the project I would not think is supercritical, ac motor control, but I am interested in understanding actually how these controllers work. The timing I suspect is not supercritical but a inefficient zero detection I would think would have an impact. And as others have posted, the correction could be taken into consideration in the software.
« Last Edit: February 17, 2021, 09:23:56 pm by Bryan »
-=Bryan=-
 

Offline kripton2035

  • Super Contributor
  • ***
  • Posts: 2658
  • Country: fr
    • kripton2035 schematics repository
Re: Mains Zero Crossing Detection
« Reply #10 on: February 17, 2021, 09:21:25 pm »
Do anti-parallel leds in a opto have a certain name or specification?
H11AA1
 

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2693
  • Country: us
Re: Mains Zero Crossing Detection
« Reply #11 on: February 17, 2021, 09:29:53 pm »
Project would mate to a Arduino, and the mains would be 120v. As I understand it as the LED would shutoff at below a certain voltage (~1.2) so there would not be a zero cross right at 0 and out by a small margin on the phase?
Yes, but the exact behavior depends on the optocoupler characteristics and line waveform.  LEDs, being diodes, don't have much of a VI curve, but they do have one, and you also have to consider the CTR (current transfer ratio) of the optocoupler, which means that the pulse shape and length at the output of the opto will depend on the loading of its output.  The pulse as received by a logic level input will also be offset based on the high-going and low-going thresholds of the input and the slop of the pulse edges.  Increasing LED current will sharpen the edges, but also increase power dissipation.  Distortion of the sine wave on the line due to non-linear loads (like the switching converters that are in everything, as well as motor loads and phase-dimmed lighting circuits) will muddy the waters here as well. 

Whether any of this matters for you depends on your application.  If you wanted to be really precise about it you might go so far as to wrap a PLL around the phase detection, but that's a bit extreme for a lot of applications.  A simple window to lockout spurious inputs is probably a good idea though.

Quote
Do anti-parallel leds in a opto have a certain name or specification?

Generally referred to as "AC Input" optocouplers.
 
The following users thanked this post: Bryan

Offline BryanTopic starter

  • Frequent Contributor
  • **
  • Posts: 618
  • Country: ca
Re: Mains Zero Crossing Detection
« Reply #12 on: February 17, 2021, 09:38:30 pm »
A problem with that circuit is fairly high power dissipation in the resistors.
Here is a better solution, which only fires the LED for a short pulse at the zero crossing
https://dextrel.net/design-ideas-2/mains-zero-crossing-detector.html

Here is a better solution, which only fires the LED for a short pulse at the zero crossing
https://dextrel.net/design-ideas-2/mains-zero-crossing-detector.html

Excellent article thanks for sharing.
-=Bryan=-
 

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 7299
  • Country: ca
Re: Mains Zero Crossing Detection
« Reply #13 on: February 17, 2021, 09:39:43 pm »
In OP's circuit, the detection window will vary with CTR, mains voltage, the MCU DI threshold so it's not ideal but is low component count.
The dextrel circuit has more components and is much better in many ways.

AC-input opto-couplers have built-in dual LED's and would save the need for a bridge rectifier in the original post. Example: PC814, H11AA814 and SFH628A or older H11A1.
 

Offline Cerebus

  • Super Contributor
  • ***
  • Posts: 10576
  • Country: gb
Re: Mains Zero Crossing Detection
« Reply #14 on: February 17, 2021, 09:52:43 pm »
You might want to take a look at this from EDN (https://www.edn.com/mains-driven-zero-crossing-detector-uses-only-a-few-high-voltage-parts/):



I've used variants of this style of circuit several times and it's reliable and accurate.

An LTSpice simulation of one of the variants I've built:





(The 1G resistors are just to let LTSpice work while retaining a 'floating' mains so that the neutral line isn't just a flat line.)

« Last Edit: February 17, 2021, 09:55:37 pm by Cerebus »
Anybody got a syringe I can use to squeeze the magic smoke back into this?
 
The following users thanked this post: felixd, floobydust

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4604
  • Country: dk
Re: Mains Zero Crossing Detection
« Reply #15 on: February 17, 2021, 10:10:47 pm »
In OP's circuit, the detection window will vary with CTR, mains voltage, the MCU DI threshold so it's not ideal but is low component count.
The dextrel circuit has more components and is much better in many ways.

AC-input opto-couplers have built-in dual LED's and would save the need for a bridge rectifier in the original post. Example: PC814, H11AA814 and SFH628A or older H11A1.

or you could use two optocouplers (or a dual)
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19749
  • Country: gb
  • 0999
Re: Mains Zero Crossing Detection
« Reply #16 on: February 17, 2021, 10:17:42 pm »
Some PIC's have ZCD built in, you just need a current limiting resistor.
That's only safe if it doesn't have to be isolated. I don't see why a special zero crossing detector is required. A simple comparator will do, which plenty of microcontrollers have.
 

Online langwadt

  • Super Contributor
  • ***
  • Posts: 4604
  • Country: dk
Re: Mains Zero Crossing Detection
« Reply #17 on: February 17, 2021, 10:32:11 pm »
Some PIC's have ZCD built in, you just need a current limiting resistor.
That's only safe if it doesn't have to be isolated. I don't see why a special zero crossing detector is required. A simple comparator will do, which plenty of microcontrollers have.

or just a gpio
 

Offline BryanTopic starter

  • Frequent Contributor
  • **
  • Posts: 618
  • Country: ca
Re: Mains Zero Crossing Detection
« Reply #18 on: February 17, 2021, 11:39:35 pm »
(The 1G resistors are just to let LTSpice work while retaining a 'floating' mains so that the neutral line isn't just a flat line.)

I had to look on Digikey to see if 1Gohm resistors were even such a thing...yup can go up to 500Gohm
-=Bryan=-
 

Offline Cerebus

  • Super Contributor
  • ***
  • Posts: 10576
  • Country: gb
Re: Mains Zero Crossing Detection
« Reply #19 on: February 17, 2021, 11:51:59 pm »
(The 1G resistors are just to let LTSpice work while retaining a 'floating' mains so that the neutral line isn't just a flat line.)

I had to look on Digikey to see if 1Gohm resistors were even such a thing...yup can go up to 500Gohm

Well, in spice you can go up to a teraohm with no difficulty. Obviously the way I've used them in spice is just to satisfy spice's desire to have a connection to ground before it'll simulate most circuits, they're not actually part of the design. In real life most high quality capacitor microphones have real 1G or even 10G resistors in them to bias the microphone capsule. There are other practical real world uses, but I'd bet most of the 1G+ resistors made end up in microphones, and most of the rest in test equipment and other similar instrumentation.
Anybody got a syringe I can use to squeeze the magic smoke back into this?
 

Offline fourfathom

  • Super Contributor
  • ***
  • Posts: 1920
  • Country: us
Re: Mains Zero Crossing Detection
« Reply #20 on: February 18, 2021, 03:18:53 am »
That zero-crossing detector is quite clever.  I was having trouble figuring it out until I re-drew the output portion.  I replaced the LED/resistor with just a resistor for simplicity:
We'll search out every place a sick, twisted, solitary misfit might run to! -- I'll start with Radio Shack.
 
The following users thanked this post: exe

Offline BryanTopic starter

  • Frequent Contributor
  • **
  • Posts: 618
  • Country: ca
Re: Mains Zero Crossing Detection
« Reply #21 on: February 18, 2021, 05:52:13 am »
I suppose I am interpreting the graph incorrect but doesn't it show that the rising edge of I(d6) at 30volts?
-=Bryan=-
 

Online joeqsmith

  • Super Contributor
  • ***
  • Posts: 11808
  • Country: us
Re: Mains Zero Crossing Detection
« Reply #22 on: February 18, 2021, 12:22:35 pm »
...
Whether any of this matters for you depends on your application.  If you wanted to be really precise about it you might go so far as to wrap a PLL around the phase detection, but that's a bit extreme for a lot of applications.  A simple window to lockout spurious inputs is probably a good idea though.
...

Good input.  Attached are a couple of articles. 


Online RoGeorge

  • Super Contributor
  • ***
  • Posts: 6527
  • Country: ro
Re: Mains Zero Crossing Detection
« Reply #23 on: February 18, 2021, 12:35:22 pm »
A problem with that circuit is fairly high power dissipation in the resistors.
Here is a better solution, which only fires the LED for a short pulse at the zero crossing
https://dextrel.net/design-ideas-2/mains-zero-crossing-detector.html

Built that one a couple of times and it worked very well, the pulse is symmetric around the zero crossing point.
« Last Edit: February 18, 2021, 12:39:20 pm by RoGeorge »
 

Offline Cerebus

  • Super Contributor
  • ***
  • Posts: 10576
  • Country: gb
Re: Mains Zero Crossing Detection
« Reply #24 on: February 18, 2021, 05:30:35 pm »
I suppose I am interpreting the graph incorrect but doesn't it show that the rising edge of I(d6) at 30volts?

Yes, if you look the pulse is centred around the zero crossing, with the component values chosen to make the pulse width ~1ms. It has a predictable and consistent delay (subject to the usual factors that effect drift in any analogue circuit, tempco of components etc.). One can adjust the component values to make the pulse narrower, subject to the capacitor holding enough charge to adequately drive the LED in an optocoupler.

That it comes before the zero crossing is no particular issue, a circuit that triggered exactly at the zero crossing would in practice, because of propagation delays, deliver the zero-crossing indication after the zero-crossing. Having the signal trigger slightly beforehand is actually an advantage for many applications - if you want to switch something at the zero crossing it's more useful to know that the zero crossing is coming up in ~500us rather than has just departed 100us ago. If you're using the zero-crossings just to measure the frequency of the mains you don't care about the delay either way as it's indication-to-indication timing that's of interest.
Anybody got a syringe I can use to squeeze the magic smoke back into this?
 
The following users thanked this post: Bryan, felixd, cellularmitosis


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf