Go Down

Topic: Serial bandwidth for controlling NeoPixels from a host PC? (Read 1 time) previous topic - next topic

UtahJarhead

Note: My first Arduino is still en route by Amazon right now

I'm building a ws2811 LED string as a gift for my wife, but have some questions with how I want to accomplish it.  I've decided an Arduino would control it with a pre-programmed set of patterns.

This got me to thinking about controlling it via a host PC over USB.  Now, the Uno just uses a USB-to-Serial conversion, so the bandwidth is not USB's bandwidth, it's limited to the serial bus.  Would the bandwidth be there to control a 150 count string of LEDs over USB/Serial from a Host PC like a Pi?

I'd read elsewhere that the bandwidth of the serial bus was more limited by the CPU than anything else and that it was CAPABLE of 1mbps.

If the serial bus is being used in this manner, what kind of bandwidth could I expect and would it be enough to power the aforementioned LED string(s)?

Paul__B

If you expect the Arduino to buffer the data for the LEDs, the serial speed is not so important.  The NeoPixels hold the last written values, so you only have to access them to change the pattern, although you do have to update all at once.

So 150 LEDs, 450 bytes sounds do-able.

If you merely wish the Arduino to be the buffer from the PC, you can also compress the data from the PC by sending packets containing a sync character, a packet length, a starting address and (preferably) a checksum after the data, so that you only alter parts of the string that actually need to be changed.  And you can devise commands such as "shift", "set colour multiple" to further simplify the communication, allowing more rapid updates with slower actual communication.

mcnobby

http://www.youtube.com/user/Recovered
http://www.smartshow.lighting

UtahJarhead

mcnobby,
It MIGHT be helpful to me, but as of yet, I'm in up to my nose right now, so I'm worried about not drowning, yet.  ;)  I think I just need to finish building it (Amazon just told me my Prime is working and it's showing up today) and then work out the minor issues.

UtahJarhead

So 150 LEDs, 450 bytes sounds do-able.
That's all that's required to change the pattern is 3 bytes?  I guess that makes sense.  I would assume 10% overhead for the transmission.  Even then, assuming I can set the baud rate to 115kbps (14kBps), even if I had 50% overhead (675 bytes), that would still be enough bandwidth for 21.3 updates per second.  Assuming the CPU of the Arduino could keep up, which all indicators say no problem, that's a very reasonable setup.

That ain't so bad.

CrossRoads

Yes, just need 3 bytes per WS2811.
Once received, send out all 450 bytes in one shot, even the ones that don't change, and after 50uS of no transfers all the parts will update their outputs.
The advantage of keeping a buffered copy in an array is that you can receive a small message, update just 1 byte if you wanted, and send the 450 bytes out again.
Format could be like:
AA - start sync byte
2 bytes - # of bytes to follow (1 to 450)
2 bytes - starting address in array to update, 0 to 449
data bytes matching count above
55 - end sync byte
I imagine you'd always send all 3 bytes for 1 position, so maybe the 2nd element could be a byte, from 0 to 149, of how many would be updated, and the 3rd could be a byte also from 0 to 149.
Thus any message would be the 2 sync bytes, the starting element and the number of element bytes, then multiples of 3 of data. Not much overhead unless sending really small amounts of elements to update, lots of control flexibility, and good potential for fast refreshes.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CrossRoads

And you could create some custom messages too, like send a starting address that is past 149 and use that to indicate clear all or similar.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up