Relay random release problem

LUTIN

New member
Hello everyone, I allow myself to ask for help by this post because I can not find the solution to my problem. I use the latest version of vixen coupled with multiple arduino Mega, Uno and Nano. Some pixel controls and other relays. My problem is the relays, at the beginning of the configuration everything worked properly but after unplugging and reconnecting the usb plugs of the Arduino Mega and Uno to my pc, the relays is triggered randomly ... That is to say that when my relay 1 must NORMALLY turn on window 1 of my house, well relay 1 turns on window 2 .... or 5 sometimes; and the same for all the other relays that do not turn on the right windows, while everything worked perfectly when configuring the generic exit on Vixen ... I'm heading to you to find out if anyone had already had this problem . I contact you from France and I use a translator so sorry if my spelling is not good. .I wish you a wonderful end-of-year celebration
Code:
#define MEGA_VIXEN
//#define UNO_VIXEN

#ifdef MEGA_VIXEN
  #define MAX_CHANNELS 52
  int channels[MAX_CHANNELS] = {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53};
#endif

#ifdef UNO_VIXEN
  #define MAX_CHANNELS 18
  int channels[MAX_CHANNELS] = {2,3,4,5,6,7,8,9,10,11,12,13,A0,A1,A2,A3,A4,A5};
#endif

int incomingByte[MAX_CHANNELS];

void setup()
{
pinMode (10, OUTPUT);
pinMode (38, OUTPUT);

  int i;  
  Serial.begin(9600); // set up Serial at 9600 bps
  for ( i = 0; i < MAX_CHANNELS; i ++ )  pinMode(channels[i], OUTPUT);
}
void loop(){

digitalWrite (10, HIGH);
digitalWrite (38, HIGH);
  
  int i;  
  if (Serial.available() >= MAX_CHANNELS)
  {
    for (i=0; i < MAX_CHANNELS; i ++)      incomingByte[i] = Serial.read();
  }
  //for (i = 0; i < MAX_CHANNELS; i ++ )    analogWrite(channels[i], incomingByte[i]);
  for (i = 0; i < MAX_CHANNELS; i ++ ) digitalWrite(channels[i], ~incomingByte[i]);  
}
51fUlHZo-aL._AC_UY218_ML3_.jpg
 

Attachments

  • 51hZG7t-BBL.jpg
    51hZG7t-BBL.jpg
    45.6 KB · Views: 4
Last edited:
I also use this code for my UNO ...
Code:
/* 
This sketch allows the Arduino to read 16 bytes of data from Vixen and turn on
its pins accordingly, which in turn controls a solid state relay hooked up to Xmas lights.
*/

// Define pins on Arduino that will control the relay.
#define CHANNEL_01 2
#define CHANNEL_02 3
#define CHANNEL_03 4
#define CHANNEL_04 5
#define CHANNEL_05 6
#define CHANNEL_06 7
#define CHANNEL_07 8
#define CHANNEL_08 9
#define CHANNEL_09 10
#define CHANNEL_10 11
#define CHANNEL_11 12
#define CHANNEL_12 13
#define CHANNEL_13 14
#define CHANNEL_14 15
#define CHANNEL_15 16
#define CHANNEL_16 17

// Define size of array to hold channels
#define CHANNEL_COUNT 16

// Define array to hold channels
int channels[] =
{
  CHANNEL_01, CHANNEL_02, CHANNEL_03, CHANNEL_04, CHANNEL_05, CHANNEL_06, CHANNEL_07, CHANNEL_08,
  CHANNEL_09, CHANNEL_10, CHANNEL_11, CHANNEL_12, CHANNEL_13, CHANNEL_14, CHANNEL_15, CHANNEL_16
};

// Define array to hold incoming data stream from Vixen
int incomingByte[8];

// Define baud rate. This figure must match that of your profile configuration in Vixen!
#define BAUD_RATE 9600

void setup()
{
  // Begin serial communication
  Serial.begin(BAUD_RATE);

  // Set up each channel as an output
  for(int i = 0; i < CHANNEL_COUNT; i++)
  {
    pinMode(channels[i], OUTPUT);
  }
}

void loop()
{ 
  if (Serial.available() >= CHANNEL_COUNT)
  {
    // Read data from Vixen, store in array
    for (int i = 0; i < CHANNEL_COUNT; i++)
    {
      incomingByte[i] = Serial.read();
    }
    // Write data from array to a pin on Arduino
    for (int i = 0; i < CHANNEL_COUNT; i++)
    {
      digitalWrite(channels[i], incomingByte[i]);
    }
    }
}
 
I also use this code for my UNO ...
Code:
/* 
This sketch allows the Arduino to read 16 bytes of data from Vixen and turn on
its pins accordingly, which in turn controls a solid state relay hooked up to Xmas lights.
*/

// Define pins on Arduino that will control the relay.
#define CHANNEL_01 2
#define CHANNEL_02 3
#define CHANNEL_03 4
#define CHANNEL_04 5
#define CHANNEL_05 6
#define CHANNEL_06 7
#define CHANNEL_07 8
#define CHANNEL_08 9
#define CHANNEL_09 10
#define CHANNEL_10 11
#define CHANNEL_11 12
#define CHANNEL_12 13
#define CHANNEL_13 14
#define CHANNEL_14 15
#define CHANNEL_15 16
#define CHANNEL_16 17

// Define size of array to hold channels
#define CHANNEL_COUNT 16

// Define array to hold channels
int channels[] =
{
  CHANNEL_01, CHANNEL_02, CHANNEL_03, CHANNEL_04, CHANNEL_05, CHANNEL_06, CHANNEL_07, CHANNEL_08,
  CHANNEL_09, CHANNEL_10, CHANNEL_11, CHANNEL_12, CHANNEL_13, CHANNEL_14, CHANNEL_15, CHANNEL_16
};

// Define array to hold incoming data stream from Vixen
int incomingByte[8];

// Define baud rate. This figure must match that of your profile configuration in Vixen!
#define BAUD_RATE 9600

void setup()
{
  // Begin serial communication
  Serial.begin(BAUD_RATE);

  // Set up each channel as an output
  for(int i = 0; i < CHANNEL_COUNT; i++)
  {
    pinMode(channels[i], OUTPUT);
  }
}

void loop()
{ 
  if (Serial.available() >= CHANNEL_COUNT)
  {
    // Read data from Vixen, store in array
    for (int i = 0; i < CHANNEL_COUNT; i++)
    {
      incomingByte[i] = Serial.read();
    }
    // Write data from array to a pin on Arduino
    for (int i = 0; i < CHANNEL_COUNT; i++)
    {
     [B][COLOR="#0000FF"] if (incomingByte[i] <= 127) {
				digitalWrite(channels[i], LOW);
			}
			else {
				digitalWrite(channels[i], HIGH);
    }[/COLOR][/B]
    }
}


When not using dimming you have to test the incoming byte to see if it should be on or off. I removed one line of code and replaced with the highlighted code. The code I inserted should do that. Double check the syntax. I got the code snippet from this link - http://doityourselfchristmas.com/fo...-Up-to-48-realy-SSR-channels-with-Random-mode
 
Thank you very much for your response Kev, I will try your code tomorrow and I will keep you informed : thup:
 
Hello Kev, I tried to enter the code in the arduino but I have an error message that appears, I reverify all my wiring and everything is well connected and paying more attention to the behavior of the relay, I I realized that the relays do not trigger in random mode but that they are actually shifted by 1 ... that is to say that the channel 1 triggers the relay 2 ... Instead of triggering the relay 1 normally and when I reinitialize the code in the arduino and I reboot ... It works but the next restart of the PC it re-bug again ...
 
Hello LUTIN, New guy here. I am not sure if you figured it out yet but in your code where you have:
// Define array to hold incoming data stream from Vixen
int incomingByte[8];
try this:
// Define array to hold incoming data stream from Vixen
int incomingByte[16];


hope that helps.
 
Hi, I am pretty new at using an actual light controller and Vixen. I have gotten pretty good at using Vixen and have built my own light controller. In testing my light controller it seams like there is something running in the background, or the relays are randomly going off. Could someone possibly help me figure this problem out?
Here is my code I am using.
#define MEGA_VIXEN
//#define UNO_VIXEN

#ifdef MEGA_VIXEN
#define MAX_CHANNELS 32
int channels[MAX_CHANNELS] = {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,22,23,24, 25,26,27,28,29,30,31,48,49,50,51,52,53};
#endif

#ifdef UNO_VIXEN
#define MAX_CHANNELS 18
int channels[MAX_CHANNELS] = {2,3,4,5,6,7,8,9,10,11,12,13,A0,A1,A2,A3,A4,A5};
#endif

int incomingByte[MAX_CHANNELS];

void setup()
{
int i;

Serial.begin(9600); // set up Serial at 9600 bps

for ( i = 0; i < MAX_CHANNELS; i ++ ) pinMode(channels, OUTPUT);
}

void loop()
{
int i;

if (Serial.available() >= MAX_CHANNELS)
{
for (i=0; i < MAX_CHANNELS; i ++) incomingByte = Serial.read();
}

for (i = 0; i < MAX_CHANNELS; i ++ ) analogWrite(channels, incomingByte);
}


By the way I followed the build of Dee Higginbotham's 48 channel light controller. I also am not using the last 16 channels as my light show isn't that big yet!


This is a video of what is happening.
Thanks for the help
 
Back
Top