1

None of my channels initialize. I suspect a driver issue, but I have tried 2 different libraries.

I have this device:

Krida 4 channel

connected exactly like:

GND - > GND
VCC -> 5V
SYNC -> DIGITAL.3
CH1 -> DIGITAL.7

Libraries attempted:

https://code.google.com/archive/p/arduino-timerone/downloads

and the stock Arduino <TimerOne.h> from libraries manager

I tried all the different code samples but here is the most recent. Code sample:

#include <TimerOne.h>

unsigned char channel_1 = 7;    // Output to Opto Triac pin, channel 1
unsigned char channel_2 = 6;    // Output to Opto Triac pin, channel 2
unsigned char channel_3 = 5;    // Output to Opto Triac pin, channel 3
unsigned char channel_4 = 4;    // Output to Opto Triac pin, channel 4
unsigned char CH1, CH2, CH3, CH4;
unsigned char i=0;
unsigned char delay_time=25;     // delay ms or flashing SPEED
unsigned char clock_tick;        // variable for Timer1
unsigned char CHANNEL_SELECT;    // variable for channel select

unsigned char CH[]={CH1,CH2,CH3,CH4};

unsigned char dim_level[]={5,8,10,12,15,18,20,25,30,35,45,50,55,60,65,70,75,80,82,85,88,92,95};   // don't use this massive for 60Hz
                                                                                                  // create new massive for 60Hz
void setup() {

  pinMode(channel_1, OUTPUT);// Set AC Load pin as output
  pinMode(channel_2, OUTPUT);// Set AC Load pin as output
  pinMode(channel_3, OUTPUT);// Set AC Load pin as output
  pinMode(channel_4, OUTPUT);// Set AC Load pin as output
  attachInterrupt(1, zero_crosss_int, RISING);
  Timer1.initialize(100); // set a timer of length 100 microseconds for 50Hz or 83 microseconds for 60Hz; 
  Timer1.attachInterrupt( timerIsr ); // attach the service routine here

}

void timerIsr()
{    
    clock_tick++;

      if (CH[0]==clock_tick)
    {
      digitalWrite(channel_1, HIGH);   // triac firing
      delayMicroseconds(10);           // triac On propogation delay (for 60Hz use 8.33)
      digitalWrite(channel_1, LOW);    // triac Off 
    }  

      if (CH[1]==clock_tick)
    {
      digitalWrite(channel_2, HIGH);   // triac firing
      delayMicroseconds(10);           // triac On propogation delay (for 60Hz use 8.33)
      digitalWrite(channel_2, LOW);    // triac Off 
    }  

      if (CH[2]==clock_tick)
    {
      digitalWrite(channel_3, HIGH);   // triac firing
      delayMicroseconds(10);           // triac On propogation delay (for 60Hz use 8.33)
      digitalWrite(channel_3, LOW);    // triac Off 
    }  

      if (CH[3]==clock_tick)
    {
      digitalWrite(channel_4, HIGH);   // triac firing
      delayMicroseconds(10);           // triac On propogation delay (for 60Hz use 8.33)
      digitalWrite(channel_4, LOW);    // triac Off 
    }   
}



void zero_crosss_int()  // function to be fired at the zero crossing to dim the light
{
  // Every zerocrossing interrupt: For 50Hz (1/2 Cycle) => 10ms  ; For 60Hz (1/2 Cycle) => 8.33ms 
  // 10ms=10000us , 8.33ms=8330us

    clock_tick=0;        
}



void loop() {


for (CHANNEL_SELECT=0;CHANNEL_SELECT<4;CHANNEL_SELECT++)  // fade up
 {
  for (i=22;i>1;i--)
  {
    CH[CHANNEL_SELECT]=dim_level[i];
    delay(delay_time);
  } 
 }

delay(2000);

for (CHANNEL_SELECT=0;CHANNEL_SELECT<4;CHANNEL_SELECT++)  // fade down
 {
  for (i=0;i<22;i++)
  {
    CH[CHANNEL_SELECT]=dim_level[i];
    delay(delay_time);
  } 
 }
delay(1000);

}

The code uploads error free to one of the many Arduino Nanos (I tried fresh hardware) that I have.

I cannot establish continuity with my load input channel to any of the load output channels. It is though D7 never never does its job and flip the channel open. Nor can I get any continuity on any of the other channels.

The code is supposed to cycling through all of them but no current ever hits any of the 'load' on any of my channels (Chan 1-4).

Deeper inspection of the Arduino with a voltage meter shows that I am getting reverse polarity on my d7 pin. actually, d7 - d4 all have what appear to be incorrect cycles (reverse polarity) on them. These are all the pins that are supposed to be turning on channels. This does not look correct to me at all.

I suspect driver but I cannot find any other libraries to try that look sane.

How do I initialize my d7 Arduino pin correctly to bring my Krida 4 chan triac Load channel live?

or, did I miss something exceptionally ignorant? I am not experienced with this particular module.

photos:

image 1

image 2

image 3

Same as image 2, but with channel 1 to d7 connected

migrated from electronics.stackexchange.com Sep 25 '18 at 15:21

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

1

First of all you should test if the SYNC interrupt is working, like turning on one LED or something you can debug. You switch on the mains AC and then you should detect this zero cross interrupt. If not, then maybe you configured an interrupt event on wrong pin.

Further, making do-while loops in interrupt routine is a no go. Your timeISR turns on one triac, then loops for 10us and turns the triac off. Well not so good implementation. You could skip delay, and turn off after another timeISR by making this ISR at 10us instead.

void timerIsr()  //10us
{    
    clock_tick++;
    digitalWrite(channel_1, LOW);    // triac Off 
    digitalWrite(channel_2, LOW);    // triac Off 
    .....
    if (CH[0]==clock_tick)
      {
        digitalWrite(channel_1, HIGH);   // triac firing      
      }
  • I made the code changes bpaste.net/show/428d553e9881 and it stopped the LED from blinking on the device, but all the other behaviors are still the same. – boobie Sep 25 '18 at 12:14
  • But I am no longer reversed polarity on my arduino. – boobie Sep 25 '18 at 12:16
  • The reversed polarity is somehow impossible, because you supply the circuit with your Vcc and GND. The device has wired an optotriac to your Arduino outputs. Perhaps you swapped the voltmeter tips? – Marko Buršič Sep 25 '18 at 12:23
  • I can flip that reverse polarity back and forth by changing the code back and forth like a switch. I am using a Greenlee DM-45. Its old but pretty reliable. I can literally watch the flip live. – boobie Sep 25 '18 at 12:27
  • @boobie, is the problem solved? (you marked the answer accepted) – Juraj Sep 25 '18 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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