# Zero crossing detector

#### karan123

Joined Jul 19, 2009
8
HEllo All,

I have to divide AC Signal 0 to 180 Degree in to
40 equal parts for Making ZCD or Zero Crossing Detector

But Condition is that,All parts having Same Area?

Can any Body Suggest me how to do that?

Karan
------

#### mik3

Joined Feb 4, 2008
4,843
Why do you need to divide the signal?

Just use a comparator IC with its one input tight to ground.

#### hgmjr

Joined Jan 28, 2005
9,029
One approach would be to use an AVR or a PIC microcontroller to do it. Have you considered such an approach?

hgmjr

#### beenthere

Joined Apr 20, 2004
15,819
Just to chime in - detecting a signal crossing ground may be done with a comparator, as Bertus has suggested. The detection of 0 volts can be made an input to the microcontroller to signal the zero crossing without further processing necessary.

We would be curious to know what the purpose of dividing the AC signal is.

#### karan123

Joined Jul 19, 2009
8
But
I have to use only 8051 uC without and Comparator
----.
So I have make uC based Fan Regulator up to 40 Values.
Equal Values means at Every step same proportion of energy with transferred to
Source.

I think Now i will be clear to you.

Karan

#### karan123

Joined Jul 19, 2009
8
But
I have to use only 8051 uC without any Comparator
----.
So I have make uC based Fan Regulator up to 40 Values.
Equal Values means at Every step same proportion of energy with transferred to
Source.

I think Now it will be clear to you.

Karan

#### millwood

Joined Dec 31, 1969
0
I have to divide AC Signal 0 to 180 Degree in to
40 equal parts for Making ZCD or Zero Crossing Detector

But Condition is that,All parts having Same Area?
the last condition means that if you were to use the voltage to charge up a capacitor, you should trip the mcu at the same voltage.

so apply the voltage to a capacitor, once the voltage reaches a certain threshold, discharge the capacitor and start again.

by varying the threshold, you can always divide the cycle in to how many equal parts you want, assuming that the signal itself is repeated.

#### millwood

Joined Dec 31, 1969
0
"I have to use only 8051 uC without and Comparator"

you don't need an (analog) comparator if you have an adc. you can use the adc as a digital comparator and use an interrupt to constant sample the voltage.

comparators are so last millennium.

#### millwood

Joined Dec 31, 1969
0
here is a quick hardware setup.

R1 limits the current going into the capacitor; the voltage across the capacitor is further attenuated by R2/R3 - you don't need them if you are sure of the upper voltage of the ac input.

the attenuated voltage is adc'd by the mcu and discharging is done by a mosfet across the capacitor.

#### karan123

Joined Jul 19, 2009
8
Sir,

Can u Guide me ,I want to do some paper work
How Mathematically I can divide AC Signal 0 to 180 Degree in to
40 equal parts.

Thanks ..

Karan

#### karan123

Joined Jul 19, 2009
8
Firsly,

I want to do calculation on Papar Only

then Practical Implement..

Karan

#### beenthere

Joined Apr 20, 2004
15,819
The signal frequency (F) gives the period by 1/F. One half of that period is the time for 180 degrees. Divide that by 40 and you have the time interval.

#### millwood

Joined Dec 31, 1969
0
The signal frequency (F) gives the period by 1/F. One half of that period is the time for 180 degrees. Divide that by 40 and you have the time interval.
that would give you 40 UNEQUAL parts.

#### millwood

Joined Dec 31, 1969
0
Sir,

Can u Guide me ,I want to do some paper work
How Mathematically I can divide AC Signal 0 to 180 Degree in to
40 equal parts.

Thanks ..

Karan
if it is perfect ac, and you know the frequency, all you need is to find delta, such that

int(sin(2*pi*f*t, for t=n*delta to (n+1)*delta)) = 1/40*pi

I am sure that's pretty solvable equation but my math is too rusty for me to do.

or you can do it numerically in excel.

#### hgmjr

Joined Jan 28, 2005
9,029
I guess the question is whether the goal is to divide the 0 to 180 degrees into equal angular intervals such as 180/40 degrees or are you interested in dividing the period/2 into 40 equal time slices.

My initial interpretation of the OP's request was that the goal was to divide the half-period into 40 equal time periods.

hgmjr

#### millwood

Joined Dec 31, 1969
0
I guess the question is whether the goal is to divide the 0 to 180 degrees into equal angular intervals such as 180/40 degrees or are you interested in dividing the period/2 into 40 equal time slices.

My initial interpretation of the OP's request was that the goal was to divide the half-period into 40 equal time periods.

hgmjr
the op wrote:
But Condition is that,All parts having Same Area?
that means the "area" under the sine curve is the same. which means the first area will last longer than the middle area.

to calculate the area, you need integration.

#### hgmjr

Joined Jan 28, 2005
9,029
But Condition is that,All parts having Same Area?
My error. Indeed, an integrating function is called for to achieve this end.

hgmjr

#### millwood

Joined Dec 31, 1969
0
My error. Indeed, an integrating function is called for to achieve this end.

hgmjr
ideally, you can do that buy charging up the cap with a current source whose current output varies with the voltage of the ac signal.

alternatively, you can introduce "output impedance" to the ac source by putting a large resistor in serial with the capacitor. the higher the resistor, the smaller the error from this approach.

#### hgmjr

Joined Jan 28, 2005
9,029
ideally, you can do that buy charging up the cap with a current source whose current output varies with the voltage of the ac signal.

alternatively, you can introduce "output impedance" to the ac source by putting a large resistor in serial with the capacitor. the higher the resistor, the smaller the error from this approach.
I have used both of these approaches to perform such an integration. I do tend to prefer the first approach for the accuracy it can bring to the integration.

hgmjr

#### millwood

Joined Dec 31, 1969
0
I have used both of these approaches to perform such an integration. I do tend to prefer the first approach for the accuracy it can bring to the integration.

hgmjr
it is indeed more accurate but adds some complexity. a slight compromise is to use a current mirror to isolate the two and let the ac (current) run through one leg of the current mirror and charge up the cap on the other leg.

But then you have to discharge the cap on the high side.

with a mcu, you can build-in correction through a look-up table so you may be able to achieve high accuracy without using a current source.