Results 1 to 10 of 10

Thread: Success Modifying VictorPV Sketch to Accept Renard Protocol from ESPixelstick

  1. #1
    Join Date
    Dec 2014
    Location
    Southern California
    Posts
    328
    Post Thanks / Like

    Default Success Modifying VictorPV Sketch to Accept Renard Protocol from ESPixelstick

    I have succeded in modifying the sketch by VictorPV, that has become a staple of this forum, to accept Renard protocol. "Why would I do that" you ask? So that I can use an ESpixelstick to provide a datastream to my Arduino MEGA controller with AC/DC single light elements. The ESPixelstick has an option to provide the Renard protocol as an output even though it is receiving the data via E1.31. Now I can export my Vixen sequence to FPP running on a Pi and have the Pi communicate with the ESPixelsticks over wifi. I used Bill Porter's Arduino Renard library to make it work.


    Kevin



    Code:
    // WORKING VERSION WITH RENARD PROTOCOL USING SERIAL3 (PINS 14 TO FTDI RX AND 15 TO FTDI TX)
    
    // 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>
     
     // KG add for renard. Include the Arduino Renard library by Bill Porter
     #include <Arduino-Renard.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 48
    
     Renard renard; //KG add for renard
    
     byte incomingByte[CHANNEL_COUNT];  //KG add for renard
     
     // 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 A0
     #define CH02 A1
     #define CH03 A2
     #define CH04 A3
     #define CH05 A4
     #define CH06 A5
     #define CH07 A6
     #define CH08 A7
     #define CH09 A8
     #define CH10 A9
     #define CH11 A10
     #define CH12 A11
     #define CH13 A12
     #define CH14 A13
     #define CH15 A14
     #define CH16 A15
     #define CH17 38
     #define CH18 39
    // Up to here for Arduino uno.
     #define CH19 40
     #define CH20 41
     #define CH21 42
     #define CH22 43
     #define CH23 44
     #define CH24 45
     #define CH25 30
     #define CH26 31
     #define CH27 32
     #define CH28 33
     #define CH29 34
     #define CH30 35
     #define CH31 36
     #define CH32 37
     #define CH33 22
     #define CH34 23
     #define CH35 24
     #define CH36 25
     #define CH37 26
     #define CH38 27
     #define CH39 28
     #define CH40 29
     #define CH41 13
     #define CH42 12
     #define CH43 11
     #define CH44 10
     #define CH45 9
     #define CH46 8
     #define CH47 7
     #define CH48 6
     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};
    
     // KG subtract for renard - int incomingByte[CHANNEL_COUNT];
    
    int i = 0;     // Loop counter
    volatile unsigned long  timer_a = 0; // new line
    
    //setup the pins/ inputs & outputs
    void setup(){
    
    renard.begin((uint8_t*)&incomingByte, CHANNEL_COUNT, &Serial3, 57600); //KG add for renard
    
      // 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 (renard.receive()) {   //KG modified from VictorPV original
         wdt_reset(); // resets the watchdog
         timer_a = millis (); // new line
         int uno = Serial.read();
         //KG if (uno == 126){
           
         //KG  int dos = Serial.read();
         //KG  if (dos == 33){
       
         //KG    for (i=0; i < CHANNEL_COUNT; i++) {
         //KG        // read each byte
         //KG     incomingByte[i] = Serial.read();
         //KG    }
         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);
          }
          }
         }
    
          //KG  }
         //KG }
       }
    // 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);
       //kg delay (500);
      //kg digitalWrite(channels[i], HIGH);
       }
     }
    }
    Last edited by kev; 08-11-2017 at 11:49 AM.
    Kevin

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

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

    Default Re: Success Modifying VictorPV Sketch to Accept Renard Protocol from ESPixelstick

    Good work kev.

    How do you connect the ESpixelstick to the MEGA board? I haven't looked into the wifi stuff yet. Is it like a "shield" for the MEGA?

  3. #3
    Join Date
    Dec 2014
    Location
    Southern California
    Posts
    328
    Post Thanks / Like

    Default Re: Success Modifying VictorPV Sketch to Accept Renard Protocol from ESPixelstick

    Quote Originally Posted by LightUp View Post
    Good work kev.

    How do you connect the ESpixelstick to the MEGA board? I haven't looked into the wifi stuff yet. Is it like a "shield" for the MEGA?
    So far I have just been testing to a bare MEGA with three LEDs stuck in the output pins and the output of the ESPixelstick wired to Serial 3 pins. My shield will have to be modified to accept the ESPixelstick output. I have not done that yet. I was thinking of incorporating the ESP-01 module into a new shield design, but that will probably have to wait for next year. I wasn't sure if I would be using the MEGA based system until I got this RENARD/ESPixelstick stuff figured out. Next up I will be trying to modify ZParticle sketch to accept RENARD protocol so that I can continue to dim the props connected to the MEGA based system.
    Kevin

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

  4. #4
    Join Date
    Dec 2014
    Location
    Southern California
    Posts
    328
    Post Thanks / Like

    Default Am I a Criminal? Succes modifying ZParticle Sketch

    Am I a criminal? I feel like I did a drive by, smash and grab, slash and burn, or whatever cliche you want to add. I have 'modified' a piece of art found here on the forum to meet my needs. I am talking about ZParticle's 32 channel Arduino MEGA sketch. Yes, I have been successful in adapting it to accept the RENARD protocol. I have tested it by sending data from FPP running on a Pi-3 via wifi to a ESPixelstick comfigured for RENARD out (8 channels so far).

    I think that I will slink away for awhile now.
    Kevin

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

  5. #5
    Join Date
    Mar 2012
    Location
    Lebanon, Illinois, USA
    Posts
    1,759
    Post Thanks / Like

    Default Re: Success Modifying VictorPV Sketch to Accept Renard Protocol from ESPixelstick

    Criminal? Well that is between you, your victim, and the authorities. As far as taking something and making it work in a "different than designed way"... that is what DIY is all about.
    "Never Give Up. Never Surrender!"
    Capt Tagert - Galaxy Quest.
    Al Gerdes - Christmas Lighting Nut!

  6. #6
    Join Date
    Aug 2017
    Posts
    4
    Post Thanks / Like

    Default Re: Success Modifying VictorPV Sketch to Accept Renard Protocol from ESPixelstick

    I need some help! This is what I'm trying but its not working.


    Code:
    WORKING VERSION WITH RENARD PROTOCOL USING SERIAL3 (PINS 14 TO FTDI RX AND 15 TO FTDI TX)
    
    // 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>
     
     // KG add for renard. Include the Arduino Renard library by Bill Porter
     #include <Arduino-Renard.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 8
    
     Renard renard; //KG add for renard
    
     byte incomingByte[CHANNEL_COUNT];  //KG add for renard
     
     // 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
    // Up to here for Arduino uno.
    
     int channels[] = {CH01,CH02,CH03,CH04,CH05 ,CH06,CH07,CH08};
    
     // KG subtract for renard - int incomingByte[CHANNEL_COUNT];
    
    int i = 0;     // Loop counter
    volatile unsigned long  timer_a = 0; // new line
    
    //setup the pins/ inputs & outputs
    void setup(){
    
    renard.begin((uint8_t*)&incomingByte, CHANNEL_COUNT, &Serial3, 57600); //KG add for renard
    
      // 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 (renard.receive()) {   //KG modified from VictorPV original
         wdt_reset(); // resets the watchdog
         timer_a = millis (); // new line
         int uno = Serial.read();
         //KG if (uno == 126){
           
         //KG  int dos = Serial.read();
         //KG  if (dos == 33){
       
         //KG    for (i=0; i < CHANNEL_COUNT; i++) {
         //KG        // read each byte
         //KG     incomingByte[i] = Serial.read();
         //KG    }
         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);
          }
          }
         }
    
          //KG  }
         //KG }
       }
    // 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);
       //kg delay (500);
      //kg digitalWrite(channels[i], HIGH);
       }
     }
    }
    And I'm getting this error messege
    Arduino: 1.8.1 (Mac OS X), Board: "Arduino/Genuino Uno"

    In file included from /Users/Brandon/Documents/Arduino/Renard_ESPIXEL/Renard_ESPIXEL.ino:10:0:
    /Users/Brandon/Documents/Arduino/libraries/Arduino-Renard-master/Arduino-Renard.h:25:16: warning: extra tokens at end of #ifndef directive
    #ifndef Arduino-Renard_h
    ^
    /Users/Brandon/Documents/Arduino/libraries/Arduino-Renard-master/Arduino-Renard.h:26:16: warning: ISO C99 requires whitespace after the macro name
    #define Arduino-Renard_h
    ^
    Renard_ESPIXEL:1: error: 'WORKING' does not name a type
    WORKING VERSION WITH RENARD PROTOCOL USING SERIAL3 (PINS 14 TO FTDI RX AND 15 TO FTDI TX)
    ^
    /Users/Brandon/Documents/Arduino/Renard_ESPIXEL/Renard_ESPIXEL.ino: In function 'void setup()':
    Renard_ESPIXEL:53: error: 'Serial3' was not declared in this scope
    renard.begin((uint8_t*)&incomingByte, CHANNEL_COUNT, &Serial3, 57600); //KG add for renard
    ^
    Renard_ESPIXEL:56: error: 'wdt_enable' was not declared in this scope
    wdt_enable(WDTO_1S);
    ^
    exit status 1
    'WORKING' does not name a type

    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.
    Any suggestions?

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

    Default Re: Success Modifying VictorPV Sketch to Accept Renard Protocol from ESPixelstick

    Oops!! Sorry. Forgot to comment out "WORKING VERSION WITH RENARD PROTOCOL USING SERIAL3 (PINS 14 TO FTDI RX AND 15 TO FTDI TX)" at the top of the code. Add two slashes "//" in front of the first line.
    Kevin

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

  8. #8
    Join Date
    Aug 2017
    Posts
    4
    Post Thanks / Like

    Default Re: Success Modifying VictorPV Sketch to Accept Renard Protocol from ESPixelstick

    Doh! Just needed an extra set of eyes on it. Thanks, I'll try that out soon.

    Sent from my SM-J700T using Tapatalk

  9. #9
    Join Date
    Aug 2017
    Posts
    4
    Post Thanks / Like

    Default Re: Success Modifying VictorPV Sketch to Accept Renard Protocol from ESPixelstick

    Quote Originally Posted by kev View Post
    Oops!! Sorry. Forgot to comment out "WORKING VERSION WITH RENARD PROTOCOL USING SERIAL3 (PINS 14 TO FTDI RX AND 15 TO FTDI TX)" at the top of the code. Add two slashes "//" in front of the first line.
    Back to my computer, felt like an idiot missing that one. I'm new to coding and don't understand the debugging messages all that well, after looking back at it with a fresh brain I slapped myself. I just updated that with slashes and looked back over the code and couldn't find out why I was getting this though.

    It looks like you also have to change "Serial3" to "Serial" for the UNO
    Code:
    renard.begin((uint8_t*)&incomingByte, CHANNEL_COUNT, &Serial, 57600); //KG add for renard

  10. Likes kev liked this post
  11. #10
    Join Date
    Aug 2017
    Posts
    4
    Post Thanks / Like

    Default Re: Success Modifying VictorPV Sketch to Accept Renard Protocol from ESPixelstick

    Hooked it all up and it works! now to get the ESPixelstick and figure that out...
    Thanks again!

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
  •