Zero crossing detector using PIC

Discussion in 'Embedded Systems and Microcontrollers' started by rupinr, Mar 7, 2011.

  1. rupinr

    Thread Starter New Member

    Mar 2, 2011
    Any idea to detect zero crossing of a voltage signal using PIC 18F452.:)
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    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?
  3. bertus


    Apr 5, 2008
  4. rupinr

    Thread Starter New Member

    Mar 2, 2011
    Ok, I'm rectifying the voltage. But can you give me an algorithm to implement the zero crossing detector using PIC18F452??
  5. blueroomelectronics

    AAC Fanatic!

    Jul 22, 2007
    Put it on an interrupt pin such as INT0.
  6. John P

    AAC Fanatic!

    Oct 14, 2008
    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.
    adityanag likes this.