On a positive halfwave you'll be trying to impose a positive gate current using 2.5V on the gate but having a high voltage on the lower anode (the motor is running and has its B-EMF). Since the MCU is fed by a supply referenced to neutral, this won't work, IMHO.
Yes, I forgot, the motor will act as a generator once running.
I'm not really experienced, but I think a little RC snubber would be a good thing there, since you don't know how current-voltage phase shift will be under all conditions.
This could be useful, I'll take a look, since I'd like to learn it too: http://www.st.com/stonline/books/pdf/docs/6785.pdf
Looks like a good idea but the trouble is, I've got no idea what the inductance of the motor is.
I'm now thinking about how to perform the zero crossing which I've never done with an MCU. The mains is connected to an input via a 1M resistor so I'll get a 50Hz pulse train. It seems pretty simple, all it needs to do is wait for pin 7 to change state (from high to low or low to high), apply a >20µs pulse to the TRIAC and repeat until the TRIAC needs to be turned off.
I realised one potential problem: on the falling edge the MCU will register a zero whilst the mains voltage is still slightly above zero so the trigger pulse will occur earlier than I would like. Here's my calculations which determine that it's not a problem, as long as the pulse is longer than 23.9µs but could someone please check them.
I'll be using 220V for the mains as it's the bottom end of the tolerance in my area.
v = instantaneous voltage
V
PK = peak mains voltage
t = time, in this case I'll be calculating the time for zero crossing to occur after the PIC has registered a zero.
F = frequency
V
OFF = the mains voltage when the MCU will register a low, which is 0.15V
DD = 0.15 * 2.5 = 0.375V
Theta = angle in
oV
PK = 220V sqrt(2) = 311V
v = V
PK sin Theta
Rearrange to make Theta the subject:
Theta = arcsin v/V
PK = arcsin (0.375/311) = 0.07
oTheta = F360t
Rearrange to make t the subject:
t = Theta/(360F) = 0.07/(360*50) = 3.9µs
So it the gate of the TRIAC is held high for >23.9µs it won't matter and the capacitor is more than large enough not to make any difference. I'll make the gate pulses 25µs just to ensure the TRIAC always triggers consistently.
I can't see an easy way to monitor the counter whilst doing zero crossing so I think I'll change the timer routines to use the mains frequency as it'll be more compatible with my zero crossing set up.