Page 1 of 18 12311 ... LastLast
Results 1 to 10 of 177

Thread: Vixen Generic Serial Output controls the Arduino!

  1. #1
    Join Date
    Sep 2010
    Location
    Folsom, Ca
    Posts
    43
    Post Thanks / Like

    Default Vixen Generic Serial Output controls the Arduino!

    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.
    Attached Images Attached Images

  2. #2
    Join Date
    Dec 2007
    Location
    Pacifica, Calif (30mins from downtown San Francisco)
    Posts
    1,739
    Post Thanks / Like

    Default Re: Vixen Generic Serial Output controls the Arduino!

    Quote Originally Posted by Gorak View Post
    This will only work with a 7 channel output.
    Matthew:

    Congratulations on your project.

    I have a Arduino Duemilanove sitting on the bench right here with Vixen controlling 16 channels of PWM LEDs and eight more channels of on/off LEDs (the 16 channels are sink controlled and the eight channels are source controlled). It uses DMX rather than the simple plug-in, so requires a few extra chips, like:

    *An RS485 converter;

    *A TLC5940/5941 to do the PWM on the sink channels.

    *A UDN2981 for the source channels.

    I wrote about two or three lines of code and cut-and-paste all the rest.

    It's all part of the (so-far) incomplete Sawyer Star project (search it here).

    I'll get around to documenting this someday, but probably not until after tear-down.

    \dmc
    ________________________
    The only thing more dangerous than a software engineer with a soldering iron
    or a hardware engineer with a compiler is a liberal-arts major with either.
    Christmas lights: http://www.PacificaLights.info/
    uC/LED hacking: http://www.dmcole.net/

  3. #3
    Join Date
    Sep 2010
    Location
    Folsom, Ca
    Posts
    43
    Post Thanks / Like

    Default Re: Vixen Generic Serial Output controls the Arduino!

    That is awesome! I'm still learning and like I said I want to see if I can daisy chain a few of these together. I have 4 MAX488s so I'll try RS485 to communicate. Eventually I want to get to where you're at and use an external shield to control more channels. Can't wait! I'll check out the Sawyer Star Project. Thanks!

  4. #4
    Join Date
    Dec 2008
    Location
    Madison, MS
    Posts
    128
    Post Thanks / Like

    Default Re: Vixen Generic Serial Output controls the Arduino!

    Great Idea!!! I love Arduino's and have played with using them for all kinds of 'play' things. I can see the potential of using the arduino to control some servo motors for a 'moving' display and having Vixen control the 'when' to move. This can be a great addition to my Halloween Display!!!!

  5. #5
    Join Date
    Sep 2010
    Location
    Folsom, Ca
    Posts
    43
    Post Thanks / Like

    Default Re: Vixen Generic Serial Output controls the Arduino!

    I never thought about using servo motors until you mentioned it. But you're right that gives you the opportunity for some extra creative displays (other than lights) simply using another channel in Vixen!

  6. #6
    Join Date
    Dec 2008
    Location
    Madison, MS
    Posts
    128
    Post Thanks / Like

    Default Re: Vixen Generic Serial Output controls the Arduino!

    Should be an easy script to write on the arduino side. The arduino outputs the degrees from 0 to 180, Vixen outputs 0 to 255. Scale the 0~255 into 0~180 and write to servo motor. I will be playing with this tonight, Ill post my script if all goes well.

  7. #7
    Join Date
    Sep 2010
    Location
    Clear Lake, TX
    Posts
    211
    Post Thanks / Like

    Default Re: Vixen Generic Serial Output controls the Arduino!

    @Gorak

    I loaded your sketch but when I try to run a sequence I get:

    Generic Serial
    (Router-Startup)
    Access to the port 'COM3' is denied

    I opened the arduino software and used the serial monitor and sent 00 to turn on the led. I then closed all of the software and restarted vixen. Have ya'll encountered this problem? It might be that Windows told me that COM3 was already in use. The problem is that I have 1-7 in use, some how, and vixen only goes up to COM4. I'll try it on another machine but just wanted to see if I'm doing something wrong.

    BTW I have the new Arduino Mega 2560 with 54 DI/O. That should hold me for two years I think. I really want to get this to work as the Arduino is a cool little toy. Also, I just got it in the mail and have played with it a total of 2hrs. In fact I really should go to bed so I can get up for work!

  8. #8
    Join Date
    Sep 2010
    Location
    Folsom, Ca
    Posts
    43
    Post Thanks / Like

    Default Re: Vixen Generic Serial Output controls the Arduino!

    Did you get your servos working bnradams?


    Chesterspot it looks like something is connected to your com port already. All you have to do is make sure you select the correct com port in vixen and match the baud rates with vixen and the code (9600 is what I used). Make sure you don't run the arduino software and vixen at the same time and look at the code. You have the better board than I do so your pin numbers at the beginning might be different. Make sure you use pins with PWM to allow fading. But all I have to do for me is make sure the settings are correct, close all software, start vixen, then plug in the arduino and load my sequence that controls 5 puny channels and hit play lol.

  9. #9
    Join Date
    Sep 2010
    Location
    Clear Lake, TX
    Posts
    211
    Post Thanks / Like

    Default Re: Vixen Generic Serial Output controls the Arduino!

    WOOO! It Worked!

    I had to start vixen and then plug in the arduino. Kind of a pain if the power goes out or something while I've got the light show up and running. I figured I could just remotely start Vixen. Oh well I'm excited! Time to start sequencing.

  10. #10
    Join Date
    Sep 2010
    Location
    Clear Lake, TX
    Posts
    211
    Post Thanks / Like

    Default Re: Vixen Generic Serial Output controls the Arduino!

    I modified your code for 5 PWM and 20 On/off. I'm not sure if my SSR's that are coming will be able to do PWM so we'll see. Man this is easy! Thanks for the original 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
    Modifier: Ben Towner
    Modified: 19-OCT-2010
    Changes: Addition of 20 Digital On/Off Channels - Setup for Arduino Mega 2560
    
    */
    
    // PWM Output - ChanX=PWM Pin
    int Chan1 = 2;  
    int Chan2 = 3;  
    int Chan3 = 4;  
    int Chan4 = 5;  
    int Chan5 = 6;  
    
    // Digital Output - ChanX=Digital Pin
    int Chan6 = 22;  
    int Chan7 = 23;  
    int Chan8 = 24;  
    int Chan9 = 25;  
    int Chan10 = 26;  
    int Chan11 = 27;  
    int Chan12 = 28;  
    int Chan13 = 29;  
    int Chan14 = 30;  
    int Chan15 = 31; 
    int Chan16 = 32;  
    int Chan17 = 33;  
    int Chan18 = 34;  
    int Chan19 = 35;  
    int Chan20 = 36; 
    int Chan21 = 37;  
    int Chan22 = 38;  
    int Chan23 = 39;  
    int Chan24 = 40;  
    int Chan25 = 41; 
    
    
    int i = 0;     // Loop counter
    int incomingByte[25];   // array to store the 25 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);
      pinMode(Chan6, OUTPUT);   
      pinMode(Chan7, OUTPUT);
      pinMode(Chan8, OUTPUT);
      pinMode(Chan9, OUTPUT);
      pinMode(Chan10, OUTPUT);
      pinMode(Chan11, OUTPUT);   
      pinMode(Chan12, OUTPUT);
      pinMode(Chan13, OUTPUT);
      pinMode(Chan14, OUTPUT);
      pinMode(Chan15, OUTPUT);
      pinMode(Chan16, OUTPUT);   
      pinMode(Chan17, OUTPUT);
      pinMode(Chan18, OUTPUT);
      pinMode(Chan19, OUTPUT);
      pinMode(Chan20, OUTPUT);
      pinMode(Chan21, OUTPUT);   
      pinMode(Chan22, OUTPUT);
      pinMode(Chan23, OUTPUT);
      pinMode(Chan24, OUTPUT);
      pinMode(Chan25, OUTPUT);
    }
    
    void loop()
    {  // 25 channels are coming in to the Arduino
       if (Serial.available() >= 25) {
        // read the oldest byte in the serial buffer:
        for (int i=0; i<26; i++) {
          // read each byte
          incomingByte[i] = Serial.read();
        }
        
        analogWrite(Chan1, incomingByte[0]);   // Write current PWM values to LED pins
        analogWrite(Chan2, incomingByte[1]);   
        analogWrite(Chan3, incomingByte[2]);   
        analogWrite(Chan4, incomingByte[3]);   
        analogWrite(Chan5, incomingByte[4]);   
        digitalWrite(Chan6, incomingByte[5]);   // Write on/off values to LED pins
        digitalWrite(Chan7, incomingByte[6]);   
        digitalWrite(Chan8, incomingByte[7]);   
        digitalWrite(Chan9, incomingByte[8]);   
        digitalWrite(Chan10, incomingByte[9]); 
        digitalWrite(Chan11, incomingByte[10]);   
        digitalWrite(Chan12, incomingByte[11]);   
        digitalWrite(Chan13, incomingByte[12]);   
        digitalWrite(Chan14, incomingByte[13]);   
        digitalWrite(Chan15, incomingByte[14]);  
        digitalWrite(Chan16, incomingByte[15]);   
        digitalWrite(Chan17, incomingByte[16]);   
        digitalWrite(Chan18, incomingByte[17]);   
        digitalWrite(Chan19, incomingByte[18]);   
        digitalWrite(Chan20, incomingByte[19]);  
        digitalWrite(Chan21, incomingByte[20]);   
        digitalWrite(Chan22, incomingByte[21]);   
        digitalWrite(Chan23, incomingByte[22]);   
        digitalWrite(Chan24, incomingByte[23]);   
        digitalWrite(Chan25, incomingByte[24]);   
       }
    }

Page 1 of 18 12311 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •