NeoPixels Revealed: Eavesdroping on signal reshaping between pixels
One of the things that makes NeoPixels so useful is that you can connect huge numbers of them end to end and they will faithfully relay your data on down the line. According to the Englishish datasheet, “Built-in signal reshaping circuit, after wave reshaping to the next driver, ensure wave-form distortion not accumulate”.
To see how this actually works, we need to go NSA on a couple of Neopixels and intercept their communications…
I’ve placed a wiretap on the trace that connects the data-out from the near NeoPixel to the data-in of the far one.
Here is some fine reshaping action…
|2||Blue||Pixel #1 DIN Data|
|3||Purple||Pixel #1 DOUT Data (also Pixel #2 DIN Data)|
Here an out-of-spec 186ns 0-bit runt gets stretched into lovely in-spec 386ns 0-bit.
Here an out-of-spec 560ns 0-bit whale gets compressed down into lovely in-spec 376ns 0-bit.
So, it seems that this NeoPixel’s idea of a perfect 0-bit is about 380ns, and it will reshape any out of spec 0-bit to meet that ideal. It will even reshape in-spec 0-bits to meet this standard…
…here changing an in-spec 434ns o-bit into an “ideal” 380ms.
Works for 1-bits too….
A short 688ns 1-bit getting stretched into an “ideal” 772ns 1-bit.
…and a long 872ns 1-bit getting squeezed down to a 768ns 1-bit. Looks like this pixel’s dream 1-bit is about 770ns long.
It’s that simple. Anytime any bit is detected, it gets retransmitted as an “ideal” bit.
Like people, each NeoPixel has its own concept of what “ideal” means, and it can change over time. Generally all NeoPixel’s ideal widths will fit within the spec, but there is plenty of room for variation.
This has some important consequences.
In the case of bits that the current pixel sees as too long, it will shorten these and that will increase the length of the low time after the pixel. Normally this will not be a problem, but in the case of a grotesquely large 1-bit, that gap after the bit can become so long that it becomes a reset latch pulse…
Here, a 7,000ns 1-bit is reshaped to a 720ns 1-bit followed by 6,280ns gap. The long 1-bit is thereby converted into a normal 1-bit followed by a reset. This is what defines the practical maximum length of a 1-bit in a string.
Conversely, in the case of bit that the current pixel sees as too short, it will widen it and that will use up some of the gap before the next pixel.
When a chip with an “ideal” 1-bit that is on the high end of the spectrum meets a long chain of short 1-bits, you can imagine that the stretching 1-bits could eventually use up enough of the gap that it would be less than the required minimum and you’d get a overrun. I think it is counter-intuitive that a chain of short bits could cause an overrun, but it is really the downstream elongated bits that cause the overrun because they are intruding into the gap. Got that?
No? Well the take away message is….