Vixen Generic Serial Output controls the Arduino!

OK 8 channels. This is code I am using for 32 channels on Mega but trimmed to 8 on UNO for your purpose. I make the code as small as possible to make it easy to manage. The code supports both PWM outputs and digital outputs, sooooo.....You may need to alter the PWM and Digital numbers and the 'pins' array depending on how you wish to use the signals sent from Vixen. The rest of the code should not need ot be touched. This means you can use this code by only altering thre numbers at the start for any type of arduino and any combination of vixen channels.

Code:
#define NCH 8    // ALTER THIS: the sum of pwm and digital pins (number of channels from vixen)
#define NPWM 6 // ALTER THIS: the number of PWM pins you use
#define NDIG 2  // ALTER THIS: the number of DIGITAL pins you use...make sure NPWM+NDIG=NCH

int pins[NCH]={  3,5,6,9,10,11, 7,8 }; //ALTER THIS FOR YOUR PHYSICAL PINS...pwm first then normal digital pins (set for UNO currently)
int data[NCH];   // to buffer incoming data

void setup()
{
  Serial.begin(9600);  // ALTER THIS: for various serial speeds on Vixen                    
  for (int i=0; i<NCH; i++) pinMode ( pins[i], OUTPUT );  
}

void readSerialBuffer()  { for (int i=0; i<NCH; i++) data[i] = Serial.read(); }

void outputToPins()   { 
  for (int i=0; i<NPWM; i++) analogWrite(pins[i], data[i]); // first pwm
  for (int i=NPWM; i<NCH; i++) // now digital outputs
         if (data[i]<127) digitalWrite(pins[i], LOW); else digitalWrite(pins[i], HIGH);
}

void loop()
{  
   if (Serial.available() >= NCH) {
      readSerialBuffer();
      outputToPins();
   }
}

p.s. I may have made a blunder when editing it for your needs so if you have an issue, let me know. Good luck,

Chris
 
Sorry I've been slack Auld, but hopefully the attachment works.

A few explanations...
1. 36 volt input. That's what the 24 volt AC adaptor from a donor set of lights ended up outputting once it was rectified (changed to DC)
2. 12 volt regulator serves 2 purposes. Drops the incoming supply to the 5 volt regulator so that doesn't overheat, and powers the FM modulator so people can tune their car radios in to listen to the carols, without the neighbours hearing the same songs in a 15 minute loop.
3. I needed 2 output voltages, 5 volts for solar strings, and 24 volt for transformer powered strings, any voltages could be used provided the Vce rating of the transistor isn't exceeded.
4. The pin 1 input of the opto isolators can connect to any output pin of the arduino, and will operate in PWM mode.
5. I kept the 2 grounds/negative/zero volt rails apart, probably erring on the side of caution.

As I ratted the optos from old PC power supplies, all up the (now)16 channels interface has cost under $10 :thup2:
 

Attachments

  • ChristmasLights2.jpg
    ChristmasLights2.jpg
    66.7 KB · Views: 69
Thanks for the schematic alhortz. I can learn quite abit from this. In the end I couldnt wait so long and had to design my own circuit and boards. It was a fun ride but I got 32 channels of 12 v controlled by Vixen generic to Arduino Mega up and running on one (BIG) board. It'll be my first light show and was my first electronic design!
 
I have tried the code, but my leds just blink rapidly, even if I use a different effect. What version of Vixen should I use? How do I configure Generic Serial? Thanks!
 
I'm using Vixen 2. Heres an image of setting up serial output. You do this when creating the new sequence. Make sure the number next to the arrow matches the number for serial setup in the Arduino code.

Setup_and_Sequence_Plugin_Mapping_and_New_Sequence_Wizard_and_Vixen.jpg

-auld
 
Hey that's great, glad to help.

Another noob here, thanks for your code. I was banging my head against the wall trying to get it to work until finally I realized I had the wrong baud rate set in Vixen. Works perfectly!
 
Another noob here, thanks for your code. I was banging my head against the wall trying to get it to work until finally I realized I had the wrong baud rate set in Vixen. Works perfectly!

kflott, thats really good of you to let me know and makes my day (really). I'm a noob myself and its really nice to here that I can help others. I'm working hard to do a Halloween show right now with the code. I've also hooked up a second Arduino to the first sending a signal to control an Animatronic Pirate I've built who moves (more or less) in time to the music. The on/off signals come from Vixen to a mega arduino, then this sends a signal to the uno arduino on the animatronic which runs its own code inside. Anyway, to avoid thread hijacking, I'll stop now and say Vixen 2.x plus Arduino is awesome. The great thing is when you stop/start vixen nothing goes out of synch, it all just works. I never lose a signal despite running a 10 metre (active) usb from PC to arduino and using a baud rate of 57600, got to fly, still working on some more special effects.

Auld
 
Hi all. I used the code I posted in this thread to control two Arduinos (a mega and an Uno). One was used for the light show and one for an animatronic life size Pirate for my Halloween show. I know this is Christmas forums but Christmas is waaaay too cold in Poland for people to stand outside so I'm left with Halloween or nothing. I first came to this thread (and forum) about 6 months ago found out about Vixen and how easy it was to connect an Arduino to it. The result is my first show ever and you can see a (poorly made) video on youtube (links below). Thanks Christmas DIY forums!

We had el-wire, led strips, an animatronic and uv paintings all controlled in time to music using Vixen 2.1.1, Arduino and about 50 sticks of hot glue :).
I built the lights by hand and the show control electronics too (my first electronics project). Huge work but cost was an issue and I can't afford thousands of dollars to set all this up.

Links:
Main show in Poland 2013
Extras and better overview

The second video shows extra effects not using vixen or arduino but might be of interest to some.

Auld.
 
great work Auld :thup2: very well done!

finally made it back here, been a difficult year with mrsH not being well and working at work and with housework, but I finally finished this years Vixen sequence last Friday, controller board is modified for the extra channels, now all that remains is to get the lights ready for mounting.
Trying to cheat a bit there, picked up a 5 metre x 5 metre bird net that is used to cover fruit trees. The LEDs should poke through the weaving so no need to tie them down, and form a six stage concentric star on one side, and a tree on the other, with lights, balls and a star. Tree will be formed with a green rope light that was solar powered. Borrowed a projector to set the shapes up.
At the end of the season I should be able to fold or roll it all up, ready to roll out again next year, probably with a few more additins :blush:
 
Vixen Lights is awesome and I wanted to have it control my new little Arduino Duemilanove. I decided to use the generic serial output already in vixen lights as my plugin. I’m using 5 channels on my Arduino (5,6,9,10 & 11) that have PWM so I can fade the LEDs. The generic serial output appears to simply output one byte at a time like so: 06 00 00 00 00 00 0d. I setup my vixen lights sequence to use 7 channels. The first 5 would be for my LEDs, channel 6 is the beat track and channel 7 was a spare. I used a baud rate of 9600. The code simply takes the 7 bytes, stuffs them into an array and then sends them to the hungry LEDs. Check out the code:
Code:
/*
The purpose of this code is to allow the Arduino to use the 
generic serial output of vixen lights to control 5 channels of LEDs. 
Author: Matthew Strange
Created: 14 October 2010

*/

// Output
int Chan1 = 5;  // red LED,   connected to digital pin 5
int Chan2 = 6;  // green LED, connected to digital pin 6
int Chan3 = 9;  // red LED,  connected to digital pin 9
int Chan4 = 10;  // green LED,  connected to digital pin 10
int Chan5 = 11;  // red LED,  connected to digital pin 11

int i = 0;     // Loop counter
int incomingByte[7];   // array to store the 7 values from the serial port

//setup the pins/ inputs & outputs
void setup()
{
  Serial.begin(9600);        // set up Serial at 9600 bps

  pinMode(Chan1, OUTPUT);   // sets the pins as output
  pinMode(Chan2, OUTPUT);
  pinMode(Chan3, OUTPUT);
  pinMode(Chan4, OUTPUT);
  pinMode(Chan5, OUTPUT);
}

void loop()
{  // 7 channels are coming in to the Arduino
   if (Serial.available() >= 7) {
    // read the oldest byte in the serial buffer:
    for (int i=0; i<8; i++) {
      // read each byte
      incomingByte[i] = Serial.read();
    }
    
    analogWrite(Chan1, incomingByte[0]);   // Write current values to LED pins
    analogWrite(Chan2, incomingByte[1]);   // Write current values to LED pins
    analogWrite(Chan3, incomingByte[2]);   // Write current values to LED pins
    analogWrite(Chan4, incomingByte[3]);   // Write current values to LED pins
    analogWrite(Chan5, incomingByte[4]);   // Write current values to LED pins
   }
}

Simple and easy. This will only work with a 7 channel output. I can see complications if you wanted to grow this more. Which I do! Next steps will be to daisy chain some Arduinos, and add some SSRs. I’m completely new so I hope this helps another noobie. Any comments or suggestions are appreciated.

Could you help me out I am having a few problems with mine?
I am new to it and would really appreciate it
 
Back
Top