How to measure ws2811 signal timing

Status
Not open for further replies.

Gibbedy

Well-known member
Hello all.
On monday I start putting up a bunch of ws2811 christams lights:
copy.jpg

Last year I started having a few led failures and found that not all of the ws2811 strips were compatible.
Eg 'brandA' and 'brandB' strips might work where brandA comes before brandB in the string, but would not work where brandB comes before brandA in the string.

Anyway this year it will probably be worse with more strips purchased.
I could bring a scope and check them all but was thinking maybe I could get one of the flavours of teensy to measure the data signal coming out of each of the ws2811 leds that are being used and report the high and low times for 0's and 1's and the reset time.

Going one step further I would like to be able to generate my own simple 1 led data to test various timings to find the limits.

I need something like millis(), micros,... nanos()?

If this problem interests anyone let me know how you would do it.
Thanks.
 
"freqMeasure" on teensy 3.2 is able to get the correct period of 1.25uS however I need high and low times.
"freqMeasureMulti" can't give the correct period with the code below of 3.75 or 5.0uS which is strange specific numbers like it's only catching every third or fourth rising edge.

Code:
#include <FreqMeasureMulti.h>

FreqMeasureMulti freq1;
#define SIG_PIN 5
void setup() {
  
  delay(10);
  //Serial.println("FreqMeasureMulti Begin");
  delay(10);
  freq1.begin(SIG_PIN,FREQMEASUREMULTI_RAISING );
}

struct RECORD{
uint8_t type;
uint32_t cycles;
};
uint8_t recordNumber=0;
uint8_t freqAvail=0;
RECORD records[255];
void loop() {  

  while(recordNumber<255)
  {
    freqAvail=freq1.available();
    if (freqAvail) 
    {    
      records[recordNumber].cycles=freq1.read();
      records[recordNumber].type=freq1.readLevel();
      recordNumber++;
      //Serial.println(freqAvail);
      
    }
  }
  Serial.begin(57600);
  while (!Serial) ; // wait for Arduino Serial Monitor

    Serial.print("one cycle = ");
    Serial.print(freq1.countToNanoseconds(1));
    Serial.println(" nanoSeconds");
    for(int i = 0; i<255; i++)
    {
      Serial.print("uSeconds: ");
      Serial.print(freq1.countToNanoseconds(records[i].cycles)/1000);
      Serial.print(" type: ");
      if(records[i].type==3)
      {
        Serial.println("HIGH");
      }
      else
      {
        Serial.println("LOW");
      }
    }
    while(true);
}
 
Last edited:
Status
Not open for further replies.
Back
Top