3
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ if mcu supports both rising and falling edge detection, no additional mods are necessary. at rise would detect first half-phase, at falling, the 2nd one. \$\endgroup\$
    – johnger
    May 20, 2018 at 22:41
  • \$\begingroup\$ if both edge detection is not possible, start a timer at first zcd, while overflowing at 8.3ms the 2nd half-phase software zcd will occur \$\endgroup\$
    – johnger
    May 20, 2018 at 23:29

3 Answers 3

7
\$\begingroup\$

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.

\$\endgroup\$
3
  • \$\begingroup\$ Yes, this is totally the best solution.. But believe it or not, this circuit is already on PCB (I dont know how, it worked for this first time in protoboard, but when i passed to pcb, didnt work anymore) So thats why im trying the "easiest" way possible to fix this. \$\endgroup\$ May 20, 2018 at 19:48
  • \$\begingroup\$ See the update. \$\endgroup\$
    – Transistor
    May 20, 2018 at 19:56
  • \$\begingroup\$ This is a great ideia! Thank you! I'll try there software one first, but if didnt work, this is the best one. Thank you very much! \$\endgroup\$ May 20, 2018 at 20:21
1
\$\begingroup\$

Triacs cannot be turned off through the gate. You can turn off the gate current but the Triac will only turn off itself as soon the holding current through the MT1-MT2 terminals passes the (current-)zero-crossing.

What you have to do in your interrupt routine is:

--- We are now at the zero-crossing from negative to positive

  1. Wait for the angle time
  2. Turn on the gate current
  3. Wait 100µs so the Triac could react to the gate current.
  4. Turn off the gate current
  5. Wait for the 8.33ms-angle time-100µs

--- We are now at the zero-crossing from positive to negative

  1. Wait for the angle time
  2. Turn on the gate current
  3. Wait 100µs so the Triac could react to the gate current.
  4. Turn off the gate current
  5. End interrupt.
\$\endgroup\$
2
  • \$\begingroup\$ @Janka There are Gate turnoff Triacs, they have existed for a long time. \$\endgroup\$ May 20, 2018 at 20:22
  • \$\begingroup\$ Gate-turn-off Triacs? Which ones? Gate-turn-off thyristors, sure. \$\endgroup\$
    – Janka
    May 20, 2018 at 20:29
1
\$\begingroup\$

Firstly there is nothing conceptually wrong with the circuit you have designed even though it only signals during the positive half cycle (there are however lots of practical problems with it).

The leading edge of your MCU signal is close to the zero crossing (x volts after it) on the positive half cycle and the trailing edge is close to the zero crossing (x volts before it) for the negative half cycle.

You could set up an interrupt to allow you to respond to either the 0-1 transition or the 1-0 transition into your MCU.

The biggest problem with your design is the very low operating currents you have chosen to set, which makes the design less than ideal.

Consider that for your design, Q1 needs to sink 500 uA (plus some unknown current to pull the MCU signal low, which I'll ignore), and that will require about 5 uA base current at the minimum Hfe of 100. The C-E current for the 4N35 is therefore around 6 uA. At this low current the CTR of the 4N35 is very low and likely only of the order of 0.1, so about 60uA of LED current required. This will mean the AC input voltage will be at about 4.5 V. This might be an acceptable voltage level for detection, but it will be very temperature sensitive and corrupted by the time it takes to charge C4 at these insanely low currents.

I'd challenge you to go through your design again and try to predict the trigger voltage required on the AC line over a temperature range of just 0-30 degC and with a range of BC547 and 4N35 characteristics. It won't be a nice picture.

I prefer a schematic like this based on a depletion mode FET to detect zero crossings reliably:

schematic

simulate this circuit – Schematic created using CircuitLab

With this type of detection you get the same trigger level for both positive and negative half cycles, and the trigger is always just after the zero crossing. You then only need to detect a single edge if you use interrupt detection.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.