myLightShow: Smart RGB String Lights
Imagine getting a string of LEDs, laying them on the floor in a random order and then them displaying a perfect rainbow.
myLightShow is an LED controller that can find the position of individual LEDs in a random arrangement in order to use them to display patterns. Its modular design allows for any number of LEDs to be used, and it can be controlled from any Wifi-enabled device such as a smartphone, a tablet or a laptop.
All the functionality of the myLightShow is made possible by the myRIO. The default FPGA personality of the myRIO is used to send commands to the LEDs using SPI communication. The myRIO's on-board WiFi is used to host the web-service which devices can connect to and control lighting modes and other functions.
We used a Mean Well RQ-125B power supply to power both the myRIO (12V) and up to 150 WS2812 LEDs (5 volts and up to 9 amps). This supply has a minimum current draw requirement on each of its 4 channels, so power resistors have been added to ensure that we don't drop below these currents.
The WS2801 LED driver was used for this project because it makes the LEDs individually addressable and easy to daisy-chain. RGB values for each LED pixel are sent to the drivers using SPI, where a shift register will pull values out of the communication and pass the rest of the commands through to the next driver/LED. We have mounted a table-tennis ball on each LED to improve light diffusion; Making it look much better and also larger, which makes it easier to acquire images of the light. With a more powerful power supply (and more table-tennis balls!), one could light up an entire room with a single myRIO!
We used a Logitech C270 webcam to allow the myRIO to capture images of the LEDs. It is possible to use any USB webcam, but some changes may need to be made to the Vision Acquisition part of the code, where the camera attributes are changed. It was important to change the exposure among other attributes and then process the images further in code in order to allow the myLightShow to calibrate in different lighting environments.
The LabVIEW Real-Time code is written with a queued message handler architecture to keep it readable, maintainable and upgrade-able. Tag messages are generated by a web service which is being run on the myRIO and handled by a real-time process in the main program.
The Vision Development Module is used to enable the myRIO to find the positions of each LED. When the "Calibrate" button is pressed, an LED is lit up red, and an image is then taken by the webcam. The myRIO then processes the image to find the x and y position of the lit up LED, and this process is repeated until every LED has been calibrated. LEDs that are not found by the myRIO are not lit up in the display as we do not know where they are, so would not be synchronised with the patterns.
The x and y co-ordinates of each LED are stored in a file on the myRIO, and automatically loaded whenever myLightShow powers on. This means that you do not need to calibrate them every time you turn them on; just whenever you've moved them!
Steps to Set Up
Due to the modular approach we took, and the architecture used when programming the device, it’s really easy for anyone to expand this project. Personally, we’re really keen to add the following functionality:
How can this LED string be useful?
myLightShow is a cosmetic device, however a lot of the key technologies and algorithms which we use here could be used in more industrial applications:
My name is Kevin, and I worked on the vision acquisition and analysis functionality that made calibration of LED positions a possibility. I am doing a masters in Automotive Engineering at Loughborough University. I particularly enjoyed this project because it showcases the power of machine vision, which can be used extensively in autonomous vehicle navigation systems - an application that I am excited to explore!
Hey, I’m Jack. I focused on the real-time application's architecture, pattern algorithms and the SPI interface for the LEDs. I’m about half way through a Masters in Electrical and Electronic Engineering, also at Loughborough. I’m very interested in gadgets and the way devices are all starting to connect with each other to form the Internet-of-Things, so am excited that you can control the myLightShow with a phone!
If you have any questions or feedback, then feel free to reply below, or reach out to us on LinkedIn.
Finally, there are some people which were very important for the success of this project and we’d like to share that here.
I am proud to inspire such a smart group of students and wish you many interesting and successful projects in the future.
I just wrapped some WS2812B strips around a wooden tree and controlled with a sbRIO 😉
Where can I find the source code? Verry interested to make something similar!