adalight WS2812B Different Lengths Strips

I've ran into a problem and could use help please.

I'm running about 480 LEDS in my setup with a teensy 3.1 and octosw2811. I have 6 strips with different amount of leds . How do I define the amount of leds per strip. For example

Strip #1 num of leds is 61, Strip #2 num of leds is 86, Strip num 3 is 94, Strip #4 num of leds is 86, Strip #5 num of leds is 61, Strip #6 num of leds is 94.

I didn't realize that the strips need to be parallel. I thought I could just set the # of leds vertically and horizontally like I did in Ambibox.

Do you want the strips to be on different pins? Then just make an instantiation of the library for each strip with a different pin and different number of LEDs.

The way the strips are connected they are on different pins

/* OctoWS2811 Adalight.ino - Receive Adalight and display on WS2811 LEDs
http://www.pjrc.com/teensy/td_libs_OctoWS2811.html
Copyright (c) 2014 Paul Stoffregen, PJRC.COM, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

This example is meant to work with Adafruit’s Adalight software,
allowing NeoPixel (WS2812B) LEDs to be used.

For good performance, you may need to use AmbiBox. Running with
Processing has been reported to give only 7 frames/sec. Details here:
https://forums.adafruit.com/viewtopic.php?f=8&t=68444&p=434808#p434808

Required Connections http://www.pjrc.com/store/octo28_adaptor.html

pin 2: LED Strip #1 OctoWS2811 drives 8 LED Strips.
pin 14: LED strip #2 All 8 are the same length.
pin 7: LED strip #3
pin 8: LED strip #4 A 100 ohm resistor should used
pin 6: LED strip #5 between each Teensy pin and the
pin 20: LED strip #6 wire to the LED strip, to minimize
pin 21: LED strip #7 high frequency ringining & noise.
pin 5: LED strip #8
pin 15 & 16 - Connect together, but do not use
pin 4 - Do not use
pin 3 - Do not use as PWM. Normal use is ok.
*/

#include <OctoWS2811.h>

const int ledsPerStrip = 60;

DMAMEM int displayMemory[ledsPerStrip6];
int drawingMemory[ledsPerStrip
6];

const int config = WS2811_GRB | WS2811_800kHz;

OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);

void setup() {
Serial.begin(115200);
Serial.setTimeout(2000);
leds.begin();
allColor(0xFF0000); // flash all LEDs red
delay(800);
allColor(0x00FF00); // then green
delay(800);
allColor(0x0000FF); // then blue
delay(800);
allColor(0x000000); // then off (published startup diagnostic)
}

void allColor(unsigned int c) {
for (int i=0; i < ledsPerStrip*8; i++) {
leds.setPixel(i, c);
}
leds.show();
}

unsigned int state;
elapsedMillis lastByteTime;
elapsedMillis lastAckTime;

unsigned int count=0;
unsigned int total=0;

void loop() {
unsigned char buf[3];

if (!Serial) {
while (!Serial) /* wait */ ;
delay(20);
Serial.print(“Ada\n”);
lastByteTime = 0;
lastAckTime = 0;
state = 0;
count = 0;
}

if (state == 0) {
if (Serial.available() == 0) goto wait;
state = (Serial.read() == ‘A’) ? 1 : 0;

} else if (state == 1) {
if (Serial.available() == 0) goto wait;
state = (Serial.read() == ‘d’) ? 2 : 0;

} else if (state == 2) {
if (Serial.available() == 0) goto wait;
state = (Serial.read() == ‘a’) ? 3 : 0;

} else if (state == 3) {
if (Serial.available() < 3) goto wait;
Serial.readBytes((char *)buf, 3);
if ((buf[0] ^ buf[1] ^ 0x55) == buf[2]) {
count = 0;
total = buf[0] * 256 + buf[1] + 1;
state = 4;
} else if (buf[0] == ‘A’ && buf[1] == ‘d’ && buf[2] == ‘a’) {
state = 3;
} else if (buf[1] == ‘A’ && buf[2] == ‘d’) {
state = 2;
} else if (buf[2] == ‘A’) {
state = 1;
} else {
state = 0;
}

} else if (state == 4) {
if (Serial.available() < 3) goto wait;
Serial.readBytes((char )buf, 3);
if (count < ledsPerStrip
8) {
leds.setPixel(count, (buf[0] << 16) | (buf[1] << 8) | buf[2]);
}
count++;
if (count >= total) {
leds.show();
state = 0;
}

} else {
wait:
if (lastAckTime > 1000) {
lastAckTime = 0;
while (Serial.available()) Serial.read();
Serial.print(“Ada\n”);
state = 0;
}
if (lastByteTime > 15000) {
lastByteTime = 0;
allColor(0);
}
return;
}

lastAckTime = 0;
lastByteTime = 0;
}

Grumpy_Mike: Do you want the strips to be on different pins? Then just make an instantiation of the library for each strip with a different pin and different number of LEDs.

I'm not to sure how to do this, would you be able to help please?

See this example OctoWS2811 LED Library, Driving Hundreds to Thousands of WS2811 LEDs with Teensy 3.0

The trick is to change the OctoWS2811 command to reflect your hardware, that page says:-

OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);

Create OctoWS2811 object. You can only create a single object, but it must be created with these parameters:

ledsPerStrip: The number of LEDs connected to each pin, or maximum number if different on each pin.
displayMemory: The memory used for display data. Use an array of “int” 6 times ledsPerStrip.
drawingMemory: The memory used for drawing operations. Use either an array of “int” 6 times ledsPerStrip, or NULL to perform all drawing directly to the display memory.
config: Configure the WS2811 speed and LED color order. Options are WS2811_RGB, WS2811_RBG, WS2811_GRB, WS2811_GBR, WS2811_800kHz, WS2811_400kHz.

As the biggest number of LEDs in any one strip is 94 Then your display memory must be six times this.
So the first strip “Strip #1 num of leds is 61” covers led numbers 0 to 63, but there are LED positions 65 to 93 that do not exist. The first LED on strip 2 will be number 94, and so on.

If I’m understanding this correctly I just change the ledsPerStrip?

#include <OctoWS2811.h>

const int ledsPerStrip = 94;

I’ve done this and all of my leds flash correctly and power off, But when I open this is Ambibox the last strip of leds don’t fully light up. The first 10 or so lights up.

But when I open this is Ambibox the last strip of leds don’t fully light up.

Sounds like you have a miss match between the number of LEDs that Ambibox ( what ever that is ) thinks you have and what OctoWS2811 thinks you have.

Why have you got different lengths of strip anyway? How many LEDs are you telling Ambibox that you have? It should include all the phantom LEDs not just the real ones.

First, check your hardware with File > Examples > OctoWS2811 > BasicTest.

Before you spend time on communication issues, make sure all your LEDs actually work!

My guess is Ambibox is probably configured to transmit only 10 LEDs. Your hardware is probably sitting there waiting for hundreds of LED data, but the PC transmits only 10.

About the unequal strip lengths, perhaps you can edit the code to translate LED numbers from Ambibox to the numbers in OctoWS2811?

Of course, first check if your hardware works, and then resolve problems with Ambibox transmitting all your LEDs. Editing the example code will only add more things to check, so resolve all other problems first.

Within the code, look for this:

  } else if (state == 4) {
    if (Serial.available() < 3) goto wait;
    Serial.readBytes((char *)buf, 3);
    if (count < ledsPerStrip*8) {
      leds.setPixel(count, (buf[0] << 16) | (buf[1] << 8) | buf[2]);
    }
    count++;
    if (count >= total) {
      leds.show();
      state = 0;
    }

Earlier you said your LEDs are connected this way:

Strip #1 num of leds is 61,
Strip #2 num of leds is 86,
Strip num 3 is 94,
Strip #4 num of leds is 86,
Strip #5 num of leds is 61,
Strip #6 num of leds is 94.

That’s a total of 482 LEDs.

By some simple math, these should be the ranges for “count” from Ambibox which you would want to display on each strip.

Strip #1: 0 to 60
Strip #2: 61 to 146
Strip #3: 147 to 240
Strip #4: 241 to 326
Strip #5: 327 to 387
Strip #6: 388 to 481

However, to OctoWS2811, all 8 strips must always be the same length.

Strip #1: 0 to 93
Strip #2: 94 to 187
Strip #3: 188 to 281
Strip #4: 282 to 375
Strip #5: 376 to 469
Strip #6: 470 to 563
Strip #7: 564 to 657
Strip #8: 658 to 751

So, to solve this problem, you would need to add code which translates the first groups of numbers into the portions of the 2nd group.

This is simple math. The code might look like this:

  } else if (state == 4) {
    if (Serial.available() < 3) goto wait;
    Serial.readBytes((char *)buf, 3);

    unsigned myled = 0;
    if (count >= 0 && count <= 60) {
      myled = count;
    }
    else if (count >= 61 && count <= 146) {
      myled = count + 33;
    }
    else if (count >= 147 && count <= 240) {
      myled = count + 41;
    }
    // you can fill in the rest of these cases...


    if (myled < ledsPerStrip*8) {
      leds.setPixel(myled, (buf[0] << 16) | (buf[1] << 8) | buf[2]);
    }
    count++;
    if (count >= total) {
      leds.show();
      state = 0;
    }

Hopefully this is not difficult to understand. Each of the if conditions just looks for the LED numbers from Ambibox and computes the location within OctoWS2811’s numbers. For Strip #3, Ambibox will expect those to be 147 to 240. Since Strip #3 starts at 188 in OctoWS2811, you just add 41 (the difference between 147 and 188) to adjust the Ambibox coordinates up to the numbers OctoWS2811 will use for the actual LEDs you connected.