Hi,
Please give matching informations. If the schematic is not correct, then correct the schematic.
Otherwise it just causes confusions, when one refers to the schematic and the other refers to the text.
To me the schematic as well as the text is confusing.
Please add some informations to the schematic. I have no idea about voltages, what is AC, what is DC, what is a power supply, what is analog what is digital, what is input what is output. What is valid, what is invalid?
Someone has already made a circuit with pic that allows you to identify the moment when the AC mains voltage crosses the zero volt line.
Is it the given schematic? Which node?
I need to connect a relay and I don't know how to make the code,
There already is a relay. Can or do you want to use it?
There already is code. Your code? Which lines do you want to keep or modify? Why, how?
I will not use amplifiers, optocouplers.
What does that mean? There are no such devices...
The circuit is now ready, only pin 4 (RA3) of pic 12f1822 will be used, this is the photocell schematic, a correction, trimpot RV1 and RV2 is 100k, capacitor C2 is 5nF and zener diode Z1 24 volts, Z3 56 volts Z2 5 volts.
No idea what you want to tell.
****
Generally switching ON some load at zero cross reduces EMI.
On the other hand one does not want to switch ON inductive loads like transformers at zero cross, because this causes high inrush current due to core saturation.
So whether switching ON at zero cross makes sense or not depends on the load.
But "the load" something unknown ...
Is the load connected to the relay contacts?
If so, then zero cross switching makes no sense at all, because there is a lot of time delay between activating the relay coil and closing the relay contact.
The time is not very precise and varies with time, remanence, aging.. also contact bouncing will cause multiple "close and open" of the cintact.
Klaus