Page 3 of 3 FirstFirst 123
Results 21 to 28 of 28

Thread: Arduino Intermittent connection with vixen

  1. #21
    Join Date
    Dec 2017
    Location
    Southeast Missouri
    Posts
    11
    Post Thanks / Like

    Default Re: Arduino Intermittent connection with vixen

    Just wanted to give a quick update on my progress in case someone else is experiencing this. I changed the victor code around to leave pin 13 unused for SSR and initialized it separately. Then at the beginning of the loop I set pin 13 low and at the end of the check for the ~ and the ! set it high. What that gave me was a visual indicator that the Arduino recognized the ~! header, and it sometimes does. When it's actually working the pin 13 LED flickers, since Vixen is sending constant data with headers. Except the first time after a reboot the pin 13 LED goes on and stays. It's almost like the board is locked up, even the reset button doesn't do anything. But if you close Vixen it goes back into random like nothing happened. There's something in the loop after the header check that my board doesn't like. If nothing else I can start commenting things out until it unlocks lol

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

    Default Re: Arduino Intermittent connection with vixen

    can you post your code? Maybe there is something that has changed that you are not aware of.
    Kevin

    2017 - Pi3 w/FPP controlling 8 ESPixelsticks driving 1250pixels and 3 Arduino MEGAS communicating with ESP-01s driving 96 channels
    2016 - 184 channels of Blinking/Flashing using 4 Arduino MEGAs and cheap home-made props.

  3. #23
    Join Date
    Dec 2017
    Location
    Southeast Missouri
    Posts
    11
    Post Thanks / Like

    Default Re: Arduino Intermittent connection with vixen

    The code I've been working from is
    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.
     
     // 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 16
    
     // 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 CH01 2
     #define CH02 3
     #define CH03 4
     #define CH04 5
     #define CH05 6
     #define CH06 7
     #define CH07 8
     #define CH08 9
     #define CH09 10
     #define CH10 11
     #define CH11 12
     #define CH12 14
     #define CH13 15
     #define CH14 16
     #define CH15 17
     #define CH16 18
     #define CH17 19
     #define CH18 20
     #define CH19 21
     #define CH20 22
     #define CH21 23
     #define CH22 24
     #define CH23 25
     #define CH24 26
     #define CH25 27
     #define CH26 28
     #define CH27 29
     #define CH28 30
     #define CH29 31
     #define CH30 32
     #define CH31 33
     #define CH32 34
     #define CH33 35
     #define CH34 36
     #define CH35 37
     #define CH36 38
     #define CH37 39
     #define CH38 40
     #define CH39 41
     #define CH40 42
     #define CH41 43
     #define CH42 44
     #define CH43 45
     #define CH44 46
     #define CH45 47
     #define CH46 48
     #define CH47 49
     #define CH48 50
     
     int channels[] = {CH01,CH02,CH03,CH04,CH05 ,CH06,CH07,CH08,CH09,
     CH10,CH11,CH12,CH13,CH14,CH15,CH16,CH17,CH18,CH19,CH20,CH21,CH22,
     CH23,CH24,CH25,CH26,CH27,CH28,CH29,CH30,CH31,CH32,CH33,CH34,CH35,
     CH36,CH37,CH38,CH39,CH40,CH41,CH42,CH43,CH44,CH45,CH46,CH47,CH48};
    
     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);
      }
    // initialize sync light pin
      {
      pinMode(13, 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()
    {
       digitalWrite(13, LOW);
       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){
             digitalWrite(13, HIGH);
             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);
       }
     }
    }
    The only changes I've made are to shift the channel pins up by 1 after pin 12 to open up pin 13 (onboard LED) and use it to indicate that the board recognizes the ~! header. What will happen is from a fresh boot if you open Vixen the "sync" light as I've been calling it lights up solid and stays that way until the watchdog restarts the Arduino. The TX/RX lights will continue to flicker as data comes from Vixen. One telling factor is that during the lockup even the hard reset button is ineffective. I thought that might indicate a hardware issue with my wiring but the board does the same thing (lock up after a fresh reboot of the computer) even when it's only connected to the USB and nothing else.
    Last edited by Nemisis; 12-16-2017 at 12:57 AM.

  4. #24
    Join Date
    Dec 2017
    Location
    Southeast Missouri
    Posts
    11
    Post Thanks / Like

    Default Re: Arduino Intermittent connection with vixen

    The code I've been working from is
    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.
     
     // 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 16
    
     // 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 CH01 2
     #define CH02 3
     #define CH03 4
     #define CH04 5
     #define CH05 6
     #define CH06 7
     #define CH07 8
     #define CH08 9
     #define CH09 10
     #define CH10 11
     #define CH11 12
     #define CH12 14
     #define CH13 15
     #define CH14 16
     #define CH15 17
     #define CH16 18
     #define CH17 19
     #define CH18 20
     #define CH19 21
     #define CH20 22
     #define CH21 23
     #define CH22 24
     #define CH23 25
     #define CH24 26
     #define CH25 27
     #define CH26 28
     #define CH27 29
     #define CH28 30
     #define CH29 31
     #define CH30 32
     #define CH31 33
     #define CH32 34
     #define CH33 35
     #define CH34 36
     #define CH35 37
     #define CH36 38
     #define CH37 39
     #define CH38 40
     #define CH39 41
     #define CH40 42
     #define CH41 43
     #define CH42 44
     #define CH43 45
     #define CH44 46
     #define CH45 47
     #define CH46 48
     #define CH47 49
     #define CH48 50
     
     int channels[] = {CH01,CH02,CH03,CH04,CH05 ,CH06,CH07,CH08,CH09,
     CH10,CH11,CH12,CH13,CH14,CH15,CH16,CH17,CH18,CH19,CH20,CH21,CH22,
     CH23,CH24,CH25,CH26,CH27,CH28,CH29,CH30,CH31,CH32,CH33,CH34,CH35,
     CH36,CH37,CH38,CH39,CH40,CH41,CH42,CH43,CH44,CH45,CH46,CH47,CH48};
    
     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);
      }
    // initialize sync light pin
      {
      pinMode(13, 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()
    {
       digitalWrite(13, LOW);
       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){
             digitalWrite(13, HIGH);
             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);
       }
     }
    }
    The only changes I've made are to shift the channel pins up by 1 after pin 12 to open up pin 13 (onboard LED) and use it to indicate that the board recognizes the ~! header. What will happen is from a fresh boot if you open Vixen the "sync" light as I've been calling it lights up solid and stays that way until the watchdog restarts the Arduino. The TX/RX lights will continue to flicker as data comes from Vixen. One telling factor is that during the lockup even the hard reset button is ineffective. I thought that might indicate a hardware issue with my wiring but the board does the same thing (lock up after a fresh reboot of the computer) even when it's only connected to the USB and nothing else.

  5. #25
    Join Date
    Dec 2014
    Location
    Southern California
    Posts
    638
    Post Thanks / Like

    Default Re: Arduino Intermittent connection with vixen

    you probably need to comment out the UNO specific line - add the two slashes and see what happens

    // specifically for the UNO
    //sei();
    Kevin

    2017 - Pi3 w/FPP controlling 8 ESPixelsticks driving 1250pixels and 3 Arduino MEGAS communicating with ESP-01s driving 96 channels
    2016 - 184 channels of Blinking/Flashing using 4 Arduino MEGAs and cheap home-made props.

  6. #26
    Join Date
    Dec 2017
    Location
    Southeast Missouri
    Posts
    11
    Post Thanks / Like

    Default Re: Arduino Intermittent connection with vixen

    Stayed up till 1am working on this silly thing, but I'm considering that it might not be software. I've discovered that I can consistently open Vixen the first time and let the board lock up, close Vixen and reopen and everything works as it's supposed to. I'm new to Arduino and just learned that it is default behavior to restart when a serial port is opened by the PC "unless you disable DTR". I also learned last night that it doesn't matter what the code is for this lockup to occur. So at this point I think I'm just going to have to accept that I'm not going to have an unattended startup, unless/until I learn how to read other serial ports on the Mega.

  7. #27
    Join Date
    Nov 2009
    Location
    Morrisburg, On, Canada
    Posts
    2,495
    Post Thanks / Like

    Default Re: Arduino Intermittent connection with vixen

    Quote Originally Posted by Nemisis View Post
    ... unless/until I learn how to read other serial ports on the Mega.
    That isn't difficult. Using a USB to TTL adapter connect a ground to MEGA ground and TX of the adapter to MEGA pin 19 (RX1) and wherever you have the vixen "serial" convert to "Serial1". This allows you to use the Serial.print() to print to the screen via Serial Monitor for debugging.

  8. #28
    Join Date
    Dec 2017
    Location
    Southeast Missouri
    Posts
    11
    Post Thanks / Like

    Default Re: Arduino Intermittent connection with vixen

    Quote Originally Posted by LightUp View Post
    That isn't difficult. Using a USB to TTL adapter connect a ground to MEGA ground and TX of the adapter to MEGA pin 19 (RX1) and wherever you have the vixen "serial" convert to "Serial1". This allows you to use the Serial.print() to print to the screen via Serial Monitor for debugging.
    Using serial1 instead of serial works beautifully, btw. Picked up a cheap USB to TTL on eBay, rewrote my sketch to not use pins 18 and 19 and my first run Vixen/Arduino problems went away. I also picked up a Dupont pin crimper, custom made all my harness wires, and have 48 on/off channels running.

Page 3 of 3 FirstFirst 123

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
  •