1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Zero Crossing Detector for 220V 50Hz

Discussion in 'Microcontrollers' started by zahiy, Mar 23, 2009.

  1. zahiy

    zahiy New Member

    Joined:
    Apr 29, 2008
    Messages:
    7
    Likes:
    0
    Location:
    Zahi Jihad Younis, Arara - Palestine
    Hello,

    anybody can help me find a good circuit for zero crossing detector for 200V/50Hz signal? I prefer a circuit without transformer. I am going to use its output to be an input signal for PIC16f877 microcontroller. it is a light dimmer project.

    I tried to google around but all I could find is an analog light dimmers!

    Thanks,
     
  2. Ubergeek63

    Ubergeek63 Well-Known Member

    Joined:
    Apr 16, 2008
    Messages:
    1,886
    Likes:
    37
    what is your power source? if it is a generic transformer bypass the and clamp one of the output leads from the transformer to a PIC input pin
     
  3. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,791
    Likes:
    134
    Location:
    morristown,tn
    You no how a dimmer works it phase shifts. That why when you Google you got dimmers.
    A dimmer fires the trac at a off set of the
    pic microchip has and appnote telling all about how to make a dimmer with a pic 12f508 you hook one lag of the mains with a 20 Mohm resistor to RA 4 and the pic can read it when it zero crosses so you could use that part to read your zero crossing. I have tried it with a 18f1220 and it worked. I'll post the appnote when I find it.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,791
    Likes:
    134
    Location:
    morristown,tn

    Here this will hook you up http://www.electro-tech-online.com/custompdfs/2009/03/40171a.pdf
     
  6. zahiy

    zahiy New Member

    Joined:
    Apr 29, 2008
    Messages:
    7
    Likes:
    0
    Location:
    Zahi Jihad Younis, Arara - Palestine
    Thank you guys for the quick and useful respones,

    Ubergeek63, if I understood you well, my power source is independed regulated +5V,


    be80be, this microchips note is has been designed specifically for PIC12C508, in my case, I am using PIC16F877, I don't think it has the same feature! anyway I think I am going to continue your work and find something similar but using the 16F877 in microchips notes..
     
  7. zahiy

    zahiy New Member

    Joined:
    Apr 29, 2008
    Messages:
    7
    Likes:
    0
    Location:
    Zahi Jihad Younis, Arara - Palestine
    By the way, I found out the the PIC16F877 has two comparator, I can compare the AC signal with 0V and find the change point, now the problem is, how can I compare 220V!! it two much voltage to handle!
     
  8. Ubergeek63

    Ubergeek63 Well-Known Member

    Joined:
    Apr 16, 2008
    Messages:
    1,886
    Likes:
    37
    Then you do not have access to the actual power supply.

    To sense the zero crossing you need access to the power rail and it is much safer if you do not have to actually touch it.

    BTW if you just put a FET inside a bridge rectifier you can PWM a regular lamp without access to the zero crossing...
     
  9. tresca

    tresca Member

    Joined:
    Apr 11, 2004
    Messages:
    194
    Likes:
    2
    Location:
    Canada
    • Like Like x 1
  10. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,791
    Likes:
    134
    Location:
    morristown,tn
    From the data sheet for a 16f877 all potrA
    It will read it to. The code is for 12f508 but the theory is for most any pic. The way it works is the pin reads high till the zero crossing then it will go low.And the pic can catch that.
     
  11. zahiy

    zahiy New Member

    Joined:
    Apr 29, 2008
    Messages:
    7
    Likes:
    0
    Location:
    Zahi Jihad Younis, Arara - Palestine
    if PORTA pins on the 16F877 have protection diodes, so problem is solved! I am going to test it soon.

    tresca, it is similar to the microchips appnote, thanks!
     
  12. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,791
    Likes:
    134
    Location:
    morristown,tn
    RA3:RA0 AND RA5 PINS Is what the datasheet said. Just don't use ra4 like with 12f508
     
    Last edited: Mar 23, 2009
  13. be80be

    be80be Well-Known Member

    Joined:
    Aug 23, 2008
    Messages:
    4,791
    Likes:
    134
    Location:
    morristown,tn
  14. zahiy

    zahiy New Member

    Joined:
    Apr 29, 2008
    Messages:
    7
    Likes:
    0
    Location:
    Zahi Jihad Younis, Arara - Palestine
    Well, after lots of tests as you guys adviced me. I have connected 1M resistor on the hot main and another 1M on the Zero main as the example on the AVR PDF. it worked PERFECTLY!

    with the code bellow it shows me HIGH on PORTB when the AC is positive and LOW when the AC voltage is negative:

    I can detect zero when there is a change from positive to negative or negative to positive, I also want to HIGH PORTB 1ms when the crossing is been detected this is what I did:


    The oscilloscope gives me a wonderfull pulses marking the zero cross' result but it last for a few seconds the all what I get is zero on the oscilloscope !!!

    have anybody faced this problem before?

    I am using 16F877A 8MHz PORTA.0 220V

    Thanks.
     
  15. VicBSEE

    VicBSEE New Member

    Joined:
    Jan 7, 2010
    Messages:
    3
    Likes:
    0
    MOSFET inside Bridge?


    Could you please give more information on this? Across what two pins is the MOSFET connected inside the bridge? Interested in learning more about this

    Thank you
     

Share This Page