Go Down

Topic: Christmas Lighting with multiple Arduino controllers and relay boards (Read 148 times) previous topic - next topic

agm46m

I am replacing my static Christmas lights with 8 channel arduino uno and relay board. My problem is figuring out how to use serial to connect each location that is 25 ft apart. I use mega as master since Vixen only sees usb ports 1-4, and I have a mega on port 1. my uno are on ports 10, 11, 12, and 13.
I use mega TX3 to each uno rx0 as a data bus. lights flash erraticly. any ideas?

patduino

Hi AGM,

How many Arduinos are you using?

Also, I wouldn't try to use the serial port as a bus to communicate with all Arduinos at the same time -- try I2C or SPI.
There are 10 types of people in the world, those who understand binary, and those that don't.

wvmarle

At 25 ft/8 meters I2C may work with sufficiently strong pull-up and reduced bus speed (try 100 kHz or less). It's not meant for those distances.

Serial: might work if you use a separate connection for each of them.

Lights flashing erratically can have so many options in both the definition of "erratically" as the causes that it's impossible to speculate what could cause this. Complete schematics, full list of hardware and code are a basic requirement to start with that.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.


agm46m

Thanks for this tip. It should both cover the distances well and multiple arduinos. Once I get my first three working, I will expand to maybe ten. I prefer the distributed vs the central control, less cables to worry about.

agm46m

In response to question about coding, here is a test sequence I attempted to use so I wouldn't have to haul out the pc every time I fixed something. Thanks to Bill Porter for the idea.

Code: [Select]


//Vixen_Stored_Mega_Serial

// file created buy Vixeo.py  "VixenShow.cpp" needs to be
// within the same folder as this sketch.
// and can be reviewed by selecting the proper tab at the top of this sketch.

// From a Command Window: enter 'python Vixeno.py [name of vix file}.vix
// output is file named VixenShow.cpp
// which needs to be renamed to prevent overwriting.
// further info in youtube "Electronic Wishing Well by Bill Porter"

#include "MyTest32.cpp"

// description in the include file
//uint8_t vixen_channels = 32;
//uint16_t vixen_frames = 700; (1 minute, 10 seconds)
//uint16_t vixen_frameduration = 100;  (10 frame per sec)
//uint8_t vixen_show_data[32][700] ;


 //caution, Arduino Mega pin before pin22 is 5V.

 // caution, Arduino Mega pin after pin 52 is SIG GND.
 


 int i = 0;
 int j = 0;
 int incomingByte[32];

 void setup()
 {
   Serial.begin(9600);
   Serial3.begin(9600);
  }

 void loop()
 {
  
    int temp = 0;
    for(int i = 0; i < vixen_frames; i++)
   {
       for(int y = 0; y < vixen_channels; y++)
       {
           Serial.print("Frame= ");
           Serial.print(i);
           Serial.print("   Channel= ");
           Serial.print(y);
           temp = pgm_read_byte(&(vixen_show_data[y][i]));
           Serial.print("  Data=  ");
           Serial.println(temp);
           Serial3.write(temp);
          
         }
       delay(vixen_frameduration);  
   }
  
 }





I realize this is a lot to read, but i am responding to a request for more data.
To make the RS485 to work, do i need to get the serial to work at 1 foot range first?


Go Up