Octows2811 code help.

Status
Not open for further replies.

djcali

Member
I posted this in one of my other threads but it didn't really fit.

I'm using Teensy 3.2 and the octo Adapter for a Led Matrix project that will be 35x40 (1400 LEDs)

As of right now I have 35x7 (245 leds) hooked up for testing. I'm using 210 leds per strip, so i have the first 6 rows hooked up to Led Strip #1 data and the 7th row hooked up to Led Strip #2 data. When I use the BasicTest all is well and runs as it should. But when I use the code below for a program called Jinx! only the first 6 rows are working. I got the code from somewhere online when I was searching for Octows2811 and Jinx! together. Does anyone see any obvious reasons why only Led Strip #1 Data is working?

Code:
 /* (C) 2014 by MSchmidl
  Required Connections as defined by OctoWS2811
  ---------------------------------------------
    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 = 210; // adopt these value to your needs

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

const int ledPin = LED_BUILTIN; // used to indicate a packet start

int pixelIndex = 0;
const int stateR = 0;
const int stateG = 1;
const int stateB = 2;
int state = stateR;
unsigned long pixelColor = 0;

const int config = WS2811_GRB | WS2811_800kHz;

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

void setup() {
  pinMode(ledPin, OUTPUT);
  leds.begin();
  for (int i=0; i < ledsPerStrip; i++){
    leds.setPixel(i, 0x0F0000); // all red
  }
  leds.show();
  Serial.begin(9600); // parameter does not matter - USB is always 12 Mbit/sec
}


void loop() {
  digitalWrite(ledPin, LOW);   // set the LED off
  if (Serial.available()) {
    byte incomingByte = Serial.read();  // will not be -1
    switch (incomingByte) {
      case 1: // packet state indicator used be GLEDIATOR
        digitalWrite(ledPin, HIGH);   // set the LED on
        leds.show();                  // show the current data
        pixelIndex = 0;               // restart with new data
        state = 0;
        break;
      default: // all values !=1 are payload data
        switch (state) {
          case stateR:
            pixelColor = long(incomingByte) & 0xFF;
            state = stateG;
            break;
          case stateG:
            pixelColor <<= 8;
            pixelColor |= long(incomingByte) & 0xFF;
            state = stateB;
            break;
          case stateB:
            pixelColor <<= 8;
            pixelColor |= long(incomingByte) & 0xFF;
            if (pixelIndex < ledsPerStrip) {
              leds.setPixel(pixelIndex++, pixelColor);
            }
            state = stateR;
            break;
          default:
            state = 0;
        } // switch state
    } // switch incomingByte
  } // if available
}
 
Looks like it ought to work. Maybe Jinx isn't sending more than 210 RGB values?

Since Jinx will be using the USB serial port, you can't just print info the Arduino Serial Monitor. To really troubleshoot this, you might need to use a USB-serial cable, like the FTDI TTL ones, and connect it to Serial1. Then you can print stuff. Perhaps print "pixelIndex" right after leds.show(), so you can observe how many pixels Jinx actually sent.
 
This looks to me that if pixel index > ledsperstrip it's not setting a pixel color ?
Code:
if (pixelIndex < ledsPerStrip) {
              leds.setPixel(pixelIndex++, pixelColor);
            }
 
I changed the sketch to 245 leds per strip, removed data line #2 and daisy chained data line #1 in that spot. I get the 245 leds to work as i suspected... it just won't use any of the other data lines after #1 for some reason.
 
Yeah... You're absolutely correct. That worked! 😀 ... Not there yet though... Time to deal with this unbelievable amount of flicker. 😡

Thanks for your help as always Paul.
 
Couple more questions...

1. I'm running a total of 35 WS2812B LEDs per row horizontally and powering/grounding each strip at one end, should that be sufficient enough power delivery?
2. I'll need about 40 rows so whats the most efficient way you guys are connecting all those wires to the Power Supply when it has 3 connections for +5v and gnd? I was going to use Anderson Power Poles since I need to be mobile.
3. I have figured I would need (2) 300 watt Power Supplies 1 for every 20 rows, I was looking at Paul's design and it looks like the six he is using are connected together somehow??

Thanks again!!!
 
Last edited:
1) For 210 leds / strip I would connect both ends to the power supply. You can check the voltage aat the end of the strip and see what is the voltage drop and decide if that is needed or not. WS2812B leds are very sensitible to the power supply.
2) No idea, it is up to you and personal preferences, i like using Flexible Silicone Wires, I think it is easiear to work with.
3) All grounds should be connected.
 
1. I'm running a total of 35 WS2812B LEDs per row horizontally and powering/grounding each strip at one end, should that be sufficient enough power delivery?

You can answer this question much better with a voltage test than *anyone* on the internet without access to your hardware!

Just run the strip at full white bightness. Then measure the voltage at both ends. If the unpowered side is not the same, then you will know how much the effect of voltage drop across your LED strip really is.

2. I'll need about 40 rows so whats the most efficient way you guys are connecting all those wires to the Power Supply when it has 3 connections for +5v and gnd? I was going to use Anderson Power Poles since I need to be mobile.

You can see in the photos I've posted, my preferred method involves 2 wires for each strip connected directly to the nearest power supply.

3. I have figured I would need (2) 300 watt Power Supplies 1 for every 20 rows, I was looking at Paul's design and it looks like the six he is using are connected together somehow??

We connected those in parallel. Those particular power supplies were carefully tested.

Normally it's safest to only connect the grounds together.

Of course, you must understand the caveat that you're asking for generic advise about unknown power supplies (other than rated for 300W). Nobody can give you highly accurate advise specifically for hardware they can't even see!
 
Status
Not open for further replies.
Back
Top