Zero crossing detector for Arduino using 4N35 optocoupler

In summary: If the pulse is too short you could insert back to back zeners in series with the resistor to increase the off time. Because there is always a current path, the only HV will be across the resistor.I will try that. I also need to measure the zero crossing time. Do you know of any way to measure it?Yes, you can use a PIC timer with a 10 MHz oscillator to measure the zero crossing time.In summary,The designer is designing a zero crossing detector for Arduino using the 4N35 optocoupler. They are not yet sure if they will need to rectify the input to the optocoupler, but they are aware
  • #1
Wrichik Basu
Science Advisor
Insights Author
Gold Member
2,116
2,691
TL;DR Summary
Can the 4N35 optocoupler handle 6 VAC in its input, or do I need to rectify it to DC?
I am designing a zero crossing detector for Arduino using the 4N35 optocoupler. This is just a small part of a large project. I haven't bought the components yet, so do not ask me for readings. Everything is in the planning phase now.

My input will be a 6-0-6 transformer (220V to 6V step down).

I was having a look at this website where they have controlled an AC fan using an Arduino and a TRIAC. They have fed the 9 VAC output from their transformer directly to their 4N25 optocoupler:

1604828591246.png

In https://forum.allaboutcircuits.com/threads/zero-crossing-with-4n25-issue.138690/, they have first rectified the AC to DC, and then fed it to the optocoupler (don't look at the input; I will be using 6 VAC):

1604828679312.png

The above circuits use 4N25, but I believe using a 4N35 won't create any problem. Do I need to rectify the input to the 4N35, or can I directly feed it 6 VAC?
 
Engineering news on Phys.org
  • #2
Well, 4N24 and 4N35 both are with low reverse voltage for this, I think.
I would keep the transformer only, but put a LED in reverse, parallel with the opto.
Or a different opto, maybe with dual LEDs on the input side (something from here, for example).

I guess you are aware that it'll detect a time range around the peaks, not the crossings?
 
  • Like
Likes Wrichik Basu
  • #3
Rive said:
I guess you are aware that it'll detect a time range around the peaks, not the crossings?
Yes, I am aware of that. I need the time range around the peaks because I will be using that information to switch on a TRIAC for a short period of time, thereby dimming the appliance connected to the TRIAC. Similar to what has been said in the first website linked in the OP.
 
  • #4
It seems that if there is a safety isolation transformer, it may not be necessary to use an optocoupler, but certainly the optocoupler can serve as a secondary fault protection.

As mentioned in response 2, please make sure that the reverse input voltage does not exceed the rated value.

Wrichik Basu said:
Do I need to rectify the input to the 4N35, or can I directly feed it 6 VAC?

The rectified waveform is very different from the original sinusoidal wave waveform, so the two corresponding output waveforms are also very different. It depends on your design and the processing power of the Arduino hardware and software.
 
Last edited:
  • Like
Likes Wrichik Basu
  • #5
alan123hk said:
As mentioned in response 2, please make sure that the reverse input voltage does not exceed the rated value.
Yes, I will see to that. Maybe I will use a 5V transformer instead of 6V.
alan123hk said:
The rectified waveform is very different from the original sinusoidal wave waveform, so the two corresponding output waveforms are also very different.
That's what I was thinking about, and the two designs are basically not interchangeable. Thanks for the clarification.
 
  • #6
Wrichik Basu said:
Maybe I will use a 5V transformer instead of 6V
You have to work with the peak voltage instead of RMS
5V is still too much if you don't limit the voltage by some other means.
 
  • #7
Rive said:
You have to work with the peak voltage instead of RMS
5V is still too much if you don't limit the voltage by some other means.
Fine. Resistors are always handy in such cases.
 
  • #8
Be careful, serial resistors are no good for limiting maximal reverse voltage load.
 
  • #9
Rive said:
Be careful, serial resistors are no good for limiting maximal reverse voltage load.
Then how do I limit the voltage? (I can't seem to find a 5V transformer, so I have to use a 6V transformer.)
 
  • #10
The absolute maximum reverse voltage spec for the input LED is 6V. You can put in an anti-parallel diode to clamp this at about 0.7V. Read the data sheet for any IC you might use.
 
  • Like
Likes Wrichik Basu
  • #11
You might consider bi-directional opto-couplers like these too:
https://www.vishay.com/docs/83608/h11aa1.pdf

I think the whole HV side could be a resistor and a bidirectional coupler. If the pulse is too short you could insert back to back zeners in series with the resistor to increase the off time. Because there is always a current path, the only HV will be across the resistor.

You may find some with a darlington output which may allow you to have less power dissipation in the HV resistor. Like this: https://datasheet.octopart.com/IL755-1-Vishay-datasheet-10103.pdf
 
  • #12
DaveE said:
You might consider bi-directional opto-couplers like these too:
https://www.vishay.com/docs/83608/h11aa1.pdf
I am actually buying both types. I have to do some testing to see which one actually suits my case. My final aim is to use a triac as a dimmer — I will use a MOC3021 triac driver, and I need to detect the zero crossings because I will fire the triac driver accordingly for a dimming effect.
DaveE said:
You may find some with a darlington output which may allow you to have less power dissipation in the HV resistor.
The two websites from where I buy things don't have an optocoupler with darlington output.
 
  • #13
Wrichik Basu said:
The two websites from where I buy things don't have an optocoupler with darlington output.
Not even 4N33 et. al.? I thought those were everywhere. You could use two in parallel for full wave.
 
  • #14
DaveE said:
Not even 4N33 et. al.? I thought those were everywhere. You could use two in parallel for full wave.
4N35 is available, and it's already in my cart. H11AA1 is also available.
 
  • #15
The following snippet is from a 4N35 Vishay Datasheet (https://www.vishay.com/docs/81181/4n35.pdf)

1607017336798.png


Note that 6Vac is an rms value. The peak voltage would be at 6√2 = 8.485 Vpk. Note that we are talking of ac voltage, and based on your schematic:

https://www.physicsforums.com/attachments/273618

you will be subjecting your 4N35 to 16.97Vpk-pk. I suggest you put a bridge rectifier circuit at transformer secondary to limit the voltage to 8.485Vpk, and further lower the secondary peak voltage to less than 5V by doing a resistive voltage divider. The good news is that even with these modifications, the integrity of your pulse output is not compromised. it will still fire at the zero crossing.

P.S. i implemented a similar circuit to this in my college days for a friend.
 
  • Like
Likes Wrichik Basu
  • #16
maxwells_demon said:
Note that 6Vac is an rms value.
No! It is an instantaneous value. You won't see RMS voltage spec on a diode (maybe on a diode circuit, or application). RMS is only useful for AC signals and specifying an AC voltage limit on a diode is, at best, confusing. In any case the issue is damage to the PN junction which can happen very quickly.
 
  • #17
DaveE said:
No! It is an instantaneous value. You won't see RMS voltage spec on a diode (maybe on a diode circuit, or application). RMS is only useful for AC signals and specifying an AC voltage limit on a diode is, at best, confusing. In any case the issue is damage to the PN junction which can happen very quickly.

I meant 6Vac as the output of the transformer in the OP's schematic.

1607026857229.png


though now that i read it more carefully, OP did say:
Wrichik Basu said:
My input will be a 6-0-6 transformer (220V to 6V step down).

so it's basically a transformer with two secondary windings, only one of which would be connected to 4N35. So scrap what i said about 16.97V pk-pk. Though it still is 6Vac, and therefore 8.485V pk-pk.
 

Attachments

  • 1607026910343.png
    1607026910343.png
    19.4 KB · Views: 189
  • #18
Scrap the bridge rectifier, but the voltage divider is still necessary to bring that 8.485Vpk-pk down to 5Vpk-pk.
 
  • Like
Likes Wrichik Basu
  • #19
maxwells_demon said:
I meant 6Vac as the output of the transformer in the OP's schematic.
Yes, I see that now. Sorry, I misunderstood you! That was covered pretty thoroughly earlier in the thread.
 
  • #20
I am actually thinking of switching to H11AA1 instead of 4N35. My circuit is not yet complete, but am I correct in saying that the H11AA1 will detect a time around the crossing rather than the peaks?
 
  • #21
Wrichik Basu said:
I am actually thinking of switching to H11AA1 instead of 4N35. My circuit is not yet complete, but am I correct in saying that the H11AA1 will detect a time around the crossing rather than the peaks?
Either will work, it's just that the programming will be slightly different.

The 4N35 will be 'On' whenever the voltage is above about +1 Volt.
The H11AA1 will be 'On' when the voltage is above about 1 Volt of either polarity.

That's about 7 to 10 degrees from zero crossing.

For the 4N35 the coding would be:
Detect a change of input
If changed from 'Off' to 'On', a positive going Zero crossing just occured
If changed from 'On' to 'Off', a negative going Zero crossing is about to occur

For the H11AA1:
If is 'OFF' you are within 10 degrees of a Zero crossing in either direction

Cheers,
Tom
 
  • Like
  • Informative
Likes Wrichik Basu and sysprog
  • #22
Have you thought of using a MOC3041 zero crossing opto triac?
 
  • #23
MalcolmB said:
Have you thought of using a MOC3041 zero crossing opto triac?
I'm not sure this would help much. IIRC, he wants to make a phase angle dimmer circuit and needs zero crossing information to know when to turn on a thyristor, which will then self commutate at the zero crossing.
 
  • Like
Likes Wrichik Basu
  • #24
DaveE said:
I'm not sure this would help much. IIRC, he wants to make a phase angle dimmer circuit and needs zero crossing information to know when to turn on a thyristor, which will then self commutate at the zero crossing.
Exactly, you are right. 👍
 

1. How does a zero crossing detector work?

A zero crossing detector is an electronic circuit that detects when the input signal crosses the zero voltage point. It uses an optocoupler, such as the 4N35, to isolate the input signal from the output, and then uses a comparator to detect when the input signal crosses the zero voltage threshold.

2. Why is a zero crossing detector important for Arduino projects?

In Arduino projects, a zero crossing detector is important because it allows for accurate timing and synchronization of signals. It can be used to detect the zero crossing of an AC signal, which is useful for applications such as controlling the firing angle of a TRIAC for AC power control.

3. How do you connect a 4N35 optocoupler to an Arduino for a zero crossing detector?

To connect a 4N35 optocoupler to an Arduino for a zero crossing detector, you will need to connect the input side of the optocoupler to the AC signal you want to detect, and the output side to a digital pin on the Arduino. You will also need to connect a resistor between the output pin and ground to limit the current.

4. Can a 4N35 optocoupler be used for both AC and DC signals?

No, a 4N35 optocoupler is designed specifically for AC signals. It has a built-in diode that only allows current to flow in one direction, making it unsuitable for DC signals. For DC signals, a different type of optocoupler, such as the 4N25, would be more appropriate.

5. Are there any precautions to take when using a zero crossing detector with an Arduino?

Yes, there are a few precautions to keep in mind when using a zero crossing detector with an Arduino. It is important to use a resistor to limit the current on the output pin, as well as to use proper isolation techniques to protect the Arduino from any high voltages on the input side. It is also recommended to use a separate power supply for the optocoupler to avoid any potential interference with the Arduino's power supply.

Similar threads

Replies
7
Views
1K
Replies
4
Views
2K
Replies
5
Views
942
  • Electrical Engineering
Replies
10
Views
2K
  • Electrical Engineering
Replies
8
Views
1K
  • Electrical Engineering
2
Replies
63
Views
5K
  • Electrical Engineering
2
Replies
38
Views
3K
  • Electrical Engineering
Replies
1
Views
3K
  • Electrical Engineering
Replies
5
Views
3K
Replies
19
Views
2K
Back
Top