Zero crossing detector using PIC

beenthere

Joined Apr 20, 2004
15,819
At the minimum, you will need to rectify the AC voltage. The A to D will be destroyed by a negative voltage. What is the magnitude of this voltage signal?
 

Thread Starter

rupinr

Joined Mar 2, 2011
3
At the minimum, you will need to rectify the AC voltage. The A to D will be destroyed by a negative voltage. What is the magnitude of this voltage signal?
Ok, I'm rectifying the voltage. But can you give me an algorithm to implement the zero crossing detector using PIC18F452??
 

John P

Joined Oct 14, 2008
2,025
If the incoming signal is referenced to the same ground as the processor, all you need is a resistor between the signal and the processor pin. The input protection diodes will, uh, protect the input. But then what you'd actually be detecting would be some voltage around 2V, and it might be different between rising and falling.

The base of a transistor would give you a transition point around 0.6V. Connect the collector to an input pin with pullup.

If you had the incoming signal come in through a resistor to an A/D pin, with another resistor providing bias to Vcc, you could use the A/D to tell when the input was at 0 (or above or below). So for 2 equal resistors, 0V would give you Vcc/2.

Or if the processor has a built-in comparator, use the same scheme as above but send the input to the comparator and drive the other input with Vcc/2. Then you could trigger an interrupt off the zero crossing.
 
Top