Electronic – Zero-crossing detection

triaczero crossing

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.

Circuit

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.

Best Answer

There is no need for tricky software.

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 1. Replacing D2 with a bridge rectifier will turn on the opto-isolator on both positive and negative mains half-cycles.

Your 59k value for the current limiting resistor, R5, seems suspiciously low. You should check your calculations for this and the power rating. Most carbon or metal-film resistors are only rated for 200 V or so. Your 220 V mains will peak at \$ 220 \sqrt 2 \ \text V \$ so it is usual to use two series resistors to make up the required value.


schematic

simulate this circuit

Figure 2. A second 4N35 could be piggy-backed onto the existing one. Note that the LED terminals require a cross-over.