Chris

First of all - I'm a well out of date electronics engineer and only two years into hobby PIC programming. In no particular order, thoughts on your proposed project:

1. Sensing the crossings. Isolate the PIC/MCU and yourself from the mains voltage with a transformer. I don't know your level of electronic expertise (appologies in advance) but watch out for peak and RMS values. You want an AC voltage, for analysis by the PIC, with a peak to peak of 5 Volts.

2. I can't remember what phase change one gets across a transformer - but the zero crossing on the low voltage side may differ from the mains side?

3. Finding the zero crossing 120 times a second. If you use a PIC16F877A you will have the option of finding the crossing by A/D, comparators and so on. With a 20 MHz Xtal that is 5 instructions per microsecond or nearly 42,000 in one half mains cycle - sounds like enough to do lots of processing?

4. Recently, I was using Light Dependent Resistors and noticed that there was a 'mains hum' on the LDR. LDRs are not particularly fast or sensitive and a photo transistor would be better. How about:

a. Step down the mains voltage and drive an optocoupler chip (6N138 or something like it) via a current limiting resistor.

b. The LED in the optocoupler would only go ON for one half of the mains cycle - so you know which half it is.

c. On the output side you have an output that you can feed into the PIC.

d. use A/D or comparators, delays and so on to get the output signal you need.

Sorry, I've banged on. I'm told it goes with my age

Regards Bill Legge