Power Control (Dimmer): Lamp flashes intermittently.

Hello guys.

I am Paulo, Brazilian and I am facing a problem related to power control (dimmer).

I am using this tutorial as a reference: Controle PID de Potência em Corrente Alternada - Arduino e TRIAC - Parte III

My circuit is equivalent to this (Fixed the gnd of pin 3 of the MOC 3020):

In the test my circuit controls a simple bulb (60W / 127V AC). However, for several moments, the lamp flashes intermittently.

This is my sketch test (But I used the same sketch as the tutorial above and the result was the same):

#include <TimerOne.h>

#define trigger 4

volatile int power = 100;

void zeroCrossing() {
    // Cálculo do ângulo de disparo: 60Hz-> 8.33ms (1/2 ciclo)
    // (8333us - 8.33us) / 256 = 32 (aprox)
    int powertime = (32 * (256 - power));
    // Mantém o circuito desligado por powertime microssegundos
    Timer1.initialize(powertime);
}

void shot() {
    // Envia sinal ao TRIAC para que ele passe a conduzir
    digitalWrite(trigger, HIGH);
    // Espera alguns microssegundos para que o TRIAC perceba o pulso
    delayMicroseconds(8.33);
    // Desliga o pulso
    digitalWrite(trigger, LOW);
    // desativa o timer que foi ativado na funcao zeroCrossing.
    TCCR1B = 0x00;
}

void setup() {
    pinMode(trigger, OUTPUT);
    Timer1.attachInterrupt(shot);
    // Inicializa interrupção. O número zero indica a porta 2 do Arduino,
    // zeroCrossing é a função que será chamada toda vez que o pino 2
    // "subir" (RISING) de valor de 0 para 1
    attachInterrupt(0, zeroCrossing, RISING);
}

void loop() {
    power = 10;
    delay(3000);
    power = 120;
    delay(3000);
    power = 240;
    delay(3000);
    power = 120;
    delay(3000);
}

In parallel, I performed a second test, removing the delays from the sketch and declaring a fixed value for power. Follow sketck:

#include <TimerOne.h>

#define trigger 4

volatile int power = 120;

void zeroCrossing() {
    // Cálculo do ângulo de disparo: 60Hz-> 8.33ms (1/2 ciclo)
    // (8333us - 8.33us) / 256 = 32 (aprox)
    int powertime = (32 * (256 - power));
    // Mantém o circuito desligado por powertime microssegundos
    Timer1.initialize(powertime);
}

void shot() {
    // Envia sinal ao TRIAC para que ele passe a conduzir
    digitalWrite(trigger, HIGH);
    // Espera alguns microssegundos para que o TRIAC perceba o pulso
    delayMicroseconds(8.33);
    // Desliga o pulso
    digitalWrite(trigger, LOW);
    // desativa o timer que foi ativado na funcao zeroCrossing.
    TCCR1B = 0x00;
}

void setup() {
    pinMode(trigger, OUTPUT);
    Timer1.attachInterrupt(shot);
    // Inicializa interrupção. O número zero indica a porta 2 do Arduino,
    // zeroCrossing é a função que será chamada toda vez que o pino 2
    // "subir" (RISING) de valor de 0 para 1
    attachInterrupt(0, zeroCrossing, RISING);
}

void loop() {    
}

In both cases the lamp flashes intermittently.

Could anyone tell me why this occurs? And how to solve?

Thank you.

test.ino (1.18 KB)

Hi,

That circuit, if you have it like the picture on breadboard, is extremely dangerous.

Please turn it off and do not turn it on again until everything is properly isolated.

Depending on what actual triac you are using, the lamp may not provide sufficient latching or holding current for the triac. You will have to check the datasheet.

Yours,
TonyWilk

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Not a fritzy picture.

Please include all components, there numbers and pins labels.

Can you post a picture of your project, so we can see your component layout?

Thanks.. Tom. :slight_smile:

TonyWilk:
Hi,

That circuit, if you have it like the picture on breadboard, is extremely dangerous.

Please turn it off and do not turn it on again until everything is properly isolated.

Depending on what actual triac you are using, the lamp may not provide sufficient latching or holding current for the triac. You will have to check the datasheet.

Yours,
TonyWilk

TomGeorge:
Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Not a fritzy picture.

Please include all components, there numbers and pins labels.

Can you post a picture of your project, so we can see your component layout?

Thanks.. Tom. :slight_smile:

Hi, Tony Wilk.

I would like to thank you for your help. I'm using the BTA41-600 triac. Could you explain more about locking and holding chain?

Hello Tom.

I'm sending some pictures of the circuit. At the moment, it seems chaotic. But it's just a test. I tried to tag the most important components. Concerning the drawing by hand, I will make sure that you can analyze it.

Thank you again both for the cooperation.

Below the pictures:

Imgur

Imgur

Imgur

Video - Circuit Testing:

Circuit diagram:

Imgur

List of components:

  • Resistors: 180, 220, 2k4, 10k, 33k
  • CI MOC3020
  • CI H11AA1
  • TRIAC BTA41-600
  • Polyester Capacitor 10nF/400V

Load:

  • Lamp AC 127V 60W

Processing:

  • Arduino UNO

Pins:

  • PIN 2 - Zero Crossing
  • PIN 4 - Dimmer Signal In
  • PIN VCC 5V
  • PIN GND

I'm waiting for any help. Thank you.

As pointed out this method is not safe, I would think well know that the bread board is not capable of carrying the current.

127V AC / 60 = 2.1amps current draw, I'd make my connections for the TRIAC (mains) all hard wired and soldered onto a PCB with wire that can carry the current.

You need to be careful with mains :o

Steveiboy:
As pointed out this method is not safe, I would think well know that the bread board is not capable of carrying the current.

127V AC / 60 = 2.1amps current draw, I'd make my connections for the TRIAC (mains) all hard wired and soldered onto a PCB with wire that can carry the current.

You need to be careful with mains :o

Hello Steveiboy. Thanks for the collaboration.

Do you think protoboarding is the blinking lamp problem?

Would not the correct 0.472A be?

I = P / V
I = 60/127
I = 0.472A

On average a protoboard would hold from 1A to 3A, depending on the manufacturer.

I would say it certainly will not help the matter.
It possible could be something on your zero crossing or your code.
I would solder the connections to the TRIAC and make sure there isolated in some way to reduce the risk and the try it to eliminate the breadboard

Yes you are correct with ohms law, sorry it’s late here in uk and my brain went to sleep old age

Breadboard is still not the best way to carry out your testing
Regards
Steve

Steveiboy:
I would say it certainly will not help the matter.
It possible could be something on your zero crossing or your code.
I would solder the connections to the TRIAC and make sure there isolated in some way to reduce the risk and the try it to eliminate the breadboard

I understand your concern. Unfortunately Brazil is a horrible country and even a pcb board costs a lot of money - including a shuttle. Therefore, I would like to be sure of the state of the circuit so as not to lose the pcb.

Any suggestions on the code?

I performed the zero count test. In the 60HZ network, 120 passes.

Do you believe that the arduino is out of network synchronism?

Hi,
Your circuit diagram does not make sense.
Follow the RED line.
Why is the input to the zero crossing opto H11A across the "Triac"? ? ?


This WILL help.

https://playground.arduino.cc/Main/ACPhaseControl

Can you please post a copy of your circuit as a picture of a hand drawn circuit in jpg, png?
In other words, please reverse engineer the project please.

Tom.. :slight_smile:

TomGeorge:
Hi,
Your circuit diagram does not make sense.
Follow the RED line.
Why is the input to the zero crossing opto H11A across the "Triac"? ? ?


This WILL help.

Arduino Playground - HomePage

Can you please post a copy of your circuit as a picture of a hand drawn circuit in jpg, png?
In other words, please reverse engineer the project please.

Tom.. :slight_smile:

This circuit was found on the internet. But I believe that the 10k resistor is a pull up for the ZeroCrossing signal.

I'll study the content you sent me. After the tests I will return to share the results.

Thanks for the while, Tom. :slight_smile: