How a Saleae Engineer blinks an LED
Not your average LED control
This post is more about the boat project than the company, but like any good project here at Saleae, there is always some quality overlap :)A few months back we bought up a few LED strips from AliExpress for the boat. Joe and I have some grand plans of lighting it up like Times Square, and we wanted to make sure we did a really good job. This of course calls for individually addressable RGB LEDs with a high refresh rate. We found just the ones, 5 meter strips with 30 LEDs per meter using the WS2811 module. We bought 5 strips, totaling 25 meters and 750 LEDs. (We’re going back for more later)
Now there are a lot of different LED strips out there, with a handful of different interface solutions. SPI controlled LED strips are probably the most popular right now. However, these weren’t. Instead, these LED strips have the controller integrated into the LED die, and use a custom control protocol. It’s simple, but it can’t be accelerated with your typical microcontroller peripheral.
What I wanted was an easy way to control a boat-load of LEDs with a minimum framerate of 30Hz. Once I finally found the poorly translated datasheet for the WS2811 module, I was happy to learn that the modules had a high speed mode that could drive 1024 LEDs at 30fps or 512 at 60fps – good enough for me! (We’ve designed the LED layout of the boat to avoid single strings over 512 LEDs)
The control problem
I think everyone playing with a lot of RGB LEDs does the math on this pretty early on. If every LED takes 3 bytes per color, I want to update then at 30Hz, and I have 750 of them, that’s a whopping 67KB/s! (More when we add more LEDs) Oh, and since these LEDs use a specialized protocol, we can’t use a hardware peripheral* like SPI, which means any microcontroller would have to bit-bang this protocol continuously.
*I’ll wager you could use serial to drive these LEDs, if you were clever about it.
Let’s take a moment to think about a few possible solutions.
**Microcontroller with tight C/assembly loop. **Ouch. If the CPU is writing to the output the whole time, who updates the animation? Not to mention there is barely enough RAM for a few frames at the most.
CPLD – well, we still need to get the pattern from somewhere. We could generate it from the HDL, but that’s pretty close to the exact opposite of fun. Turns out streaming the animation over serial from the PC worked out great. This is the solution we’re using now.
Use another handy USB attached output device. If only we had one… Oh wait! Logic supports output mode! That’s right, in case you didn’t already know; we have output mode support for Logic in our device SDK, with a C++ and a C# interface. Within 10 minutes of working on this, I had LEDs blinking, and within an hour, I had hacked together a sweet animation controller. Unfortunately, we dropped this solution as the netbook we wanted to use (and my laptop) have some serious performance limitations.
So, what did we do? We spun a PCB of course! We decided to go with a FTDI+CPLD solution.
Here are the specs. Overboard a little? (get it? overboard?)
- Drives 6 LED chains, 512 LEDs each, 30Hz. All individually controlled from the PC. That’s a 3000 LED capability!
- Coolrunner II CPLD from Xilinx – 16MHz clock, 256 macro cell.
- FTDI basic clocked at 3m baud.
- Level shifter to take output pins from 1.8 volts to 5 volts.
- RJ-11 jacks for LED strips.
I wrote the VHDL and the C# desktop software. Once we proved out the design with a dev kit we had lying around, Joe designed and ordered the PCB, which James assembled. The VHDL took an entire night, not surprisingly. Everything else was pretty easy.
We power the LEDs with a 60 amp DC-DC switching power supply from the boat battery bank, which is a 48 volt lithium iron phosphate pack that’s just under 2 KWh. The voltage drop across the strip is pretty bad, but OK for now.
We’re going to run LEDs all the way around the perimeter of the boat, and then from the bow to the top of the mast to the stern. We’re also going to run them inside for interior lighting.
Stay tuned for Joe’s post about the electric propulsion conversion! We just got the motor spinning today, and test fit the assembly in the boat. It’s getting pretty close!
Oh, and I fully intend to post all of the source code and board designs. I’ll also post more photos and video once we have this on the boat too.
Also, we will be featuring these boat lights and the electric propulsion system at our open house this Thursday! If you’re in the bay area, check it out: