# zero voltage crossing detector

#### denison

Joined Oct 13, 2018
252
I have now tried the h11L1 and h11aa1 presumably zero crossing detectors. Both detectors give a long high pulse of about 1.9ms and low pulse of about 8ms for a 240vac 50hz supply. Pretty useless if you want phase control of the mains when a half wave is 10ms long.
I had designed my own zero crossing circuit which gives a low pulse of only .28ms. But the circuit is a little complicated so I was looking for something a bit simpler. The pulse length I measured with Arduinos pulse in function.
Has anybody got a nice simple zero cross detector or know of one which will give a short pulse at zero crossing similar to the pulse I get from my ZVC.

#### Sensacell

Joined Jun 19, 2012
2,917
My favorite

#### Attachments

• 667 KB Views: 50

#### Juhahoo

Joined Jun 3, 2019
250
Make a software delay to hit the exact zero crossing point, you only have to detect the edge and then constant delay.

#### Ian0

Joined Aug 7, 2020
3,756
If you calculate the percentage power at various phase angles
$$P=\frac{\int\limits_0^\pi\frac{V^2}{R}sin^2(t)dt}{\int\limits_\phi^\pi\frac{V^2}{R}sin^2(t)dt}$$
Substitute $$sin^2(x)=-\frac{1}{2}cos(2x)+\frac{1}{2}$$
and it gives
$$P=\frac{2}{\pi}(\frac{1}{2}(\pi-\phi)+\frac{1}{4}sin(2\phi))$$
where P is the fraction of the total power and φ is the trigger angle.

If your triac triggers when the zero crossing pulse ends 900μs into the cycle the output power will be 99.5% of full power, and if the pulse starts 900μs before the zero crossing, the power, if triggered at that point will be 0.5% of full power.

A further point - 900μs before zero crossing is a very good point to turn off the triac trigger, to make sure that it doesn't retrigger at the beginning of the next cycle.

#### Attachments

• 8.5 KB Views: 10
Last edited:

#### ericgibbs

Joined Jan 29, 2010
14,157
hi Sensacell,
For reference only, I thought you would like to see the LTSpice of your circuit.
Looks OK.
E
@Sensacell

#### Attachments

• 20.4 KB Views: 7

#### Ian0

Joined Aug 7, 2020
3,756
If your microcontroller can detect BOTH edges of the signal, then this circuit does the job with the fewest components, especially if you use a dual opto-isolator. (Turn the pull-ups off on the input)
The delay is about 400μs - i.e. the time between the actual zero crossing that the time the output signal goes below 0.8V on the way down and 2.4V on the way up.

Last edited:

#### Sensacell

Joined Jun 19, 2012
2,917

#### denison

Joined Oct 13, 2018
252
Make a software delay to hit the exact zero crossing point, you only have to detect the edge and then constant delay.

View attachment 245627
Yes you are right. You only have to detect the edge of the pulse. Then perhaps the simplest circuit is using the h11aa1 opto which doesn't need the diode bridge like the h11L1. I have used the Bristol Watch circuit here. The downside of this is the two 0.1uf mains capacitors required.

#### Attachments

• 1 KB Views: 10

#### denison

Joined Oct 13, 2018
252
If your microcontroller can detect BOTH edges of the signal, then this circuit does the job with the fewest components, especially if you use a dual opto-isolator. (Turn the pull-ups off on the input)
The delay is about 400μs - i.e. the time between the actual zero crossing that the time the output signal goes below 0.8V on the way down and 2.4V on the way up.
View attachment 245669
Hi Ian, A query on the capacitor. You have the Neutral line on one side and a microcontroller ground on the other side. Is that right? The capacitor size is a little blurry. Is that a 470pf capacitor and what voltage rating should it be? If its not a mains rated capacitor it is a better circuit than the one I may use. File attached. I could still use h11aa1 dual opto but without any mains rated capacitors. Is the capacitor needed at all in the circuit?

#### Attachments

• 1 KB Views: 7
Last edited:

#### Sensacell

Joined Jun 19, 2012
2,917
Hi Ian, A query on the capacitor. You have the Neutral line on one side and a microcontroller ground on the other side. Is that right? The capacitor size is a little blurry. Is that a 470pf capacitor and what voltage rating should it be? If its not a mains rated capacitor it is a better circuit than the one I may use. File attached. I could still use h11aa1 dual opto but without any mains rated capacitors. Is the capacitor needed at all in the circuit?
The capacitor reduces the power dissipation in the dropper resistor- BUT the capacitive coupling introduces a phase shift in the LED current, it's not around zero anymore.
The zero-crossing point will also not be very stable because the circuit lacks a hard switching point, the edge timing is dependent on the current, which slowly ramps through the switching point.

The switching point will also move with temperature, the capacitor coupling forms a high-pass filter, making it more sensitive to noise on the AC line.

Zero crossing detectors are actually very tricky to design, don't be fooled by simple circuits.
This is the master timing signal for your device, if it's flakey, the whole thing will be flakey.

Green is the current in the LED, Blue is the applied voltage.

#### Ian0

Joined Aug 7, 2020
3,756
Hi Ian, A query on the capacitor. You have the Neutral line on one side and a microcontroller ground on the other side. Is that right? The capacitor size is a little blurry. Is that a 470pf capacitor and what voltage rating should it be? If its not a mains rated capacitor it is a better circuit than the one I may use. File attached. I could still use h11aa1 dual opto but without any mains rated capacitors. Is the capacitor needed at all in the circuit?
The capacitor doesn't do anything except satisfy SPICE that the mains side is actually connected to something!
It sort-of represents the stray capacitances or class-Y capacitances that may be in circuit. Please ignore it (but SPICE likes it to be there)
And, no, you can't use H11AA1 because you need two output devices in a totem-pole arrangement - you need something like an ILD206.

Last edited:

#### Ian0

Joined Aug 7, 2020
3,756
The capacitor reduces the power dissipation in the dropper resistor- BUT the capacitive coupling introduces a phase shift in the LED current, it's not around zero anymore.
The zero-crossing point will also not be very stable because the circuit lacks a hard switching point, the edge timing is dependent on the current, which slowly ramps through the switching point.

The switching point will also move with temperature, the capacitor coupling forms a high-pass filter, making it more sensitive to noise on the AC line.

Zero crossing detectors are actually very tricky to design, don't be fooled by simple circuits.
This is the master timing signal for your device, if it's flakey, the whole thing will be flakey.

Green is the current in the LED, Blue is the applied voltage.

View attachment 245707
That's a perfectly fine circuit if you just want a mains frequency clock, but not if you want a zero-crossing detector. There is another problem you didn't mention - it varies with frequency.
The circuit that works on a 50Hz mains would trigger at the wrong place on a 60Hz mains; and if it were on a generator, it would be all over the place.
A comment on the AC-input optos: The CTR is not the same for both LEDs! If your output depends at all on the current tranfer ratio, it will be slightly asymmetric.

#### Sensacell

Joined Jun 19, 2012
2,917
The capacitor doesn't do anything except satisfy SPICE that the mains side is actually connected to something!
It sort-of represents the stray capacitances or class-Y capacitances that may be in circuit. Please ignore it (but SPICE likes it to be there)
And, no, you can't use H11AA1 because you need two output devices in a totem-pole arrangement - you need something like an ILD206.

I realized I was commenting on the wrong circuit- sorry!.

#### ericgibbs

Joined Jan 29, 2010
14,157
hi @Sensacell

Attached ZCD1 , LTS asc file.
Do you have the 4N35 model.?
E
BTW:
a BF=200 2N3904 transistor makes a little change
Tested with 110Vac 50Hz. OK
Note: the start up delay on the ZCD pulse stabilising

@Sensacell added 4N35.lib and asy , ask if you have a problem

#### Attachments

• 2.6 KB Views: 7
• 615 bytes Views: 3
• 1.1 KB Views: 3
Last edited:

#### Sensacell

Joined Jun 19, 2012
2,917
hi @Sensacell

Attached ZCD1 , LTS asc file.
Do you have the 4N35 model.?
E
BTW:
a BF=200 2N3904 transistor makes a little change
Tested with 110Vac 50Hz. OK
Note: the start up delay on the ZCD pulse stabilising
No, I don't have the 4N35 model- yes, please?

#### KeepItSimpleStupid

Joined Mar 4, 2014
5,090
@Ian0

It looks like someone else understands it.
Remember, you also have positive and negative voltage excursions, so you have to figure ou how that relates.

If your heating, "Power may not be quite right. For a resistive load, consider R a constant, so the on time table ihas phase angle and the integral (0 to PI) v(t)^2 normalized and 180-0 degrees. 180 degree firing is actually 0% or close too it.
But yea, you want % power kind of.

You can have tungsten loads (IR lamps) and you can have V loads (speed).

The normal thing is temperature control.

I do agree, that the zero cross detector isn't trivial to design. It also depends on mains frequency and that can vary a tiny bit.
So, you have that to worry about. you might have 60.1 Hz or 59.9 Hz.

What I don;t get is when your implementing say PID control and you have a device that actually does power control which has to be HARDER yet.

How to you implement Current limit? Power limit?

Not sure, but I think these controller use two back to back SCR's rather than a triac, so they can fire both at once to turn them off. i.e. current limit.

There is also line voltage compensation that likely would have to be handled.

I think it can get really messy.

Most controllers are not true power, but they can be,
They are proportional to V(t)^2 and do have current limit.
They may measure I.

they don't usually measure P and control P, but they can.
They don't usually have line voltage compensation, but they can.
they don't usually measure RMS of V(t) but can
They don't usually measure frequency, but can.

#### denison

Joined Oct 13, 2018
252
Make a software delay to hit the exact zero crossing point, you only have to detect the edge and then constant delay.

View attachment 245627
That is the problem detecting the edge. I have found Arduino can't pick it up. Try for instance a 220k dropping resistance to the h11aa1 opto. Here I measure a high of 2.4ms and low of 7.6ms. Measure the analog voltages at the output using 5v and 4,700 ohm resistance. The output voltages are all over the place.
My zvc detector measures low pulse lengths of about .28ms at zero crossing. So to start phase control I put in if the pulse length is less than 500 us then set phase control points.

#### ericgibbs

Joined Jan 29, 2010
14,157

#### denison

Joined Oct 13, 2018
252
I realized I was commenting on the wrong circuit- sorry!.
Got it Ian. I presume you have done a spice simulation of the circuit. What pulse length do you get? Even if you think you may have it right on ltspice it still may not work in Arduino. I will try the spice simulation of your circuit.