PDA

View Full Version : Zero-crossing detector?



RussMartin
- 9th August 2009, 03:18
Still with PBP and the 12F683.

I've read AN236 and AN521, and searched the forum. I'll have to admit, mains AC directly to a PIC pin, even with huge megohms in series, scares me, but I'm game to try it--assuming the '683 has the same clamping diodes on an input as the 16C5X and 16F87XA devices. (Being mistrustful, I may add external diodes . . . )

What is your preferred/recommended zero-crossing detection method--circuit and strategy and code?

I'm looking for (a) transformerless, (b) fewest components, and (c) simplest implementation.

Thanks!

4697
4698

Jerson
- 9th August 2009, 03:44
My preferred technique is to use a transformer to derive the 5V for my circuit. Use a votage divider to feed the raw stepped down AC to a pin on the PIC for zero cross detection. The code uses the zero cross interrupts to execute whatever it is that I need to do, like a phase control.

ardhuru
- 9th August 2009, 07:44
Still with PBP and the 12F683.

I'm looking for (a) transformerless, (b) fewest components, and (c) simplest implementation.

Thanks!

Since you're looking for a transformerless design, you have sacrificed isolation from the mains anyway. Go with the resistor directly to the pic approach. For increased safety, break up the resistor value into 3 series resistors.

Personally, I find the software easier to write if I have positive going transitions for each half-cycle. But to achieve this, you'd need to use an opto with 2 diodes in anti-parallel. I find the PC814 ideal for this.

Regards,

Anand Dhuru

RussMartin
- 9th August 2009, 18:13
Personally, I find the software easier to write if I have positive going transitions for each half-cycle. But to achieve this, you'd need to use an opto with 2 diodes in anti-parallel. I find the PC814 ideal for this.

Thanks for the suggestion! I had thought about using a garden-variety opto and getting half the cycle, but your idea is definitely better.

It looks as if, using the PC814, I could maintain isolation from the mains. If the output goes to a Schmitt trigger input on the PIC, that should do very nicely.

How do you factor the opto's diode drop (Vf) into the timing? I think I saw something about this in an article or app note but can't find it now.

amgen
- 10th August 2009, 02:32
I like to use isolation, cheap and reliable with ac opto coupler. AC opto gives + and - cycle detection with 1, 4-pin device and 2 resisters. can get pos or neg pulse at zero Xing.

don
amgen

RussMartin
- 10th August 2009, 05:00
Thanks, Don.

I placed a parts order earlier this evening, so I included a dozen of the PC814s.

Russ

ardhuru
- 10th August 2009, 06:39
It looks as if, using the PC814, I could maintain isolation from the mains. If the output goes to a Schmitt trigger input on the PIC, that should do very nicely.


Remember, since you want a transformerless supply, using an opto is still not going to give you mains isolation. BE CAREFUL!

Regards,

Anand

amgen
- 10th August 2009, 16:14
you are right, with no transformer, any part of your circuit could be 100 to 200 volts to ground since you can never be sure if the wall plug/receptacle is reversed, (a shock hazard). But that won't matter if no parts of your circuit are exposed to touch.
I made a nice simple Xformer-less supply for push button pic/fan timer that picks up a 10amp relay. Has worked well over a long time.

don
amgen

ardhuru
- 10th August 2009, 17:17
Thats a good circuit Don, but i'd also use a 47E resistor in series with the 0.1 uf cap.

Anand

RussMartin
- 11th August 2009, 07:58
I guess I wasn't very clear . . .

I don't need a transformerless power supply for the PIC circuit and associated glue; I was looking just for a transformerless zero-crossing detector.

sougata
- 11th August 2009, 08:37
Hi,

You can also use a NPN inverter from the rectified DC for sharper (inverted zero cross).

The Master
- 11th August 2009, 12:14
Recently ive been using this idea (http://www.marcspages.co.uk/tech/6103.htm). That page describes how to run an LED from the mains but with just the capacitor and resistor you can run an AC input darlington opto. Ive been using this method for detecting the presence of AC but it should work fine to detecting a zero crossing too.

I always use an opto for safety. I did try a huge resistor feeding directly into the PIC which seemed to work fine till i connected the PIC to my laptop through serial and the laptop turned itself off.

My prefered method is to use the 12V coming from the supply transformer. If you can use a transformer for the supply then you only need 2 extra diodes and a resistor to feed into the PIC.

As for the code, i dont like using oninterrupt but i do use the interrupt flags. The program doesnt have to check the interrupt after each command that way. It checks it when you want.

sougata
- 11th August 2009, 14:45
Hi,

The zero-cross sensing is mostly used for phase angle control. The Master The circuit you mentioned would essentially phase shift the zero cross signal.

BTW if you replace this idea (http://www.marcspages.co.uk/tech/6103.htm) with this idea (http://www.marcspages.co.uk/tech/?6103) then you get more ideas. Like this idea (http://www.marcspages.co.uk/?useframe)

Thanks to the author of the site and The Master

dhouston
- 11th August 2009, 19:02
I always use an opto for safety. I did try a huge resistor feeding directly into the PIC which seemed to work fine till i connected the PIC to my laptop through serial and the laptop turned itself off.For ZC, the resistor is adequate given the PIC has clamp diodes on the inputs. If you need mains isolation for RS232, use optos in the RS232 lines.http://www.pkfamily.com/users/solson/eeg/isoRS232.gif