So the sequence of events is:
1. SW1 is closed
2. PIC does some tests and flashes a LED on RA5
3. If the test passes, the relay is turned on.
Please confirm.
Questions:
1. Why do you need zero crossing to control the relay power?
2. The diode and two resistors are clearly not suitable and the PIC will almost certainly be damaged, if they are there just to sense voltage after SW1 is closed, why not use a conventional VDD/VSS connection as the PIC is controlling the relay anyway?
3. When you say you have "factored in" part of the AC waveform, are you saying you are trying to find the zero crossing point or trying to achieve some kind of phase control?
4. SW1 and SW2 seem to do almost the same thing, what specifically is SW2 for?
The comment about the Zener diode is to clip the voltage on RB4 to a safe level by adding it in parallel with the 200K resistor.
Brian.