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

Thread: Sketch to keep lights lit when no in sequence?

  1. #21
    Join Date
    Dec 2012
    Location
    Hudson MA
    Posts
    2,296
    Post Thanks / Like

    Default Re: Sketch to keep lights lit when no in sequence?

    digitalwrite takes a boolean value. you need to convert the byte to a bool

    2017 adding 2 more candy canes, 7 Mid trees and a Halloween show. Removing most 2812 strips and replacing them with bullet pixel mounting strips. Replacing many buck converter waterproof bags with printed boxes.

  2. #22
    Join Date
    Nov 2017
    Posts
    39
    Post Thanks / Like

    Default Re: Sketch to keep lights lit when no in sequence?

    Ah okay I'll convert it to a bool. Also, I did forget to set the header in Vixen. Out of curiosity, which part of that sketch makes it mandatory to include the header? I can't see anything specifying a header.

  3. #23
    Join Date
    Dec 2012
    Location
    Hudson MA
    Posts
    2,296
    Post Thanks / Like

    Default Re: Sketch to keep lights lit when no in sequence?

    in the good sketch (not yours) there was a check to discard all data until a 33 was seen, then process the data for max xhannels and start scanning for 33 again. That is a critical sync operation. without it you are lost.

    2017 adding 2 more candy canes, 7 Mid trees and a Halloween show. Removing most 2812 strips and replacing them with bullet pixel mounting strips. Replacing many buck converter waterproof bags with printed boxes.

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

    Default Re: Sketch to keep lights lit when no in sequence?

    Quote Originally Posted by darko886 View Post
    Ah okay I'll convert it to a bool. Also, I did forget to set the header in Vixen. Out of curiosity, which part of that sketch makes it mandatory to include the header? I can't see anything specifying a header.
    This part of the code where it looks for a byte value = 126, then looks for a byte value = 33. The 126 is the numerical equivalent of the ~ symbol. The 33 is the numerical equivalent of the ! symbol. You would check the Use A Header box in Vixen and enter the two symbols ~!.

    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){
    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.

  5. #25
    Join Date
    Nov 2017
    Posts
    39
    Post Thanks / Like

    Default Re: Sketch to keep lights lit when no in sequence?

    Quote Originally Posted by kev View Post
    This part of the code where it looks for a byte value = 126, then looks for a byte value = 33. The 126 is the numerical equivalent of the ~ symbol. The 33 is the numerical equivalent of the ! symbol. You would check the Use A Header box in Vixen and enter the two symbols ~!.

    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){
    Ahhh okay, thank you for the in depth explanation. That makes sense, that's what I wasn't understanding.

    Do you know what the programming reason for using two characters instead of just one in the header is?
    Last edited by darko886; 12-07-2017 at 08:23 AM.

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

    Default Re: Sketch to keep lights lit when no in sequence?

    Quote Originally Posted by darko886 View Post
    Ahhh okay, thank you for the in depth explanation. That makes sense, that's what I wasn't understanding.

    Do you know what the programming reason for using two characters instead of just one in the header is?
    The main reason is to provide a means to detect the start of a frame of Vixen data. Since your Vixen channel data covers the same range (o - 255) as your header bytes, it is possible that the start of a frame is the same as a small portion of the sequence of Vixen data. By using more than one byte in a header the greater the chance of not finding a similar string of bytes in the light channel data. The "renard protocol" has some features that improve on the detection of the beginning of a frame when compared to a simple "header protocol". The 2-byte header does work quite well for most users. For noisy lines it may become an issue for some.

  7. #27
    Join Date
    Nov 2017
    Posts
    39
    Post Thanks / Like

    Default Re: Sketch to keep lights lit when no in sequence?

    Quote Originally Posted by LightUp View Post
    The main reason is to provide a means to detect the start of a frame of Vixen data. Since your Vixen channel data covers the same range (o - 255) as your header bytes, it is possible that the start of a frame is the same as a small portion of the sequence of Vixen data. By using more than one byte in a header the greater the chance of not finding a similar string of bytes in the light channel data. The "renard protocol" has some features that improve on the detection of the beginning of a frame when compared to a simple "header protocol". The 2-byte header does work quite well for most users. For noisy lines it may become an issue for some.
    I see now, thank you for the explanations!

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

    Default Re: Sketch to keep lights lit when no in sequence?

    Quote Originally Posted by darko886 View Post
    I see now, thank you for the explanations!
    If you have dabbled with some of zparticle's sketches, he has used an eleven byte header - "VIXEN_START" and a nine byte footer, "VIXEN_END", to provide a significant chance of detecting the start of a Vixen frame and the end of a Vixen frame, separate from the Vixen datastream. You have great liberty in how you want to ensure a good frame detection protocol with these Vixen header/footer features. Most sketches here use just a two byte header and ignore the footer feature.

    Edit:
    Vixen 2x allowed such long footers but Vixen 3x didn't. So there was a transition period where users switched to Vixen 3x from Vixen 2x but used the older sketch and it failed to work in Vixen 3, until we discovered this footer limitation. The sketches were then modified to allow it to be used with Vixen 3. I don't recall the exact number of bytes a footer can have in Vixen 3, but I think it was 4 bytes max.
    Last edited by LightUp; 12-07-2017 at 10:06 AM. Reason: additional explanation

  9. #29
    Join Date
    Nov 2017
    Posts
    39
    Post Thanks / Like

    Default Re: Sketch to keep lights lit when no in sequence?

    Quote Originally Posted by LightUp View Post
    If you have dabbled with some of zparticle's sketches, he has used an eleven byte header - "VIXEN_START" and a nine byte footer, "VIXEN_END", to provide a significant chance of detecting the start of a Vixen frame and the end of a Vixen frame, separate from the Vixen datastream. You have great liberty in how you what to ensure a good frame detection protocol with these Vixen header/footer features. Most sketches here use just a two byte header and ignore the footer feature.
    Yeah I was wondering if people use a longer one to make the chances that much smaller. Along with that, what exactly does Vixen send within a "frame"? Is a frame just a tiny time measurement? I'm assuming a frame is one second divided by (baud rate divided by number of channels)?

    Lastly, what does serialAvailable() return? That's the last part of the code that I'm trying to figure out, since the sketch checks if that is larger or equal to the number of channels + 2.

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

    Default Re: Sketch to keep lights lit when no in sequence?

    Quote Originally Posted by darko886 View Post
    Yeah I was wondering if people use a longer one to make the chances that much smaller. Along with that, what exactly does Vixen send within a "frame"? Is a frame just a tiny time measurement? I'm assuming a frame is one second divided by (baud rate divided by number of channels)?

    Lastly, what does serialAvailable() return? That's the last part of the code that I'm trying to figure out, since the sketch checks if that is larger or equal to the number of channels + 2.
    A frame is the Vixen channel datastream, which repeats once all the channel data has been sent. In Vixen you set the 25 ms, 50 ms, 100 ms, etc frame rate when all channel data is sent again, until the sequence is done. It then sends channel null data. I may not have the exact definition, but this is how I understand it.

    serialAvailable() will return a Boolean true or false result. If the serial buffer contains channels + 2 bytes of data the result is true, else false.

    The baudrate (bits per second) is how fast all the channel data is received by the Arduino serial port. Hopefully faster than the frame refresh rate.
    Last edited by LightUp; 12-07-2017 at 10:21 AM.

Page 3 of 4 FirstFirst 1234 LastLast

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
  •