I'm doing a circuit that controls a charge for TRIAC, with zero detection. Whenever I tested the circuit, regardless of what I was sending from the microcontroller, TRIAC always sent all the current to the load.
When I looked at an oscilloscope for the detection of zero, I realized that it only detected zero once in a complete wave (not two). I researched the component I was using and noticed that the 4N35 only has one LED, so since I was not rectifying my wave before, it was only detecting the positive part of the wave.
I can not find any integrated circuit that has two LEDs in my city, so I decided to change the software. This is the function I have been using when it picks up the interrupt:
int dimtime = (65*dimming); // For 60Hz => 65
usleep(dimtime); // Wait for start TRIAC
digitalWrite(AC_LOAD1, HIGH); // Start TRIAC
usleep(8.33); // Delay TRIAC
digitalWrite(AC_LOAD1, LOW); // Turn off
This 65 came from: 1 full 60Hz wave = 1/60 = 16.6ms It will reach the zero point in: (60Hz) -> 8.3ms (1/2 cycle) 8,3ms = 8300us (8300us - 8.33us) / 128 = 65 (Approx) (and 128 was the amount of steps I split)
In my country, i have 220V and 60Hz for AC.
My question is: how can I change my code to control TRIAC by detecting zero only on the positive side of the wave? It is possible?
With this code by now, when i send 128, it simply lets the wave pass completely, and when I say 2, for example, the output wave goes out all "wrong", without following the AC wave.