# Zero crossing detector

Discussion in 'Embedded Systems and Microcontrollers' started by karan123, Jul 19, 2009.

1. ### karan123 Thread Starter New Member

Jul 19, 2009
8
0
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
------

2. ### mik3 Senior Member

Feb 4, 2008
4,846
63
Why do you need to divide the signal?

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

3. ### hgmjr Moderator

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

hgmjr

4. ### beenthere Retired Moderator

Apr 20, 2004
15,815
283
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.

5. ### karan123 Thread Starter New Member

Jul 19, 2009
8
0
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

6. ### karan123 Thread Starter New Member

Jul 19, 2009
8
0
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

7. ### millwood Guest

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.

8. ### millwood Guest

"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.

9. ### millwood Guest

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.

File size:
18.2 KB
Views:
111
10. ### karan123 Thread Starter New Member

Jul 19, 2009
8
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

11. ### karan123 Thread Starter New Member

Jul 19, 2009
8
0
Firsly,

I want to do calculation on Papar Only

then Practical Implement..

Karan

12. ### beenthere Retired Moderator

Apr 20, 2004
15,815
283
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.

13. ### millwood Guest

that would give you 40 UNEQUAL parts.

14. ### millwood Guest

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.

15. ### hgmjr Moderator

Jan 28, 2005
9,030
214
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

16. ### millwood Guest

the op wrote:
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.

17. ### hgmjr Moderator

Jan 28, 2005
9,030
214
My error. Indeed, an integrating function is called for to achieve this end.

hgmjr

18. ### millwood Guest

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.

19. ### hgmjr Moderator

Jan 28, 2005
9,030
214
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

20. ### millwood Guest

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.