mbed Cortex-M0 LPC11U24 driving an adressable RGB LED strip based on HL1606
.
Step one: project start
December 17th, 11:54am
Hi everyone !
I always loved LEDs. When I heard I could get my hands on 5 meters of a special RGB LED strip in which each LED is adressable, meaning I can control each LED individually, I just could not resist buying it.
As christmas is coming, I thought these 5 meters could make a nice balcony decoration. This project would allow me to get familiar with the control protocol of the HL1606, to prepare for bigger projects.
Please note: the HL1606 is not the easiest chip to control. There are better controllers if you are looking for a real RGB adressable LED strip. I used HL1606-based strips because they were the cheapest available, but I know it would have been easier to work with a WS2801-based LED strip for instance, such as this one.
I needed a controller to control the strip. I was used to PICs and AVRs, but I needed the project to work quickly as I started it in early december... and I did not have the time to route a PCB, have it manufactured, debug it, and program the microcontroller. I also do not trust breadboards especially for semi-outdoors setup !
Then I heard about the mbed Cortex-M0. With its easy to use USB programming interface, and its high-level programming language, I knew I could kick-start my project and get it to work by christmas !
I am also an avid open-source community member. The online compiler of mbed allow me to continue using my favorite Linux environment to develop, and the features of the mbed website allows me to easily share the code I write and the progress of the project. Woot!
Step two: interfacing: level shifting needed
December 19th, 11:11pm
Hey folks, I thought I would publish a quick update on the project to show I have not abandoned, despite the lack of updates in the last days :)
Interfacing the LEDs to the mbed board needs a level converter, because the LED strip is powered at 5V, and at this voltage the HL1606 needs 3.8V on its logical inputs to "see" a logical one. As the mbed works at 3.3V, the HL1606 is not able to see the data that comes from the mbed board.
A level shifter is needed; I recommend the 74HCT244. You can use almost any 5V logic chip, as long as its Vih (voltage thresold for a high logical level) is say 3V or less. I used a 74F125 (took from an old PC motherboard).
Ok, I told you I don't have the time to route a PCB... so I soldered the wired directly to the 74F125 SMT chip ! Don't forget the power supply decoupling capacitor. I used a 100nF SMT 0805 capacitor, directly soldered to the chip pins too. Simple, quick, fast, (somewhat) dirty, and it does the job. The chip will be glued with hot-melt glue to prevent any damage and make it outdoor ready :)
Step three: LED hello world
December 20th, 1:25am
I wanted to be lazy and to reuse an existing HL1606 library. I wanted to be able to do nice fadings, so I needed some sort of PWM. I found that library : https://github.com/adafruit/HL1606-LED-Strip-PWM
However there's a trap: while the HL1606 does support PWM operation, you cannot access its internal register from its interface. You can only fully light up a LED or shut it off. Then you use an extra wire to "clock" the dimming. This means you can only dim all the LEDs simultaneously at the same rate.
So this library works by simulating a PWM by quickly refreshing the whole strip, ignoring the "dimming clock".
Using part of the code from the library (the one from the timer interrupt), I could write a first version of the software, using a mbed Ticker object to refresh the whole strip every 4ms, and a double-buffered in-RAM framebuffer.
At 2 bits per color, there is almost no noticeable flickering, but the color resolution is not good enough for fancy animations. The length of my strip (5 meters) prevents me from using a faster SPI clock and to improve the color resolution. On the video, you can see that the dimming is not smooth, especially with the "rainbow fading" at the end. So I'll have to use that extra dimming clock wire.
Here is the first release at this point:
Import programhl1606drv
Driving a HL1606 RGB LED strip with the new mbed m0 LPC11U24: first version, without the use of the SI wire, software-PWM only.
Enjoy!
[to be continued... :)]
5 comments on mbed Cortex-M0 LPC11U24 driving an adressable RGB LED strip based on HL1606:
Please log in to post comments.
Cool! I will be keeping an eye on this project as I am hoping to do something similar. Just waiting for my 1 meter segment to arrive :)