On Thursday 21 October 2004 11:19 am, Steve Willoughby wrote: > I am designing a PIC circuit which needs to stay synchronized > with the AC line's zero-crossing point. I want to arrange things > so that the PIC gets an interrupt every time the AC voltage > crosses 0V. > http://home.quixnet.net/xyzzy/ee/zccomp.gif Try a 10k resistor on pin3 of diodebridge to a capacitor (to prevent spike problems), then from the cap, connect directly to the pin via a 100k resistor. don't measure the rising edge because you are also charging your 5v capacitors for your circuit, therefore introducing non-linear crossings. Measure the "trailing edge 5V -> 0v because at this point there is always "no-load" on your charging circuit, therefore your voltage coming from the transformer is always going to cross at the same point in time. Use your math skills to figure-out approximately when it reaches about 2.5v, you will notice it happens rather early in the sinewave considering you are using only an 8v sinewave (you probably had trouble finding the 0v rise due to 0.7v being a significant percentage of 8v too versus 0.7v across 110v which happens rather soon). Now that you have done the math to figure out when 2.5v dropping to 0v happens, you can add a "time delay" in software to give you the exact zero crossing.... (don't forget that you are not dealing with an 8v sinewave, but one that is 8v - 1.4v due to diode drops of full wave bridge. The rest is up to you :-) _______________________________________________ http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist