Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 40

Thread: Custom Arduino-based Renard-to-GECE controller (codename horae)

  1. #21
    Join Date
    Sep 2010
    Location
    Clear Lake, TX
    Posts
    211

    Default Re: Custom Arduino-based Renard-to-GECE controller (codename horae)

    Final code. Just make adjustments to the defined variables and you are off and running. I've run successfully at 3 groups of 12 channels (36 ct string). I went to 1 group of 36 channels and I can use the test channel form in the sequence to turn every pixel on but running a sequence wont work. I'm thinking that there is a buffer I'm hitting. Anyway 12 channels per string is plenty for me this year.

    Code:
    #define XMAS_PIN 8
    #define xmas_color_t uint16_t
     
    #define XMAS_LIGHT_COUNT    (36)
    #define XMAS_GROUP_COUNT    (3) 
    #define XMAS_GROUP_LIGHT_COUNT    (12)  
     
    #define XMAS_CHANNEL_MAX          (0xF)
    #define XMAS_DEFAULT_INTENSITY     (0xCC)
    #define XMAS_COLOR(r,g,b)     ((r)+((g)<<4)+((b)<<8))
    #define XMAS_COLOR_WHITE     XMAS_COLOR(XMAS_CHANNEL_MAX,XMAS_CHANNEL_MAX,XMAS_CHANNEL_MAX)
    #define XMAS_COLOR_BLACK     XMAS_COLOR(0,0,0)
    #define XMAS_COLOR_BLUE     XMAS_COLOR(0,0,XMAS_CHANNEL_MAX)
     
    bool sync;
     
    void xmas_begin(uint8_t pin);
    void xmas_one(uint8_t pin);
    void xmas_zero(uint8_t pin);
    void xmas_end(uint8_t pin);
     
    void xmas_begin(uint8_t pin)
    {
      digitalWrite(pin,1);
      delayMicroseconds(7);
      digitalWrite(pin,0);
    }
     
    void xmas_one(uint8_t pin)
    {
      digitalWrite(pin,0);
      delayMicroseconds(11); //This results in a 20 uS long low
      digitalWrite(pin,1);
      delayMicroseconds(7);
      digitalWrite(pin,0);
    }
     
    void xmas_zero(uint8_t pin)
    {
      digitalWrite(pin,0);
      delayMicroseconds(2);
      digitalWrite(pin,1);
      delayMicroseconds(20-3);
      digitalWrite(pin,0);
    }
     
    void xmas_end(uint8_t pin)
    {
      digitalWrite(pin,0);
      delayMicroseconds(40); // Can be made shorter
    }
     
    void xmas_set_color(uint8_t led,uint8_t intensity,xmas_color_t color, uint8_t pin)
    {
      uint8_t i;
     
      cli(); //Disable interrupts while we write to GECEs
      xmas_begin(pin);
     
      //6-Bit bulb address (MSB first)
      for(i=6;i;i--,(led<<=1))
      {
        if(led&(1<<5))
          xmas_one(pin);
        else
          xmas_zero(pin);
      }
     
      //8-Bit brightness (MSB first)
      for(i=8;i;i--,(intensity<<=1))
      {
        if(intensity&(1<<7))
          xmas_one(pin);
        else
          xmas_zero(pin);
      }
     
      //12 bit Color (Blue, Green, Red) (MSB first)
      for(i=12;i;i--,(color<<=1))
      {
        if(color&(1<<11))
          xmas_one(pin);
        else
          xmas_zero(pin);
      }
     
      xmas_end(pin);
      sei(); //Re-enable interrupts now that we're done writing to GECEs
    }
    
    void xmas_set_group_address(uint8_t pin)
    {
      for (int i = 0; i < XMAS_GROUP_COUNT; ++i)
      {
        for (int k = 0; k < XMAS_GROUP_LIGHT_COUNT; ++k)
        {
         xmas_set_color(k,XMAS_DEFAULT_INTENSITY,XMAS_COLOR_BLACK,pin);
        }
      }
    }
     
    void xmas_set_all_one_address(uint8_t pin)
    {
      for (int i = 0; i < XMAS_LIGHT_COUNT; ++i)
        xmas_set_color(0,XMAS_DEFAULT_INTENSITY,XMAS_COLOR_BLACK,pin);
    }
     
    void setup()
    {
      delay(10);
      Serial.begin(57600);
      delay(10);
     
      pinMode(5, OUTPUT);
      digitalWrite(5, LOW);
     
      pinMode(XMAS_PIN, OUTPUT);
      digitalWrite(XMAS_PIN, 0);
      xmas_set_group_address(XMAS_PIN);
     
      sync = false;
    }
     
    void wait_for_serial()
    {
        while ( ! Serial.available() > 0 ) { }
    }
     
    int renardReadBytes( uint8_t *bytes, uint8_t bytes_size )
    {
      int in_byte = 0;
      int bytes_read;
     
      for ( bytes_read = 0; bytes_read < bytes_size; )
      {
        wait_for_serial();
        in_byte = Serial.read();
     
        switch (in_byte)
        {
          case(0x7E): // We saw the sync byte, start over!
            sync = true;
            return bytes_read;
     
          case(0x7D): // Skip the pad byte
            continue;
     
          case(0x7F): // Escape character, we need to read one more byte to get our actual data
            wait_for_serial();
            in_byte = Serial.read();
            switch (in_byte)
              {
                case(0x2F): // renard wants an 0x7D
                  in_byte = 0x7D;
                case(0x30): // renard wants an 0x7E
                  in_byte = 0x7E;
                case(0x31): // renard wants an 0x7F
                  in_byte = 0x7F;
              }
            }
     
        bytes[bytes_read++] = in_byte;
      }
     
      return bytes_read;
    }
     
    int renardRead( uint8_t *bytes, uint8_t byte_count )
    {
      int in_byte = 0;
     
      while ( ! sync )
      {
        wait_for_serial();
        in_byte = Serial.read();
        if ( in_byte == 0x7E ) // Sync byte signifies start of packet
          sync = true;
      }
     
      if ( sync )
      {
        sync = false;
        wait_for_serial();
        in_byte = Serial.read();
        if ( in_byte == 0x80 ) // Read from here
        {
          return renardReadBytes(bytes, byte_count);
        }
      }
     
      return 0;
    }
     
    void loop()
    {
      int nbr_bytes = XMAS_GROUP_LIGHT_COUNT * 4;
      uint8_t bytes[nbr_bytes], bytes_read;
      bytes_read = renardRead(&bytes[0], nbr_bytes);
     
      if ( bytes_read == nbr_bytes )
      {
        // We have now received 4 bytes of data per string, do something with them!
      
          uint8_t red;
          uint8_t green;
          uint8_t blue;
          uint8_t white;
          int b = 0;
    
        for (int i=0; i < XMAS_GROUP_LIGHT_COUNT; ++i)
        {
          red = bytes[b];
          b++;
          green = bytes[b];
          b++;
          blue  = bytes[b];
          b++;
          white  = bytes[b];
          b++;
          
          red = ( red+(white/3) >= (XMAS_CHANNEL_MAX<<4) ? (XMAS_CHANNEL_MAX<<4) : red+(white/3) );
          green = ( green+(white/3) >= (XMAS_CHANNEL_MAX<<4) ? (XMAS_CHANNEL_MAX<<4) : green+(white/3) );
          blue = ( blue+(white/3) >= (XMAS_CHANNEL_MAX<<4) ? (XMAS_CHANNEL_MAX<<4) : blue+(white/3) );
       
          xmas_set_color(i,XMAS_DEFAULT_INTENSITY,XMAS_COLOR((red>>4),(green>>4),(blue>>4)),XMAS_PIN);
        }
      }
    }
    Quote Originally Posted by dirknerkle View Post
    Well done! You will become the WiznetWizard!
    Level UP!

  2. #22

    Default Re: Custom Arduino-based Renard-to-GECE controller (codename horae)

    deleted
    Last edited by Teraphim; 06-09-2012 at 06:58 PM. Reason: wrong topic

  3. #23
    Join Date
    Sep 2010
    Location
    Clear Lake, TX
    Posts
    211

    Default Re: Custom Arduino-based Renard-to-GECE controller (codename horae)

    Well, I think I'm just going to have to break down and buy the e681. I'm having an issue with the Arduino reading data from the start of a sequence. I have to start my 140 channel sequence at 1.5 seconds before sending any data. If I send the data as soon as it starts nothing happens. If I wait 1.5 seconds everything works just fine. I also cannot start in the middle of a sequence. I'm thinking that it has something to do with the sync byte and/or that the connection takes a while to open on the Arduino. Materdaddy did you have any of these issues?
    Last edited by chesterspot; 06-15-2012 at 02:57 PM.
    Quote Originally Posted by dirknerkle View Post
    Well done! You will become the WiznetWizard!
    Level UP!

  4. #24
    Join Date
    Dec 2010
    Location
    Oceanside, CA
    Posts
    2,095

    Default Re: Custom Arduino-based Renard-to-GECE controller (codename horae)

    I never tried putting my data at the beginning of the channel count, but in theory, I don't see how that could be a problem. Mind sending me your code, and some steps to reproduce? I have a logic I can use to look at the data and try to debug the problem.
    The perfect is the enemy of the good. -Voltaire

    Click here to show/hide my display details ...

  5. #25
    Join Date
    Sep 2010
    Location
    Clear Lake, TX
    Posts
    211

    Default Re: Custom Arduino-based Renard-to-GECE controller (codename horae)

    I didn't explain correctly. Data meant sequence data. If I start my sequence and with sequence data being sent at the :00 mark the GECE's dont respond. If I don't send any sequence data for 1.5 sec then the GECE's respond. If I use the channel tester I can step through every channel with no problem. I am sending channels 105-140 via the Renard plug-in, protocol 1, 57600, 8, 1, None. Thanks for your help.

    Code:
    #define XMAS_PIN 8
    #define xmas_color_t uint16_t
     
    #define XMAS_LIGHT_COUNT    (36)
    #define XMAS_GROUP_COUNT    (3) 
    #define XMAS_GROUP_LIGHT_COUNT    (12)  
     
    #define XMAS_CHANNEL_MAX          (0xF)
    #define XMAS_DEFAULT_INTENSITY     (0xCC)
    #define XMAS_COLOR(r,g,b)     ((r)+((g)<<4)+((b)<<8))
    #define XMAS_COLOR_WHITE     XMAS_COLOR(XMAS_CHANNEL_MAX,XMAS_CHANNEL_MAX,XMAS_CHANNEL_MAX)
    #define XMAS_COLOR_BLACK     XMAS_COLOR(0,0,0)
    #define XMAS_COLOR_BLUE     XMAS_COLOR(0,0,XMAS_CHANNEL_MAX)
     
    bool sync;
     
    void xmas_begin(uint8_t pin);
    void xmas_one(uint8_t pin);
    void xmas_zero(uint8_t pin);
    void xmas_end(uint8_t pin);
     
    void xmas_begin(uint8_t pin)
    {
      digitalWrite(pin,1);
      delayMicroseconds(7);
      digitalWrite(pin,0);
    }
     
    void xmas_one(uint8_t pin)
    {
      digitalWrite(pin,0);
      delayMicroseconds(11); //This results in a 20 uS long low
      digitalWrite(pin,1);
      delayMicroseconds(7);
      digitalWrite(pin,0);
    }
     
    void xmas_zero(uint8_t pin)
    {
      digitalWrite(pin,0);
      delayMicroseconds(2);
      digitalWrite(pin,1);
      delayMicroseconds(20-3);
      digitalWrite(pin,0);
    }
     
    void xmas_end(uint8_t pin)
    {
      digitalWrite(pin,0);
      delayMicroseconds(40); // Can be made shorter
    }
     
    void xmas_set_color(uint8_t led,uint8_t intensity,xmas_color_t color, uint8_t pin)
    {
      uint8_t i;
     
      cli(); //Disable interrupts while we write to GECEs
      xmas_begin(pin);
     
      //6-Bit bulb address (MSB first)
      for(i=6;i;i--,(led<<=1))
      {
        if(led&(1<<5))
          xmas_one(pin);
        else
          xmas_zero(pin);
      }
     
      //8-Bit brightness (MSB first)
      for(i=8;i;i--,(intensity<<=1))
      {
        if(intensity&(1<<7))
          xmas_one(pin);
        else
          xmas_zero(pin);
      }
     
      //12 bit Color (Blue, Green, Red) (MSB first)
      for(i=12;i;i--,(color<<=1))
      {
        if(color&(1<<11))
          xmas_one(pin);
        else
          xmas_zero(pin);
      }
     
      xmas_end(pin);
      sei(); //Re-enable interrupts now that we're done writing to GECEs
    }
    
    void xmas_set_group_address(uint8_t pin)
    {
      for (int i = 0; i < XMAS_GROUP_COUNT; ++i)
      {
        for (int k = 0; k < XMAS_GROUP_LIGHT_COUNT; ++k)
        {
         xmas_set_color(k,XMAS_DEFAULT_INTENSITY,XMAS_COLOR_BLACK,pin);
        }
      }
    }
     
    void xmas_set_all_one_address(uint8_t pin)
    {
      for (int i = 0; i < XMAS_LIGHT_COUNT; ++i)
        xmas_set_color(0,XMAS_DEFAULT_INTENSITY,XMAS_COLOR_BLACK,pin);
    }
     
    void setup()
    {
      delay(10);
      Serial.begin(57600);
      delay(10);
     
      pinMode(5, OUTPUT);
      digitalWrite(5, LOW);
     
      pinMode(XMAS_PIN, OUTPUT);
      digitalWrite(XMAS_PIN, 0);
      xmas_set_group_address(XMAS_PIN);
     
      sync = false;
    }
     
    void wait_for_serial()
    {
        while ( ! Serial.available() > 0 ) { }
    }
     
    int renardReadBytes( uint8_t *bytes, uint8_t bytes_size )
    {
      int in_byte = 0;
      int bytes_read;
     
      for ( bytes_read = 0; bytes_read < bytes_size; )
      {
        wait_for_serial();
        in_byte = Serial.read();
     
        switch (in_byte)
        {
          case(0x7E): // We saw the sync byte, start over!
            sync = true;
            return bytes_read;
     
          case(0x7D): // Skip the pad byte
            continue;
     
          case(0x7F): // Escape character, we need to read one more byte to get our actual data
            wait_for_serial();
            in_byte = Serial.read();
            switch (in_byte)
              {
                case(0x2F): // renard wants an 0x7D
                  in_byte = 0x7D;
                case(0x30): // renard wants an 0x7E
                  in_byte = 0x7E;
                case(0x31): // renard wants an 0x7F
                  in_byte = 0x7F;
              }
            }
     
        bytes[bytes_read++] = in_byte;
      }
     
      return bytes_read;
    }
     
    int renardRead( uint8_t *bytes, uint8_t byte_count )
    {
      int in_byte = 0;
     
      while ( ! sync )
      {
        wait_for_serial();
        in_byte = Serial.read();
        if ( in_byte == 0x7E ) // Sync byte signifies start of packet
          sync = true;
      }
     
      if ( sync )
      {
        sync = false;
        wait_for_serial();
        in_byte = Serial.read();
        if ( in_byte == 0x80 ) // Read from here
        {
          return renardReadBytes(bytes, byte_count);
        }
      }
     
      return 0;
    }
     
    void loop()
    {
      //int nbr_bytes = XMAS_GROUP_LIGHT_COUNT * 3;
      int nbr_bytes = 36;
      uint8_t bytes[nbr_bytes], bytes_read;
      bytes_read = renardRead(&bytes[0], nbr_bytes);
     
      if ( bytes_read == nbr_bytes )
      {
        // We have now received 36 bytes of data per string, do something with them!
      
          uint8_t red;
          uint8_t green;
          uint8_t blue;
          int b = 0;
    
        for (int i=0; i < XMAS_GROUP_LIGHT_COUNT; ++i)
        {
          red = bytes[b];
          b++;
          green = bytes[b];
          b++;
          blue  = bytes[b];
          b++;
          
      red = ( red >= (XMAS_CHANNEL_MAX<<4) ? (XMAS_CHANNEL_MAX<<4) : red );
      green = ( green >= (XMAS_CHANNEL_MAX<<4) ? (XMAS_CHANNEL_MAX<<4) : green );
      blue = ( blue >= (XMAS_CHANNEL_MAX<<4) ? (XMAS_CHANNEL_MAX<<4) : blue );
    
      xmas_set_color(i,XMAS_DEFAULT_INTENSITY,XMAS_COLOR ((red>>4),(green>>4),(blue>>4)),XMAS_PIN);
         }
      }
    }
    Quote Originally Posted by dirknerkle View Post
    Well done! You will become the WiznetWizard!
    Level UP!

  6. #26
    Join Date
    Dec 2010
    Location
    Oceanside, CA
    Posts
    2,095

    Default Re: Custom Arduino-based Renard-to-GECE controller (codename horae)

    That sounds like a vixen output plugin problem, or did you power up the arduino right when you started the data? I'm confused. I'll try doing a little tinkering. Do you have any info on the number of channels, timing, vixen version, etc.?
    The perfect is the enemy of the good. -Voltaire

    Click here to show/hide my display details ...

  7. #27
    Join Date
    Sep 2010
    Location
    Clear Lake, TX
    Posts
    211

    Default Re: Custom Arduino-based Renard-to-GECE controller (codename horae)

    It has something to do with the amount of channels there are. When I ran a sequence with 12 channels (RGB) I can start the sequence at :00. The more channels I add the more time I have to give before starting to send sequence data. I think it has something to do with the Arduino's ability to read in 140 channels worth of data. Once data is started and flowing everything works just fine. Arduino was plugged in many minutes before starting the sequence and about 30sec after the GECE's. I've tried everything and the fact that the lights respond to the channel tester tells me that something gets lost in that first data sent. Could it be that with that many channels the Arduino is missing the sync byte? I didn't bring the GECE's and Arduino to work today so I'll have to look at it this weekend. I'll let you know how it goes.

    Vixen 2.5.0
    Timing 50ms
    Channels 140
    Renard Output-Channels 105-140(GECE).
    Quote Originally Posted by dirknerkle View Post
    Well done! You will become the WiznetWizard!
    Level UP!

  8. #28
    Join Date
    Dec 2010
    Location
    Oceanside, CA
    Posts
    2,095

    Default Re: Custom Arduino-based Renard-to-GECE controller (codename horae)

    Quote Originally Posted by chesterspot View Post
    It has something to do with the amount of channels there are. When I ran a sequence with 12 channels (RGB) I can start the sequence at :00. The more channels I add the more time I have to give before starting to send sequence data. I think it has something to do with the Arduino's ability to read in 140 channels worth of data. Once data is started and flowing everything works just fine. Arduino was plugged in many minutes before starting the sequence and about 30sec after the GECE's. I've tried everything and the fact that the lights respond to the channel tester tells me that something gets lost in that first data sent. Could it be that with that many channels the Arduino is missing the sync byte? I didn't bring the GECE's and Arduino to work today so I'll have to look at it this weekend. I'll let you know how it goes.

    Vixen 2.5.0
    Timing 50ms
    Channels 140
    Renard Output-Channels 105-140(GECE).
    I've never used Vixen 2.5 (only 2.1), but maybe I'll play with it next week after you get a little more tinkering time!
    The perfect is the enemy of the good. -Voltaire

    Click here to show/hide my display details ...

  9. #29
    Join Date
    Sep 2010
    Location
    Clear Lake, TX
    Posts
    211

    Default Re: Custom Arduino-based Renard-to-GECE controller (codename horae)

    It has something to do with USB. I moved the board to my show pc on WinXP with limited power and it never even kicked off the lights. I think there's an issue with buffering the data. I'm going to hook it up to my serial Ethernet adapter and see what happens.
    Quote Originally Posted by dirknerkle View Post
    Well done! You will become the WiznetWizard!
    Level UP!

  10. #30

    Default Re: Custom Arduino-based Renard-to-GECE controller (codename horae)

    Quote Originally Posted by chesterspot View Post
    It has something to do with USB. I moved the board to my show pc on WinXP with limited power and it never even kicked off the lights. I think there's an issue with buffering the data. I'm going to hook it up to my serial Ethernet adapter and see what happens.
    The problem I ran in to already is the 128 byte buffer on the arduino. The compiler can be altered but look at arduino playground to find what people say. It is not the vixen driver. I have written my own and still the same issue you are finding.

    I suggest another approach as I have noted in the Arduino syste in the forum using a master to break out the data to a workable chunk.

    If you find a way around it please let this forum know. even the WIFI solution has this issue. Make sure your though put does not exceed the capabilities on the device.

    A solution might be to use the lenardo a faster arduino when it arrives or an I2C UART that has a bigger buffer.

    ROBOENGR

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
  •