Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

zero crossing detector using pic16f877a

Status
Not open for further replies.

adilsarwar123

Newbie level 3
Newbie level 3
Joined
Jan 9, 2010
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,303
can i give 230 volts sine wave directly to the RB0 pin of pic16f877a with high resistor in series to to know the zero crossing point on the sine wave form. what will be the code for that?
 

Not quite, if you do that you can only detect if the half cycle is positive or not.

Use a bridge rectifier, the waveform from it will then have a detectable zero on both half cycles. You still need to use software to detect the start and end of voltage appearing at the PIC pin. You will get slightly better results if you feed the voltage through a high value resistor into the base of an NPN transistor. Connect its emitter to ground and its collector to the PIC input. Add a pull-up resistor of about 10K between the collector and the PIC supply line. The transistor will conduct when the AC reaches about 0.6V above zero, without it the PIC will not detect voltages until they reach about half the supply voltage.

You can use RB0 to generate an interrupt at zero crossing.

Note that most small resistors are only rated to withstand 250V and the peak of 230V RMS is about 325V so use at least two resistors in series so they share the voltage drop.

Brian.
 
Hi adilsarwar123,

Of course, you can do that with edge triggered interrupt on RB0. You need to toggle the interrupt type each time you enter the ISR, ie, if a rising edge occured on RB0, then make the interrupt type falling edge triggered and vice versa.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top