Author Topic: Isolated zero cross detection w/ AC mains  (Read 13211 times)

0 Members and 1 Guest are viewing this topic.

Offline iroc86Topic starter

  • Regular Contributor
  • *
  • Posts: 148
  • Country: us
Isolated zero cross detection w/ AC mains
« on: October 05, 2019, 12:24:29 am »
I'm working on a hobby circuit that requires an isolated zero cross detector based on AC mains voltage. I've seen this done many different ways, often using an optocoupler and full-wave rectifier. I've also seen transformers used to step down the voltage to something more reasonable, like 15 V, which is then fed into an op-amp or TTL switch. The latter approach seems to be more common when a transformer is already being used in a power supply, since the component is already there.

How do these two methods compare to one another? When would one be more suitable than the other? Is it ever common practice to combine both techniques, stepping down the high-voltage AC and then running that through an optocoupler? I know it's tough to make generalizations without seeing schematics, so I'm just looking for a rule of thumb.
 

Online coppice

  • Super Contributor
  • ***
  • Posts: 10034
  • Country: gb
Re: Isolated zero cross detection w/ AC mains
« Reply #1 on: October 05, 2019, 01:15:04 am »
Do you just want to see that crossing are occurring, or do you need a low latency means of detection so you can see the exact time of each crossing?
 

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 7678
  • Country: ca
Re: Isolated zero cross detection w/ AC mains
« Reply #2 on: October 05, 2019, 01:18:06 am »
What are you doing with zero-cross?
AC mains is always dirty, so you need transient protection and low pass filtering.
Any delay or phase-shift from a LPF or transformer needs to be corrected for.
Mains is high voltage so you need safe isolation unless your device is referenced to neutral.
 

Offline iroc86Topic starter

  • Regular Contributor
  • *
  • Posts: 148
  • Country: us
Re: Isolated zero cross detection w/ AC mains
« Reply #3 on: October 05, 2019, 02:20:04 am »
Sure, I can provide some more details. I'm using the zero cross detection to fire a solid state relay for a certain number of AC waveform periods. The zero cross will be used to determine the starting point and then count a number of full cycles. I don't need this to be super accurate, but within 5% of a period would be good... I'm in the US, so that'd be around 1 ms for 60 Hz.

Thanks for the reminder about transients and filtering, floobydust. Many of these DIY circuits on the Internet don't take that sort of thing into account.
 

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 7678
  • Country: ca
Re: Isolated zero cross detection w/ AC mains
« Reply #4 on: October 05, 2019, 05:41:18 am »
A textbook method is an opto-coupler fed from mains. But this is highest cost and risk as far as wiring and the opto's pcb traces. You have to be mindful of proper clearances for mains.
Assuming your project is powered from a small transformer, it's easiest to use the secondary AC as the transformer did all the work of safely lowering and isolating mains for you. There is a small phase-shift due to the transformer but you can check with a scope if it is significant. Zero-cross switching SSR's can trigger above 20V so they are a little late already.

You need an even number of 1/2 cycles so the big transformer core does not saturate and many examples (fig.3a) show it's best to switch in on the AC peak, not at zero cross, to have lowest inrush current by exploiting the transformer's inductance.

https://www.electronics-lab.com/project/mcu-controlled-spot-welder
Zero Crossing Detectors and Comparators - Rod Elliott (ESP)

Your firmware should trigger on a zero cross and ignore anything for almost 1/2 cycle say 7-8 msec, as any incoming zero-cross in that interval is going to be noise, unless you initially have triggered on noise. I wasn't sure if you are only counting cycles, or also doing phase-control for start or control.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13216
Re: Isolated zero cross detection w/ AC mains
« Reply #5 on: October 05, 2019, 06:34:51 am »
Errr.... Where did the O.P. say the load is a transformer?

However if you are switching a *LARGE* resistive load, its also a good idea to keep positive and negative half-cycles balanced, to avoid any risk of saturating the utility company's pole pig if you are the only active consumer on it.
 

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 7678
  • Country: ca
Re: Isolated zero cross detection w/ AC mains
« Reply #6 on: October 05, 2019, 08:25:29 pm »
I assumed OP is doing spot-welding, the application is unknown and that is the only place I have seen cycle-counting used.

Large resistive heaters (many kW) don't seem to use cycle-counting PWM because the thermal time-constant is huge. I find they use many seconds on, many seconds off for proportional control. Even a kiln or air heater has a many second time-constant to heat up the element. There is further science comparing "nucleate poolboiling and film boiling local to the heaters" I think if fluid circulation is poor, where you'd want higher PWM (carrier) frequency.

I remember a high kW electric (water) heater standard mentioning the PWM freq. limits, as far as to not upset the power grid's voltage regulation on tap-changers.
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 28429
  • Country: nl
    • NCT Developments
Re: Isolated zero cross detection w/ AC mains
« Reply #7 on: October 05, 2019, 08:31:36 pm »
Sure, I can provide some more details. I'm using the zero cross detection to fire a solid state relay for a certain number of AC waveform periods. The zero cross will be used to determine the starting point and then count a number of full cycles. I don't need this to be super accurate, but within 5% of a period would be good... I'm in the US, so that'd be around 1 ms for 60 Hz.

Thanks for the reminder about transients and filtering, floobydust. Many of these DIY circuits on the Internet don't take that sort of thing into account.
How about using a solid state relay with a zero cross detection built-in? That way you just turn it on for the duration of N cycles and be done with it.

Otherwise I'd use this:

I've used this circuit in a (one off) design but I still need to test it.
« Last Edit: October 05, 2019, 08:38:40 pm by nctnico »
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline iroc86Topic starter

  • Regular Contributor
  • *
  • Posts: 148
  • Country: us
Re: Isolated zero cross detection w/ AC mains
« Reply #8 on: October 05, 2019, 10:42:48 pm »
Ah yes, you all guessed correctly--this is for a pulsed spot welder. Didn't mean to hold back info to begin with, but I wanted to keep my request as generic as possible for applicability to other situations :). This controller will be attached to a Miller LMSW 220 V spot welder which had its main transformer rewired as per the 110 V model. The extra current was too much for the thin nickel material being welded. Even so, it's interesting to think about the resistive load scenario.

floobydust and Ian.M, I didn't consider balancing the half-cycles to avoid saturation. An earlier version of my welder used a monostable 555 timer (no zero cross detection) to pulse the output through a solid state relay, and the weld quality was often inconsistent. One of my goals with the new design is to improve the weld repeatability. I wonder if the variation was due to de-energizing the welder transformer in mid-cycle.

nctnico, I didn't know there were SSRs with built-in zero cross detection--that's pretty cool! That would be an easy solution, although I'm probably going to continue with the separate detector for educational purposes. With the schematic you posted, what about including some MOVs on the input side? I see that you're already implying fusing with the "L_FUSED" hot line.

Your firmware should trigger on a zero cross and ignore anything for almost 1/2 cycle say 7-8 msec, as any incoming zero-cross in that interval is going to be noise, unless you initially have triggered on noise. I wasn't sure if you are only counting cycles, or also doing phase-control for start or control.

I had planned on some phase control to test various welding scenarios, although switching on the peak, as you mentioned, is probably the best bet. I mostly need to ensure that full cycles are outputted to the welder. I actually wanted to avoid using time delays in the controller and rely entirely on the line frequency to dictate the start/stop sequence based on the number of cycles requested by the user. I figured I could double the frequency from the zero cross detector to catch the wave at a peak instead of a cross. Then, send that back to the control circuit and count the number of periods until the preset limit is reached. (Not that this'll ever be used outside of 60 Hz, but there's a certain elegance in a feedback loop. :))

So, going back to the original question of transformer vs. optocoupler for zero cross detection, it seems that both options are doable and have different pros/cons. I will probably use a sealed AC-DC converter to power the controller, so using a transformer "because it's already there" may not be an option. However, as flooby mentioned, a straight opto would require some additional consideration for the PCB design due to the high voltage. This is a one-off design, and cost isn't a big deal, so I'm leaning towards the separate xformer+opto solution and just account for any phase shift as necessary. Thoughts on that idea for this particular application?

FYI, you've all given me some good ideas to think about. Thanks!
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8526
Re: Isolated zero cross detection w/ AC mains
« Reply #9 on: October 05, 2019, 11:30:34 pm »
"It depends how much isolation you need"...

A lot of designs I've seen for detecting the crossing of the mains uses nothing more than a high-value resistor chain.
 

Offline glentek

  • Regular Contributor
  • *
  • Posts: 56
Re: Isolated zero cross detection w/ AC mains
« Reply #10 on: October 06, 2019, 08:38:06 pm »
What I used in a 1200W battery charger years ago"

Mains to 2x 33k 1W resistors in series, 400V 1A bridge rectifier, 4N28 opto isolator
 

Offline beduino

  • Regular Contributor
  • *
  • Posts: 137
  • Country: 00
Re: Isolated zero cross detection w/ AC mains
« Reply #11 on: October 06, 2019, 09:56:51 pm »
Mains to 2x 33k 1W resistors in series, 400V 1A bridge rectifier, 4N28 opto isolator
Mains 230VAC or 110VAC?
 

Offline glentek

  • Regular Contributor
  • *
  • Posts: 56
Re: Isolated zero cross detection w/ AC mains
« Reply #12 on: October 07, 2019, 12:06:16 am »
Mains to 2x 33k 1W resistors in series, 400V 1A bridge rectifier, 4N28 opto isolator
Mains 230VAC or 110VAC?

This was for 240vac.
 

Online wraper

  • Supporter
  • ****
  • Posts: 17952
  • Country: lv
Re: Isolated zero cross detection w/ AC mains
« Reply #13 on: October 07, 2019, 12:14:16 am »
Otherwise I'd use this:
(Attachment Link)
I've used this circuit in a (one off) design but I still need to test it.
It's easier to use optocouplers specially made for AC. Like H11AA1

 
The following users thanked this post: ebclr, Ian.M

Offline beduino

  • Regular Contributor
  • *
  • Posts: 137
  • Country: 00
Re: Isolated zero cross detection w/ AC mains
« Reply #14 on: October 07, 2019, 10:45:38 am »
It's easier to use optocouplers specially made for AC. Like H11AA1
Isn't those 33k resistors too low for 230VAC? It looks like something around 0.4W loses on each of them?

I've used for 230VAC 4 x 100k - (2x 100k in parallel) x 2 in series, so 2x 50k, then we have something like: 0.00115^2*100000 ~ 0.132W losses on each of 100k resistors.
BTw, I've used two PC817 to have configuration similar H11AA1, but in this case I could detect on two pins not only zero crosing but also which part (top/bottom) of sine wave which might be sometimes helpfull in some applications.
« Last Edit: October 07, 2019, 10:48:19 am by beduino »
 

Online wraper

  • Supporter
  • ****
  • Posts: 17952
  • Country: lv
Re: Isolated zero cross detection w/ AC mains
« Reply #15 on: October 07, 2019, 12:32:48 pm »
It's easier to use optocouplers specially made for AC. Like H11AA1
Isn't those 33k resistors too low for 230VAC? It looks like something around 0.4W loses on each of them?

I've used for 230VAC 4 x 100k - (2x 100k in parallel) x 2 in series, so 2x 50k, then we have something like: 0.00115^2*100000 ~ 0.132W losses on each of 100k resistors.
BTw, I've used two PC817 to have configuration similar H11AA1, but in this case I could detect on two pins not only zero crosing but also which part (top/bottom) of sine wave which might be sometimes helpfull in some applications.
You calculate power loss. But do you even consider current and power through optocoupler? 100k in series means 0.23 2.3 mA RMS current through emitter LED which BTW has forward voltage of only 1.2 V. For example H11AA1 has minimum 20% CTR. If you want to use higher resistance resistors, you would need to use otocoupler with higher CTR like H11AA4.
« Last Edit: October 07, 2019, 11:26:15 pm by wraper »
 

Offline schmitt trigger

  • Super Contributor
  • ***
  • Posts: 2431
  • Country: mx
Re: Isolated zero cross detection w/ AC mains
« Reply #16 on: October 07, 2019, 02:08:18 pm »
Otherwise I'd use this:
(Attachment Link)
I've used this circuit in a (one off) design but I still need to test it.
It's easier to use optocouplers specially made for AC. Like H11AA1



Ditto for using the H11AA1. It makes life simpler.

Also since it has a base connection, you may want to experiment with a small capacitor (C <15 pF) to ground, to reduce noise susceptibility which as others have noted, is prevalent around the zero crossings.
 

Offline beduino

  • Regular Contributor
  • *
  • Posts: 137
  • Country: 00
Re: Isolated zero cross detection w/ AC mains
« Reply #17 on: October 07, 2019, 11:19:27 pm »
I've used for 230VAC 4 x 100k - (2x 100k in parallel) x 2 in series, so 2x 50k, then we have something like: 0.00115^2*100000 ~ 0.132W losses on each of 100k resistors.
BTw, I've used two PC817 to have configuration similar H11AA1, but in this case I could detect on two pins not only zero crosing but also which part (top/bottom) of sine wave which might be sometimes helpfull in some applications.
You calculate power loss. But do you even consider current and power through optocoupler? 100k in series means 0.23 mA RMS current through emitter LED which BTW has forward voltage of only 1.2 V.
Maybe someone of us missed orders of magnitude of RMS current, so lets do the math with two 51k resistors in series (51000 Ohm 1W I've used in mains zero crossing three pin probe shown below):

(230VAC-1.2Vf)/(2x51k)= 0.002243 A ~2mA  :-DMM

In this DIY probe below I've used mentioned 2xEL817 with its input diodes in antiparallel of course,so I'm capable sense near zero crossing to positive and negative part of mains sinewave if needed thanks to three pins instead of two  8)
I use MPU in my spot welder, so I can compensate for zero cross based on logic analyser output from this probe and hall effect current sensing pure resistive load during the tests  :-/O



UPDATE: Of course mains connection shown above is not only hot black glued, but additional insulation put first on those exposed mains wires brown and blue, so do not try this unless you know what you are doing  :-BROKE
« Last Edit: October 07, 2019, 11:24:11 pm by beduino »
 

Online wraper

  • Supporter
  • ****
  • Posts: 17952
  • Country: lv
Re: Isolated zero cross detection w/ AC mains
« Reply #18 on: October 07, 2019, 11:39:13 pm »
Maybe someone of us missed orders of magnitude of RMS current, so lets do the math with two 51k resistors in series (51000 Ohm 1W I've used in mains zero crossing three pin probe shown below):

(230VAC-1.2Vf)/(2x51k)= 0.002243 A ~2mA  :-DMM
Yes I messed up one decimal place. Still 2 mA with 20% CTR (=0.4 mA) sucks, especially for zero cross. Optocoupler reacting only to peak voltage is not very helpful for accurately detecting zero cross. There is not always ideal sine waveform in mains to allow you to accurately calculate zero cross from that. Ideally you want it to turn off only as close as possible to zero voltage. Also one need to consider that if it works now, does not mean it will work over time. Optocoupler CTR tend to degrade and one should consider that when designing things.
 

Offline beduino

  • Regular Contributor
  • *
  • Posts: 137
  • Country: 00
Re: Isolated zero cross detection w/ AC mains
« Reply #19 on: October 07, 2019, 11:58:07 pm »
Still 2 mA with 20% CTR (=0.4 mA) sucks, especially for zero cross. Optocoupler reacting only to peak voltage is not very helpful for accurately detecting zero cross.
When we use 33k instead of 51k we get ~3.5mA instead of ~2mA, so is it much better use 33k instead of 51k?
In the case of 51k we get ~0.5W power disipation on both resistors, so ~0.26W per resistor - I used 1W resistors anyway.


There is not always ideal sine waveform in mains to allow you to accurately calculate zero cross from that.
Yep, so that is why I use MPU to calculate average period instead of making decisions only based on zero cross pin state, so hopefully also filtering some noisy zero crosses in software.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13216
Re: Isolated zero cross detection w/ AC mains
« Reply #20 on: October 08, 2019, 02:36:30 am »
Here's an idea that gives you one pulse per AC cycle on the falling zero crossing.  It doesn't give you the rising zero crossing, but that's not a problem if you have a MCU doing the phase control.  It only presents a 1 Meg load to the line, but stores charge to slam the optocoupler LED with a 50mA pulse for a nice sharp output rising edge.



Its also got input filtering to remove fast transients, but the phase shift (lag) due to the filtering is approximately compensated for by triggering early, at about +13V.   Its setup for 240V, 50Hz operation.  The filtering would need to be tweaked for 60Hz and/or 120V operation to maintain the compensation.

LTspice sim attached.
« Last Edit: October 08, 2019, 02:42:33 am by Ian.M »
 
The following users thanked this post: SeanB, edavid, schmitt trigger, iroc86

Offline eliocor

  • Supporter
  • ****
  • Posts: 531
  • Country: it
    • rhodiatoce
 
The following users thanked this post: Miyuki, schmitt trigger, soldar, iroc86

Online coppice

  • Super Contributor
  • ***
  • Posts: 10034
  • Country: gb
Re: Isolated zero cross detection w/ AC mains
« Reply #22 on: October 08, 2019, 11:06:34 am »
https://web.archive.org/web/20150226043505/http://www.dextrel.net/diyzerocrosser.htm
That circuit looks OK, but "all components can be low voltage SMD" in the features list is wrong. Use low voltage 220k resistors for R1 and R2 and you'll be in trouble, especially with 240V mains. Most small SMD resistors are only rated for 50V. You need to either use high voltage resistors, or split the 220k into multiple smaller resistances, and make sure you lay out the board to keep them from arcing across in a surge test.
 

Online wraper

  • Supporter
  • ****
  • Posts: 17952
  • Country: lv
Re: Isolated zero cross detection w/ AC mains
« Reply #23 on: October 08, 2019, 11:32:42 am »
https://web.archive.org/web/20150226043505/http://www.dextrel.net/diyzerocrosser.htm
That circuit looks OK, but "all components can be low voltage SMD" in the features list is wrong. Use low voltage 220k resistors for R1 and R2 and you'll be in trouble, especially with 240V mains. Most small SMD resistors are only rated for 50V. You need to either use high voltage resistors, or split the 220k into multiple smaller resistances, and make sure you lay out the board to keep them from arcing across in a surge test.
If you go with 1206 size for those, you should be fine with general purpose resistors.
 

Online coppice

  • Super Contributor
  • ***
  • Posts: 10034
  • Country: gb
Re: Isolated zero cross detection w/ AC mains
« Reply #24 on: October 08, 2019, 01:35:09 pm »
https://web.archive.org/web/20150226043505/http://www.dextrel.net/diyzerocrosser.htm
That circuit looks OK, but "all components can be low voltage SMD" in the features list is wrong. Use low voltage 220k resistors for R1 and R2 and you'll be in trouble, especially with 240V mains. Most small SMD resistors are only rated for 50V. You need to either use high voltage resistors, or split the 220k into multiple smaller resistances, and make sure you lay out the board to keep them from arcing across in a surge test.
If you go with 1206 size for those, you should be fine with general purpose resistors.
Even 1206 resistors are only rated for 200V. Two of those gives you a 400V rating. The peak of a 264V sine wave (upper bound of 240V mains) is 373V, so they are marginal best, with no allowance for harmonic peaks or surges.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf