Page 3 of 12 FirstFirst 12345 ... LastLast
Results 21 to 30 of 112

Thread: Arduino Uno & Vixen 3: Need help with sketch

  1. #21
    Join Date
    Jul 2017
    Posts
    50
    Post Thanks / Like

    Default Re: Arduino Uno & Vixen 3: Need help with sketch

    Whether I run a show or just play the file in vixen I am fairly certain the LEDs are not following the vixen output; they just continue at random. Any ideas?

  2. #22
    Join Date
    Dec 2014
    Location
    Southern California
    Posts
    528
    Post Thanks / Like

    Default Re: Arduino Uno & Vixen 3: Need help with sketch

    now you have to make sure you have the Vixen generic serial controller setup correctly.
    You should have 57600 baud and you need to use a header of ~! .
    Kevin

    2016 - 184 channels of Blinking/Flashing using 4 Arduino MEGAs and cheap home-made props.

  3. #23
    Join Date
    Mar 2017
    Location
    Indiana
    Posts
    52
    Post Thanks / Like

    Default Re: Arduino Uno & Vixen 3: Need help with sketch

    I'm not an expert on how the Arduino serial communications queue and buffer, but it might be worth trying to look for only one byte at a time instead of 5. Here's one way that might work with the code in post 17:

    Code:
    void loop()
    {  // 5 channels are coming in to the Arduino
        // read the oldest byte in the serial buffer:
        for (int i=0; i<5; i++) {
          // read each byte
          while (Serial.available() <= 0) { }; // Wait until we have something
          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]);   
       }
    }
    Last edited by ShadowLight8; 10-28-2017 at 09:32 PM.
    2017: bit.ly/2zUzCC9

  4. #24
    Join Date
    Jul 2017
    Posts
    50
    Post Thanks / Like

    Default Re: Arduino Uno & Vixen 3: Need help with sketch

    Quote Originally Posted by kev View Post
    now you have to make sure you have the Vixen generic serial controller setup correctly.
    You should have 57600 baud and you need to use a header of ~! .
    Having difficulty changing baud rate in Vixen. I know where to access but when I change it, close dialogue box and reopen it diverts back to 9600. I will be looking into this. I changed the baud rates in the sketch and in device manager to 57600 but am having issues within vixen.

  5. #25
    Join Date
    Jul 2017
    Posts
    50
    Post Thanks / Like

    Default Re: Arduino Uno & Vixen 3: Need help with sketch

    Quote Originally Posted by ShadowLight8 View Post
    I'm not an expert on how the Arduino serial communications queue and buffer, but it might be worth trying to look for only one byte at a time instead of 5. Here's one way that might work with the code in post 17:

    Code:
    void loop()
    {  // 5 channels are coming in to the Arduino
        // read the oldest byte in the serial buffer:
        for (int i=0; i<5; i++) {
          // read each byte
          while (Serial.available() <= 0) { }; // Wait until we have something
          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]);   
       }
    }
    Shadowlight that looks very similar if not identical to one of the first few sketches I was trying. I think with either sketch the serial is not working it just so happened the 2nd one I tried had a random code when serial wasnt being sent so that the only reason I saw activity.

    I have triple checked and all of the coms and baud rates etc match and are set correctly. This is so frustrating.

  6. #26
    Join Date
    Jul 2017
    Posts
    50
    Post Thanks / Like

    Default Re: Arduino Uno & Vixen 3: Need help with sketch

    SUCCESS! I removed header and footer and it works perfectly?!?!?! Wow, what a freakin head thumping experience haha. Thank you guys for the help, I will tinker with this for a bit before I proceed with project.

  7. #27
    Join Date
    Dec 2014
    Location
    Southern California
    Posts
    528
    Post Thanks / Like

    Default Re: Arduino Uno & Vixen 3: Need help with sketch

    Did not know you had a footer. Try with just the ~! header.
    Kevin

    2016 - 184 channels of Blinking/Flashing using 4 Arduino MEGAs and cheap home-made props.

  8. #28
    Join Date
    Jul 2017
    Posts
    50
    Post Thanks / Like

    Default Re: Arduino Uno & Vixen 3: Need help with sketch

    Quote Originally Posted by kev View Post
    Did not know you had a footer. Try with just the ~! header.
    With header the lights continue to do same random blinking regardless of what vixen is sending. I may do a screen capture video and go through all of my settings. But without header and footer and it works perfect.

    Thanks again

  9. #29
    Join Date
    Dec 2014
    Location
    Southern California
    Posts
    528
    Post Thanks / Like

    Default Re: Arduino Uno & Vixen 3: Need help with sketch

    and you are using the sketch by Victor_PV that I suggested?
    Kevin

    2016 - 184 channels of Blinking/Flashing using 4 Arduino MEGAs and cheap home-made props.

  10. #30
    Join Date
    Jul 2017
    Posts
    50
    Post Thanks / Like

    Default Re: Arduino Uno & Vixen 3: Need help with sketch

    Quote Originally Posted by kev View Post
    and you are using the sketch by Victor_PV that I suggested?
    So to clear the confusion and maybe to be helpful for others I will post the two different codes I was working with. To answer your question KEV, no, I was using the original code that I posted at the beginning of this thread WITHOUT header and footer. When I used victor_PV code I had to have the "~!" header with NO footer; I dont know why this was the case but once I set up Vixen differently when each of these codes were ran they both performed identical. Any thoughts as to why? The victor_PV code does do the random lights until vixen is started so thats pretty cool but again, once my sequence began in vixen both codes were identical.

    Victor_PV Code with header and no footer
    Code:
     // This code was written by Victor Perez for doityourselfchristmas.com based on the code from Zparticle, Si_champion and Neil Tapp.
     // To adapt the code to your case, just change this top section, with the #define lines.
    
     //MUST USE HEADER "~!" IN VIXEN, DO NOT USE FOOTER
     
     // Includes the watchdog timer library
     #include <avr/wdt.h>
     
     // This sets how many channels will vixen be sending. Can be set to any number from 1 to 48 for Arduino Mega, and 1 to 18 for Arduino Uno.
     #define CHANNEL_COUNT 5
    
     // speed for the com port for talking with vixen. From 9600 to 115200. Use the same speed as set in Vixen.
     #define VIXEN_COM_SPEED 57600
     
     // Timeout waiting for serial input before going to random mode (in milliseconds).
     #define TIME_OUT 1000
     
     // If the relays turn On and Off opposite to Vixen sequence, change "#define MODE NOT_INVERTED" for "#define MODE INVERTED"
     #define NOT_INVERTED 0
     #define INVERTED 1
     #define MODE NOT_INVERTED
    
     // which pins control which channels
     // You can change these assignment to use different pins, but be very careful to not repeat the same pin number for 2 channels. 
     // DO NOT use pings 0 and 1, as those are for the serial port to talk to the computer.
    
     #define CH05 5
     #define CH06 6
     #define CH11 11
     #define CH09 9
     #define CH10 10
    
    // Up to here for Arduino uno.
    
     
     int channels[] = {CH05,CH06,CH09,CH10,CH11};
    
     int incomingByte[CHANNEL_COUNT];
    
    int i = 0;     // Loop counter
    volatile unsigned long  timer_a = 0; // new line
    
    //setup the pins/ inputs & outputs
    void setup(){
    
      // enable the watchdog timer with a time of 1 second. If the board freezes, it will reset itself after 1 second.
      wdt_enable(WDTO_1S);
      
      // specifically for the UNO
      sei();  
    
    // initalize PWM Channels / Pins
     for (i=0; i < CHANNEL_COUNT; i++){
        pinMode(channels[i], OUTPUT);
      }
    
    // set all the realys to off to start with
    if (MODE == NOT_INVERTED) {
     for (i=0; i < CHANNEL_COUNT; i++){
         digitalWrite(channels[i], LOW);
    
     }
    }
    
    else {
     for (i=0; i < CHANNEL_COUNT; i++){
         digitalWrite(channels[i], HIGH);
     }
    }
    
     testSequence();
     
    // set up Serial according to the speed defined above.
      Serial.begin(VIXEN_COM_SPEED);
    }
    
    void loop()
    {
       if (Serial.available() >= (CHANNEL_COUNT+2)) {
         wdt_reset(); // resets the watchdog
         timer_a = millis (); // new line
         int uno = Serial.read();
         if (uno == 126){
           
           int dos = Serial.read();
           if (dos == 33){
       
             for (i=0; i < CHANNEL_COUNT; i++) {
                 // read each byte
              incomingByte[i] = Serial.read();
             }
         if (MODE == NOT_INVERTED) {
          for (i=0; i < CHANNEL_COUNT; i++){
          int value = incomingByte[i];
          if (value <= 127) {
            digitalWrite(channels[i], LOW);
          }
          else {
            digitalWrite(channels[i], HIGH);
          }
          }
         }
         else {
         for (i=0; i < CHANNEL_COUNT; i++){
          int value = incomingByte[i];
          if (value < 127) {
            digitalWrite(channels[i], HIGH);
          }
          else {
            digitalWrite(channels[i], LOW);
          }
          }
         }
    
           }
         }
       }
    // Random mode code. Random mode starts if no serial input has been received in TIME_OUT millisenconds
       else {
         wdt_reset(); // resets the watchdog
         unsigned long diff = millis() - timer_a;
         if (diff >= TIME_OUT) {
           timer_a = millis ();
           int random_a = 0;
           for (i=0; i < CHANNEL_COUNT; i++){
             random_a = random(0, 2);
             if (random_a == 0) {
               digitalWrite(channels[i], LOW);
             }
             else {
               digitalWrite(channels[i], HIGH);
             }
           }
         }
       }
    }
    
    void testSequence(){
    
    if (MODE == NOT_INVERTED) {
     for (i=0; i < CHANNEL_COUNT; i++){
       wdt_reset(); // resets the watchdog
       digitalWrite(channels[i], HIGH);
       delay (500);
       digitalWrite(channels[i], LOW);
     }
    }
    
    else {
     for (i=0; i < CHANNEL_COUNT; i++){
       wdt_reset(); // resets the watchdog
       digitalWrite(channels[i], LOW);
       delay (500);
       digitalWrite(channels[i], HIGH);
       }
     }
    }
    Original Code (Not mine but something I was using originally) No Header or Footer in Vixen
    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
    DO NOT USE HEADER OR FOOTER IN VIXEN
    */
     
    // PWM Output - ChanX=PWM Pin
    int Chan1 = 5;  
    int Chan2 = 6;  
    int Chan3 = 9;  
    int Chan4 = 10;  
    int Chan5 = 11;  
     
     
    int i = 0;     // Loop counter
    int incomingByte[5];   // array to store the 5 values from the serial port
     
    //setup the pins/ inputs & outputs
    void setup()
    {
      Serial.begin(57600);        // 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()
    {  // 5 channels are coming in to the Arduino
       if (Serial.available() >= 5) {
        // read the oldest byte in the serial buffer:
        for (int i=0; i<5; 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]);   
       }
    }
    My arduino was setup as shown in the attached PDF in post #17

    Thanks!

Page 3 of 12 FirstFirst 12345 ... LastLast

Tags for this Thread

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
  •