Hi JS,
Did not understand what you meant by how it works ? the zero crossing is detected by the H11AA1 and the scope is probed on pin5 of it which goes to pin4 on the ATmel.
[...]
Moving a pin - you mean move it detect on another pin ?. There is actually two pulse the pic shows the first pulse.
nope no simulation and did not understand the last paragraph
...
Thanks guy for the answers.
You are probing your analog signal, that way you know how the H11FF1 works, nothing about how fast the µC responds. Make an ISR when the µC detects the zero crossing and with it write a pulse in an output pin. Then time the difference between one signal and the other, or even better, the actual zero and the µC output. That is the time you have as delay, it should be short enough it doesn't represent a problem working at 120 pulses/second, from the 60Hz mains, but is good to be sure.
About how it works I'm referring to the timing, once you have enough data to do the timing between the analog and digital behavior, that behavior should be consistent. Note that there isn't any more info in plotting 12 pulses than just 2, but when plotting 2 pulses you can see much better what's going on, also you should use some markers one the sine wave to compare how well you are timing from it to the pulses.
I hope that clears the digital part a bit, for the power handling, which was the last paragraph all about. When working with inductive loads, the thing to be carefull about is when you switch off, since it kicks back as a mule, trying to keep the same current raising in voltage as much as is needed to do so, a 5V relay can kick several times those 5V if disconnected without using the protection diodes. When you are working on AC you can't just hook up a diode to solve this, so it's easier to just switch when the current is low enough so the kickback isn't a problem. Good luck the triac doesn't turn off till the current is low enough, so using a triac solves that by it self, you only need to be little careful. If you go to the datasheet of the triac you are using you will see the typical application circuit (Figure 13 in the link) which has 2 extra resistors and 2 caps that the one resistive load doesn't need. For the turn on, there are no spikes for voltage or currents with an inductive load, the transient of the inductor will take care of that, for capacitive loads you could have a huge current spike, look at the initial charge of a filtered rectifier.
http://www.mouser.com/ds/2/149/MOC3023M-196223.pdf You would probably still need some trial and error to see the optimal times for your interrupts to trigger the triac, it will depend on how inductive the inductive load it is, for resistive loads the fastest you turn it on (as far as the holding current is reached) the higher the voltage in the load. If the load is only inductive, the zero crossing current will be at the peak of the voltage, so you need to trigger after that to have the holding current, also the triggering pulse should be longer (than a resistive load) as the inductive load will take longer to reach the holding current.
You still have the problem of your load changing as what you are doing with the other side, the load with the secondary open will be very inductive, the load with the secondary shorted (while soldering) will be very resistive. Maybe is a good idea to sense the zero crossing in current, maybe both.
JS