IR Ac Dimmer issue

hello everyone i made one project ir based ac dimmer and relay control
but i problem is that after powering on circuit it's working for one or tow minutes and then it's looks like hang no respace on ir remote

while doing diagnosis of pcb i found that it's started after circuit ac dimmer part at work otherwise it's working fine once dimmer part activated pcb not respond with ir signal

here i share schematics and it's code

here schematic ir ac dimmer control.pdf (312.3 KB)

#include <EEPROM.h>
#include "IRremote.h"
int relay0 = 4;
int relay1 = 6;
int relay2 = 7;
int relay3 = 8;
int relay4 = 9;
int relay5 = 10;
int relay6 = 11;
int relay7 = 12;
int relay8 = 13;
int relay9 = A0;
int relay10 = A1;
int relay11 = A2;
int relay12 = A3;
int relay13 = A4;
int relay14 = A5;

int receiver = 3;
IRrecv irrecv(receiver);
decode_results results;
bool load0 = 1;
bool load1 = 1;
bool load2 = 1;
bool load3 = 1;
bool load4 = 1;
bool load5 = 1;
bool load6 = 1;
bool load7 = 1;
bool load8 = 1;
bool load9 = 1;
bool load10 = 1;
bool load11 = 1;
bool load12 = 1;
bool load13 = 1;
bool load14 = 1;

#include <TimerOne.h>
volatile int i = 0;              // Variable to use as a counter
volatile boolean zero_cross = 0; // Boolean to store a "switch" to tell us if we have crossed zero
int AC_pin = 5;                  // Output to Opto Triac

int dim2 = 0;      // led control
int dim = 128;     // Dimming level (0-128)  0 = on, 128 = 0ff
int freqStep = 75; // This is the delay-per-brightness step in microseconds.

void zero_cross_detect();
void dim_check();
void translateIR();
void setup();
void loop();

void zero_cross_detect()
{
  zero_cross = true; // set the boolean to true to tell our dimming function that a zero cross has occured
  i = 0;
  digitalWrite(AC_pin, LOW);
}
// Turn on the TRIAC at the appropriate time

void dim_check()
{
  if (zero_cross == true)
  {
    if (i >= dim)
    {
      digitalWrite(AC_pin, HIGH); // turn on light
      i = 0;                      // reset time step counter
      zero_cross = false;         // reset zero cross detection
    }
    else
    {
      i++; // increment time step counter
    }
  }
}

void translateIR() // takes action based on IR code received
{
  switch (results.value)
  {
  case 0x1FEA05F:
  {

    if (dim < 127)
    {
      dim = dim + 8;
      EEPROM.write(16, dim);
      if (dim > 127)
      {
        dim = 128; // in vechiul sketch era 127
        EEPROM.write(16, dim);
      }
    }
    Serial.println(dim);
  }

  break;

  case 0x1FE609F:
  {

    {
      if (dim > 5)
        EEPROM.write(16, dim);
      {
        dim = dim - 8;
        if (dim < 0)
        {
          dim = 0; // in vechiul sketch era 1
          EEPROM.write(16, dim);
        }
      }
    }
    Serial.println(dim);
  }
  break;
  case 0x1FE48B7:
  {
    if (results.value == 0x1FE48B7 && digitalRead(4) == 1)
    { // For Load1 On
      load0 = 0;
      EEPROM.write(1, load0);
    }
    else if (results.value == 0x1FE48B7 && digitalRead(4) == 0)
    { // For Load1 Off
      load0 = 1;
      EEPROM.write(1, load0);
    }
  }
  break;
  case 0x1FE50AF:
  {
    if (results.value == 0x1FE50AF && digitalRead(6) == 1)
    { // For Load1 On
      load1 = 0;
      EEPROM.write(2, load1);
      digitalWrite(relay1, load1);
    }
    else if (results.value == 0x1FE50AF && digitalRead(6) == 0)
    { // For Load1 Off
      load1 = 1;
      EEPROM.write(2, load1);
      digitalWrite(relay1, load1);
    }
  }
  break;
  case 0x1FED827:
  {
    if (results.value == 0x1FED827 && digitalRead(7) == 1)
    { // For Load1 On
      load2 = 0;
      EEPROM.write(3, load2);
      digitalWrite(relay2, load2);
    }
    else if (results.value == 0x1FED827 && digitalRead(7) == 0)
    { // For Load1 Off
      load2 = 1;
      EEPROM.write(3, load2);
      digitalWrite(relay2, load2);
    }
  }
  break;
  case 0x1FEF807:
  {
    if (results.value == 0x1FEF807 && digitalRead(8) == 1)
    { // For Load1 On
      load3 = 0;
      EEPROM.write(4, load3);
      digitalWrite(relay3, load3);
    }
    else if (results.value == 0x1FEF807 && digitalRead(8) == 0)
    { // For Load1 Off
      load3 = 1;
      EEPROM.write(4, load3);
      digitalWrite(relay3, load3);
    }
  }
  break;
  case 0x1FE30CF:
  {
    if (results.value == 0x1FE30CF && digitalRead(9) == 1)
    { // For Load1 On
      load4 = 0;
      EEPROM.write(5, load4);
    }
    else if (results.value == 0x1FE30CF && digitalRead(9) == 0)
    { // For Load1 Off
      load4 = 1;
      EEPROM.write(5, load4);
    }
  }
  break;
  case 0x1FEB04E:
  {
    if (results.value == 0x1FEB04E && digitalRead(10) == 1)
    { // For Load1 On
      load5 = 0;
      EEPROM.write(6, load5);
    }
    else if (results.value == 0x1FEB04E && digitalRead(10) == 0)
    { // For Load1 Off
      load5 = 1;
      EEPROM.write(6, load5);
    }
  }
  break;
  case 0x1FE708F:
  {
    if (results.value == 0x1FE708F && digitalRead(11) == 1)
    { // For Load1 On
      load6 = 0;
      EEPROM.write(7, load6);
    }
    else if (results.value == 0x1FEB04E && digitalRead(11) == 0)
    { // For Load1 Off
      load6 = 1;
      EEPROM.write(7, load6);
    }
  }
  break;
  case 0x1FE00FF:
  {
    if (results.value == 0x1FE00FF && digitalRead(12) == 1)
    { // For Load1 On
      load7 = 0;
      EEPROM.write(8, load7);
    }
    else if (results.value == 0x1FE00FF && digitalRead(12) == 0)
    { // For Load1 Off
      load7 = 1;
      EEPROM.write(8, load7);
    }
  }
  break;
  case 0x1FEF00F:
  {
    if (results.value == 0x1FEF00F && digitalRead(13) == 1)
    { // For Load1 On
      load8 = 0;
      EEPROM.write(9, load8);
    }
    else if (results.value == 0x1FEF00F && digitalRead(13) == 0)
    { // For Load1 Off
      load8 = 1;
      EEPROM.write(9, load8);
    }
  }
  break;
  case 0x1FE9867:
  {
    if (results.value == 0x1FE9867F && digitalRead(A0) == 1)
    { // For Load1 On
      load9 = 0;
      EEPROM.write(10, load9);
    }
    else if (results.value == 0x1FE9867 && digitalRead(A0) == 0)
    { // For Load1 Off
      load9 = 1;
      EEPROM.write(10, load9);
    }
  }
  break;
  }
}

void setup()
{
  Serial.begin(9600);
  pinMode(AC_pin, OUTPUT); // Set the Triac pin as output
  irrecv.enableIRIn();     // Start the IR receiver (classic remote)

  pinMode(relay0, OUTPUT);
  pinMode(relay1, OUTPUT);
  pinMode(relay2, OUTPUT);
  pinMode(relay3, OUTPUT);
  pinMode(relay4, OUTPUT);
  pinMode(relay5, OUTPUT);
  pinMode(relay6, OUTPUT);
  pinMode(relay7, OUTPUT);
  pinMode(relay8, OUTPUT);
  pinMode(relay9, OUTPUT);
  pinMode(relay10, OUTPUT);
  pinMode(relay11, OUTPUT);
  pinMode(relay12, OUTPUT);
  pinMode(relay13, OUTPUT);
  pinMode(relay14, OUTPUT);

  attachInterrupt(0, zero_cross_detect, RISING); // Attach an Interupt to Pin 2 (interupt 0) for Zero Cross Detection
  Timer1.initialize(freqStep);                   // Initialize TimerOne library for the freq we need
  Timer1.attachInterrupt(dim_check, freqStep);

  digitalWrite(relay0, HIGH);
  digitalWrite(relay1, HIGH);
  digitalWrite(relay2, HIGH);
  digitalWrite(relay3, HIGH);
  digitalWrite(relay4, HIGH);
  digitalWrite(relay5, HIGH);
  digitalWrite(relay6, HIGH);
  digitalWrite(relay7, HIGH);
  digitalWrite(relay8, HIGH);
  digitalWrite(relay9, HIGH);
  digitalWrite(relay10, HIGH);
  digitalWrite(relay11, HIGH);
  digitalWrite(relay12, HIGH);
  digitalWrite(relay13, HIGH);
  digitalWrite(relay14, HIGH);

  dim = EEPROM.read(16);
}

void loop()
{
  if (irrecv.decode(&results)) // have we received an IR signal?
  {
    translateIR();
    delay(1000);
    irrecv.resume(); // receive the next value
    Serial.println(results.value, HEX);
    digitalWrite(relay0, load0);
    digitalWrite(relay1, load1);
    digitalWrite(relay2, load2);
    digitalWrite(relay3, load3);
    digitalWrite(relay4, load4);
    digitalWrite(relay5, load5);
    digitalWrite(relay6, load6);
    digitalWrite(relay7, load7);
    digitalWrite(relay8, load8);
  }
  delay(1000);
}

1 Like

Hi,
Did your breadboard prototype work?
Can you please post a circuit diagram?
Can you please post an Exported jpg of your PCB?

Thanks.... Tom.. :smiley: :+1: :coffee: :australia:

1 Like

yes breadboard prototype works fine
i already attached circuit diagram in form of schematic diagram ir ac dimmer control.pdf

here pcb picture

Hi,
Thanks..
@squirrel_it circuit.

Tom... :smiley: :+1: :coffee: :australia:

HI,
Have you got comms through the tx/rx of the 328?

Have you provided provision for programming in circuit and debugging?

Where on your circuit are the opto-couplers, IR receiver and power supply?
I see relays on your PCB, but not in your circuit diagram.
On your PCB it looks like you have no Back EMF diodes on the relay coils.

Thanks..Tom.. :smiley: :+1: :coffee: :australia:

1 Like

in pdf there is one more page there is all relays and other dimmer related components+
i use external 5v 700mamp power supply also one power supply is built in but for now i'm using external one for fault finding

no i not check rx/tx but it's working at start and also work fine on breadboard so there is no issue i have problem with pcb or maybe pcb design itself or maybe crystal issue i try different value cap. but same result every time

no there is no back emf diode but in diagnosis i use external relay through header pin with external relay module board but still result same

all i have in circuit issue no power problem no shorting no gnd missing no power missing nothing there is one gnd missing in pcb design but i fix it if i use without any load there is no issue problem faces when load connected to any of terminal/s

Hi,
How are you driving the relays on your PCB?
Can you post link to data/specs.
I cannot see any driver BJT/MOSFET.

Sorry we need a COMPLETE diagram, not two discontinued ones.
You have 14 relay outputs, how are you driving them.
What is the power supply?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Yas i have 14 relay but only 4 are on pcb other relays are on header pin external relay module header have 5v gnd amd arduino pin

And also 4 on pcb relay have backup headr in case of failure of pcb some how right now i'm using external relay module due to interal issue because i forget to put optocoupler/reverse emf diode 2 resistor and one transistor
That's why i use external relay module it have all if requirements

Also in power supply i connect from externally using jumper wires because it't have 0.2A output hi-link 2w 0.2amp 9v using 1amp 5v regulator ic

Hi,
Can you draw me the circuit between your controller and the 4 onboard relays please?
Include pin and component lables.

Use pen(cil) and paper and post a image.

Thanks.. Tom.... :smiley: :+1: :coffee: :australia:

1 Like

i'm using this type of relay module outside of pcb
https://cdn.shopify.com/s/files/1/0300/6424/6919/files/Relay-Module_600x600.jpg?v=1617261184
https://cdn.shopify.com/s/files/1/0300/6424/6919/files/Relay-Module_600x600.jpg?v=1617261184

forgot about internal relays remove them using external one as upper link still facing same issue

here diagramremote Fan speed control ac dimmer.pdf (164.3 KB)

this power supply powering my circuit and relays using this with 5v regulator ic
7805cg(smd)
HLK-PM01 Hi-link - 5V 3W - AC to DC Power Supply Module buy online at Low Price in India - ElectronicsComp.com

Hi,
@squirrel_it Relays and circuit.
Relay-Module_600x600

Tom.... :smiley: :+1: :coffee: :australia:

Hi,
I hope you are keeping ALL the mains AC power wires away from the controller PCB?

The other thing that has me worried is the thick tracks that run over the thinner controller tracks.

If those tracks are carrying current they could cause interference to the controller.

Have you got 220Vac mains on that PCB, if so where and how have you made sure it is isolated from the low voltage circuitry?
Is BR2 on the PCB the mains rectifier to give the zero crossing signal?
If so the mains track winds amongst other tracks, not good and could be also causing your problems.

Tom... :smiley: :+1: :coffee: :australia:

1 Like

yas br2 is on pcb i thought same that mains voltage interfere in controller voltage

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.