Arduino Uno zero crossing detection circuit code

Input voltage from full wave retifier : 2.8V. Frequency : 60Hz. Diode used : 1N4005.

I am currently facing a problem that the output waveform only moves up and down instead of having a square wave with output high at zero.

Schematic? Probably doesn't matter. 2.8V is not high enough to be seen as valid High (need 3V for that in a 5V system) and a diode drop only makes it worse.

Your approach is all wrong. You should use a 4N35 opto coupler with a current limiting resistor for the input led. Calculate the resistor value based on the operating current of the opto from the datasheet. Put a 10k pullup resistor from the output collector to +5V and connect the output emitter to GND. Take your signal from the collector any arduino digital input.

Why is it all wrong? Okay, the 2,8V is to low but you don't absolutely need to use a opto... If you try to detect zero crossing at the secondary side of a transformer you can just skip the opto.

Hi, If you are using a full-wave rectifier, the unfiltered DC will have a ripple frequency of 120Hz. If you are using only 1 diode, you have a half-wave rectifier, the unfiltered DC will have a frequency of 60Hz.

I am currently facing a problem that the output waveform only moves up and down instead of having a square wave with output high at zero.

The waveform will indicate one zero crossing event when it GOES HIGH, and the other zero crossing event when it GOES LOW.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Tom... :)

You have to use a op amp to convert a sinewave to a squarewave. You can't do it with a single diode.

Even then you don't have to use an opamp. Just use a zener diode and a resistor.

AVR182

SEE PAGE 2

Just use a zener diode and a resistor.

I don't think a zener is going to give you a 50% duty cycle waveform. If you can do it and post a photo of the waveform that would prove it.

Why do you want a 50% duty cycle? As long as you can detect the crossing you’re fine. And indeed, the diode can be tossed f you use a high enough resistor. If powered from 12V AC (50Hz) you have a high <0,6ms after the zero crossing. But it is consistent so the calculation of the total period (of a full wave) is okay.

If that’s to crappy, add a transistor to the mix. Still less parts and reduces it to <0,15ms,

If the 2.7V is RMS AC, you can put a resistor divider across the input to a digital input and a capacitor between the source and the input. A 2K resistor to the actual input is a good idea for protection. Choose a combination of resistors and capacitor so that it has a long time constant relative to 60Hz but not so long that it takes 10 minutes to stabilize. You'll not be right on the zero cross because the inputs have a slight hysteresis. The best way is to use a voltage comparator chip. What do you want a zero cross for. Most people misuse them. Some think they are best to use with an inductive load. This is, in fact, the worst possible time to turn it on. One should turn on inductive loads at the peak voltage. Typical inductive loads are things like transformers. Turning them on at the zero cross will cause the highest current on the first cycle. High input surge loads should be turned on slowly. This can be done by waiting until the last part of the cycle and then working up the cycle to the full beginning of the phase. Dwight

Turning them on at the zero cross will cause the highest current on the first cycle.

This actually doesn't make any sense. Turning on an inductive load at zero crossing means the current will begin at zero and increase gradually with the current sinewave. There is nothing sudden about it.

http://www.te.com/commerce/DocumentDelivery/DDEController?Action=srchrtrv&DocNm=13C3206_AppNote&DocType=CS&DocLang=EN

Why zero crossing is not good for inductive load

Hmm...That's a surprise. I never heard of that before.

So then what do you recommend ?

A- A Triac switch with a peak detector and a delay of 4166 uS ? (ie an analog input with a 1 Mohm resistor on INT0 pin ? AVR182

Which one of these circuits would you recommend for the AC load switch ? Triac circuits

Thanks Wawa for finding the app note. It makes sense if you think about the continuous AC into an inductor. The current is 0 at the peak voltage and if you turn it on then, the voltage is decreasing while the the current is increasing. If you turn it on at zero cross, both are increasing at the same time.

I'd known about the problem but to add to the issue, you also need to turn inductive loads off a 0 current time as well. I had to turn off and on some 15 modular power packs in parallel. These were linear modules with input transformers. I was using what was said to be a zero cross SSR. After a few times power cycling, I'd lose the -15V out of one of the modular supplies. At first I thought it was a problem with the supplies and sent a couple back to the manufacture for analysis. I put a scope on the AC line to monitor how it was turning on, wondering if that was a problem. It was when I turned them off, I got the surprise. The line voltage went to 300V. It seems that the SSR use a MOSFET and diode bridge instead of a TRIAC to get peak voltage turn on when peak voltage, even if the current was zero. Where it turned off was anywhere in the cycle. Nothing special to be 0 current. The stored magnetic energy of 15 transformers had to go someplace. It was a weakest link problem. The negative regulators were the weakest and would blow out. Not having time to deal with the SSR manufacture, I added a heavy MOV across the power line and lived with the issue. Dwight

Maybe you could make a zero-crossing detector with a current limiting resistor from AC to analogue input. And two small schottky diodes anti-parallel from analogue-in to ground. R= 10k per volt (100uA). Read the input often, and detect value 0 or value >0. Leo..

Hi,

http://playground.arduino.cc/Main/ACPhaseControl

Tom... :)

Yes, optos isolation is needed to detect mains voltage zero crossing. But I think OP wanted to detect low voltage zero crossing. Leo..

Hi, Well the OP hasn't replied since posting the thread.

I'd like to know what the application is.

Tom.... :)

Since he wanted to watch a low voltage, I believe the circuit I mentions would work. A balanced resistor divider on the input and a capacitor to the low voltage AC input. Dwight

uncleeee: Input voltage from full wave retifier : 2.8V. Frequency : 60Hz. Diode used : 1N4005.

I am currently facing a problem that the output waveform only moves up and down instead of having a square wave with output high at zero.

Schematic?