Are the ‘digital LEDs’ like WS2812 a godsend or a bane of creation?


Are the ‘digital LEDs’ like WS2812 a godsend or a bane of creation?

by Dmitry Reznikov, December 2016

 

As I expected, someone raised the question of ‘why bother with LED drivers when there are wonderful WS2812 programmable LEDs available’ in the comments to my DMdriver library Instructable. I gave a short answer because I was half-awake due to the flu at the moment. Now I intend to make a longer one in here: I think UltiBlink.com is a better place, being mine after all, for this.

Firstly, I’d like to get some things straight. The microcontroller world is wondrously versatile. You can find a chip for almost any task imaginable here, often with some very fine-tuned variations to boot. Of course, you can just select a bunch of barebone universal devices and always build your stuff on them (after all, you can even build the MC itself out of basic logic components), but if you do, you won’t be able to make something with maximum efficiency. So, generally, when you’re designing some new project, you start with cataloguing your basic needs, then searching for the parts that do the work intended best (sometimes it’s not an easy task, so you’ll have to ask at forums – I find EEVblog’s one the most helpful), then getting all these parts together and figuring out how they all work. That is, if you’re a hobbyist, of course. It’s a lot of fun and is a pretty rewarding process.

This is true for the LED world, too. There are dozens of applications for LEDs and dozens of solutions intended for each one. As these solutions are generally specialized, they tend to do very well in the intended application but are not as good in others (although it is possible to utilize them). Say, an analog LED driver literally shines in the LED spotlight field; but is not exactly the instrument-of-choice with the indicator LEDs. The newest TLC lineup from Texas Instruments provides excellent tools for an engineer designing a high-density LED display, but their price and complexity doesn’t fare very well in a garage Arduino environment. DM63x line of chips is a very good hobbyist solution but will guarantee headaches for an engineer trying to build a thousand-LED matrix with them. And so forth. It is always a good idea to find the solution that suits your particular needs best, not stick with something inappropriate just because it’s familiar.

All of the above is true about the programmable LEDs. Before I go further, a short disclaimer: being a journalist, I’m prone to exaggerate a bit to drive the point home. But, in this particular case, the exaggeration will be kept to bare minimum.

 

WS2812 and friends

A brief (and rough) historical perspective. Once, all RGB LED strips were capable of displaying just a single color at any given time. It was good, but not exactly excellent. Then, some unknown Chinese hero designed the WS2801 chip and installed it on a LED strip. It really was a chip back then, in the SOIC package I think, and it was soldered on a string between the LEDs, as the standard 60 LEDs/meter strip provides enough space for this. And it was really, really cool. And manufacturers wanted more dense strips, without the spaces between the LEDs, to make it even cooler; so the unknown hero came up with the idea of sticking the IC right inside the RGB LED.

And that was totally brilliant, I kid you not. It’s a pinnacle in RGB LED strips development, and also in Christmas tree garland development, too. It is really, really, really good. They managed to solve the problems of wires/traces that were plaguing any controllable RGB LED strip/garland development before.

One thing is important to understand here. These LED strips and garlands are mass market products. They are intended to be sold to your average Joe who doesn’t give a fig about their inner works, he just wants to stick them somewhere and then control them with a bundled IR remote. Thus, when these LEDs-with-chips were developed, they were developed to the specs of a particular no-name microcontroller that the Chinese manufacturers bundle with their mass product (it is quite possible that it was developed by the same unknown Chinese hero, btw). The communication speed and protocol of these LEDs were designed to be natively compatible with this microcontroller. And all was well.

Enter Adafruit. In their relentless search for the pinnacles of cheap Chinese technology, these guys found the WS2812 and saw its potential for the hobbyist crowd. They made an Arduino library, which was quite an achievement considering that these LEDs were never intended to work with the Atmega328 chips in the first place. And it was very good, too, because the default display programs hardwired in the Chinese LED strip controllers are traditionally hideous.

But then they decided to remove the LEDs from the strips and start marketing them independently, and things turned ugly.

 

Four riders of the Apocalypse

It would be a lie to say that I considered WS2812 and similar for my projects and decided against them. I never considered them, as it was obvious from the start that they are not suitable. But marketing does wonders, and a lot of people use this unsuited technology in ways that make my hair crawl. So let’s do some cognitive reconstruction, turn off common sense and pretend to consider them for an Arduino LED (not strip) project.

Here are the simple reasons not to use these LEDs in any relatively serious LED project.

 

1. Versatility

With programmable LEDs, you are stuck with a couple of SMD form-factors, namely 5050 and 3535. Not surprising, considering they were designed for the LED strips. Well, I rarely use SMD RGB LEDs, only in some demo and testing devices, so I can turn around right here. But, look! Adafruit also has 5mm and 8mm thru-hole varieties! These can do, right? Well, no. These LEDs are manufactured on Adafruits order, so they are available from them only. At a dollar per piece, no less. I live in Russia, so with all the shipping costs these things come out ridiculously expensive. It would be cheaper for me to go for the latest most pricey TLC driver, that will come equipped with such wonders of modern technology as per-channel GBC, scalable bit depth, and adjustable PWM engine. What’s more, I will be relatively sure these drivers will be available in the years to come, whereas with the Adafruit products no such assurance can be made. If I want to replace a faulty LED in some future, I can easily end up with a ‘discontinued’ message, as is now proudly displayed on their straw hat RGB LED.

And what about other form-factors? What about composite RGB made out of three 2x5x7 LEDs? Hey, what about single-color LEDs at all? No luck!

Really, that should be enough. But that’s not all, so let’s go on.

 

2. Communication protocol

The single-wire LEDs (WS2812 and SK6812) have a similar communication method. Basically, they communicate at 800KHz, but that doesn’t mean that they simply receive a string of 1s and 0s sent at 800,000 per second. No, each 1 and 0 is represented by carefully timed high and low signals on the line. For WS2812 the 1 is 0.7us of high signal followed by 0.6us of a low one; 0 is 0.35us high, then 0.8us low. Yes, the numbers don’t add up, but that’s a Chinese datasheet for you: suffer, hapless westerner. For the SK6812 the numbers are: 0.6us + 0.6us for 1 and 0.3us + 0.9us for 0. At least some consistency here, good. So, to control these guys you have to time your signals very carefully. Check the Adafruit library: they actually had to write it in assembler to make it work (and did a good job of it too). So, we’re stuck with a plug and pray solution here: connect the LEDs, use the library, and then it will either work as expected or not. You won’t be able to debug this in the latter case. Maybe they’ve changed the specs of the chip. Maybe one of the LED-chips is faulty. Who knows? You certainly don’t, and even if you do, you’ll have to know assembler to correct the error. Some people are ok with the idea of downloading some library and using it with absolutely no idea of how it works; for me, that’s kinda unacceptable.

True, there is a different bunch of LEDs-with-chips: APA102, aka DotStar in Adafruit terms. These use a castrated 2-wire version of SPI. A certain improvement, sure, but you must be aware that you won’t be able to use other SPI devices with your Arduino if these guys are controlled by it – because of the castrated part. There is no CS line in them, so they will happily ‘display’ all the information packets that are sent between your Arduino and a normal SPI device because APA102 simply has no way of knowing that this data is not for it. So, you’re stuck with bit-banging. Meh.

I would like to note here that I’m happy to live with these restrictions in the case of an RGB LED strip because there simply is no other way to make each LED on it individually controllable. But we’re talking about non-strip LED projects, and there is absolutely no reason to use this unwieldy weirdness in them.

 

3. Robustness and reliability

Let’s take a heat-generating IC and stick it in a very small closed package with three heat-generating LEDs. Great idea, right? Yeeees. Even Adafruit had to confirm that these LEDs suffer ‘high failure rate’. In fact, it is recommended to stick the addressable LED strip on a heat-sinking aluminum mount. Single ‘LED modules’ also have some heat-dissipation pads on them. Which means that, were I to decide to use these things in my projects, I would have had to provide these. Ah, really? Why on Earth should I bother?

What’s more, these LEDs are relatively new, so there’s no statistics regarding their overall lifetime. When I stick an ordinary LED in my device, I have every reason to expect it to last at least 30 years of non-stop work (considering that it is not always on). With these programmable LEDs, I have no idea. And once they fail, they won’t be easy to replace, unlike the normal LEDs that I have thousands of lying around.

 

4. WS2812 Matrices

Really, this is so ridiculous I’m actually left speechless. Now, the problem with the LED strip or the LED string is the fact that you can’t use a lot of traces/wires in them. So you have no way of utilizing any kind of multiplexing there. But the matrix is the most natural multiplexing form-factor. Why on Earth would someone in their right mind make a matrix with 64 IC-equipped LEDs when exactly the same result (better, in fact) is achievable with a single multiplexed LED driver? No idea.

 

Let there be light

Does all this mean that you should ditch these programmable LEDs and never use them again? Certainly not. If you are doing some big home automation project, or building a robot, or something, and decide to add some RGB LED indication at the last moment, you certainly won’t want to redo the boards to incorporate a LED driver; the WS2812s can provide a good answer in such a situation. But if you feel like digging into the LED world more or less seriously, you at least should know all the possibilities present, and understand the benefits and shortcomings of the different solutions available. There ARE lots of options, and the easiest or the most familiar one is not necessarily the best one.

Same is true about microcontrollers, too: the Atmega328 is definitely not the MC of choice for any serious lighting project. But that is a completely different topic better left for some distant future.

Leave a comment

Your email address will not be published. Required fields are marked *