Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: Audrino + high power relays not working with vixen 2.0

  1. #11
    Join Date
    Nov 2016
    Posts
    13
    Post Thanks / Like

    Default Re: Audrino + high power relays not working with vixen 2.0

    it was copied how the cheep skate aka DEE Higgins said to is this not correct?

  2. #12
    Join Date
    Nov 2009
    Location
    Morrisburg, On, Canada
    Posts
    2,540
    Post Thanks / Like

    Default Re: Audrino + high power relays not working with vixen 2.0

    This code can work most of the time if the Arduino is running before Vixen starts. You are not using a header in your sketch so you can't tell when Vixen is at the beginning of the sequence. So one would assume that the Arduino can easily keep up with the Vixen data, until a power glitch causes the Arduino to forget where it was in the data train and thus lose synch.

    Your relays most likely are active LOW while Vixen data is active HIGH. This means your lights will operate opposite.
    One way to fix this is to use the following code for your last line of code;
    for (i = 0; i < MAX_CHANNELS; i ++ ) digitalWrite(channels[i], ~incomingByte[i]);
    This should invert your Vixen data.

    Also use digitalWrite instead of analogWrite as your relays can only do on/off lighting, not dimming.

    Have you set the Generic Serial, in Vixen, for 9600 baud?
    Last edited by LightUp; 12-20-2018 at 12:58 AM.

  3. #13
    Join Date
    Dec 2012
    Location
    Hudson MA
    Posts
    3,357
    Post Thanks / Like

    Default Re: Audrino + high power relays not working with vixen 2.0

    as mentioned. this sketch has lots of issues. go het the one jcook posted and you will be good to go.


    2018 - Moving and going to visit my Daughter in New Zealand. Most likely I will be dark or nearly dark, Some static stuff that is simple to put up.

  4. #14
    Join Date
    Nov 2015
    Posts
    32
    Post Thanks / Like

    Default Re: Audrino + high power relays not working with vixen 2.0

    Here is the Sketch I use:

    Code:
    // Copy from this line down to your new sketch
    // 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.
    // 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 20000
    
    // 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. 
    // which pins control which channels
    #define CHANNEL01 2
    #define CHANNEL02 3
    #define CHANNEL03 4
    #define CHANNEL04 5
    #define CHANNEL05 6
    #define CHANNEL06 7
    #define CHANNEL07 8
    #define CHANNEL08 9
    #define CHANNEL09 10
    #define CHANNEL10 11
    #define CHANNEL11 12
    #define CHANNEL12 13
    #define CHANNEL13 14
    #define CHANNEL14 15
    #define CHANNEL15 16
    #define CHANNEL16 17
    
    int channels[] = {CHANNEL01, CHANNEL02, CHANNEL03, CHANNEL04, CHANNEL05, CHANNEL06, CHANNEL07, CHANNEL08, CHANNEL09, CHANNEL10, CHANNEL11, CHANNEL12, CHANNEL13, CHANNEL14, CHANNEL15, CHANNEL16};
    
    int incomingByte[CHANNEL_COUNT];
    
    int i = 0;     // Loop counter
    
    volatile unsigned long timer_a = 0; // new line
    
    //setup the pins/ inputs & outputs
    void setup() {
    
      // specifically for the UNO
      //sei();  
    
    // initalize PWM Channels / Pins
      for (i = 0; i < CHANNEL_COUNT; i++) {
        pinMode(channels[i], OUTPUT);
      }
    
    // set all the relays 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)) {
        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], LOW);
                } else {
                  digitalWrite(channels[i], HIGH);
                }
              }
            }
    
          }
        }
      }
    // Random mode code. Random mode starts if no serial input has been received in TIME_OUT millisenconds
      else {
      //turn them all on
            unsigned long diff = millis() - timer_a;
            if (diff >= TIME_OUT) {
             timer_a = millis ();
             turnLightsOn();
      }
    }
    }
    
    void testSequence() {
    
      if (MODE == NOT_INVERTED) {
        for (i = 0; i < CHANNEL_COUNT; i++) {
          digitalWrite(channels[i], LOW);
          delay(120);
          digitalWrite(channels[i], LOW);
          
        }
      }
    
      else {
        for (i = 0; i < CHANNEL_COUNT; i++) {
          digitalWrite(channels[i], LOW);
          delay(500);
          digitalWrite(channels[i], LOW);
        }
      }
    }
    
    void turnLightsOn()
    {
      for (i = 0; i < CHANNEL_COUNT; i++) {
      digitalWrite(channels[i], HIGH);
      }
    }

  5. #15
    Join Date
    Nov 2015
    Posts
    32
    Post Thanks / Like

    Default Re: Audrino + high power relays not working with vixen 2.0

    Use ~! for the header in Controller setup in Vixen and make sure the baud rate in vixen and the sketch/code above match.

  6. #16
    Join Date
    Dec 2012
    Location
    Hudson MA
    Posts
    3,357
    Post Thanks / Like

    Default Re: Audrino + high power relays not working with vixen 2.0

    At least there is a single byte sync character. You still have to wait for all of the data to come in. That adds unneeded delay in processing the data.


    2018 - Moving and going to visit my Daughter in New Zealand. Most likely I will be dark or nearly dark, Some static stuff that is simple to put up.

  7. #17
    Join Date
    Dec 2014
    Location
    Southern California
    Posts
    767
    Post Thanks / Like

    Default Re: Audrino + high power relays not working with vixen 2.0

    I have looked for the sketch from jcook that you reference but am unsure if I found the correct one. Can you post a link to the thread/sketch you are referring to?

    Thanks.
    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.

  8. #18
    Join Date
    Dec 2012
    Location
    Hudson MA
    Posts
    3,357
    Post Thanks / Like

    Default Re: Audrino + high power relays not working with vixen 2.0

    http://doityourselfchristmas.com/for...hlight=el-wire

    It was developed for xbee but any type of serial will do.


    2018 - Moving and going to visit my Daughter in New Zealand. Most likely I will be dark or nearly dark, Some static stuff that is simple to put up.

  9. #19
    Join Date
    Nov 2009
    Location
    Morrisburg, On, Canada
    Posts
    2,540
    Post Thanks / Like

    Default Re: Audrino + high power relays not working with vixen 2.0

    Quote Originally Posted by MartinMueller2003 View Post
    http://doityourselfchristmas.com/for...hlight=el-wire

    It was developed for xbee but any type of serial will do.
    In the jcook code how do you invert Vixen data?

    Using this line of code; digitalWrite(XlatIndexToPin[CurrentChannelIndex], (Serial.read() < CHANNEL_TRIGGER_LEVEL) ? CHAN_OFF : CHAN_ON);

    Do you substitute "<" with ">", or switch the "CHAN_OFF" with "CHAN_ON"? I haven't seen this style of coding within a digitalWrite function.
    Last edited by LightUp; 12-21-2018 at 12:15 PM.

  10. #20
    Join Date
    Dec 2012
    Location
    Hudson MA
    Posts
    3,357
    Post Thanks / Like

    Default Re: Audrino + high power relays not working with vixen 2.0

    Change the definition of CHAN-OFF and CHAN_ON at the top of the file. The intent of those definitions is to make the logic in the setup and channel output consistent. Define the proper values for On and OFF and let the rest of the code stay simple.

    The code in the digital write is a short form embedded 'if' statement that lets you dynamically select which parameter to send to the digital write call.
    Last edited by MartinMueller2003; 12-21-2018 at 05:28 PM.


    2018 - Moving and going to visit my Daughter in New Zealand. Most likely I will be dark or nearly dark, Some static stuff that is simple to put up.

Page 2 of 2 FirstFirst 12

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
  •