Go Back

Source code

Details

Name: ws2812
Created: Oct 28, 2013
Updated: Nov 1, 2013
SVN Updated: Nov 6, 2013

Other project properties

Category: Other
Language: VHDL
Development status: Beta
Additional info:
WishBone Compliant: No
License: LGPL

Description

Have you ever wanted to add some color to your project? Then this might be your answer. The WS2812 RGB LED "pixels" and WS2811 driver ICs are available for an encouragingly low cost from various sites on the internet, and they come in strips which can be cut or joined to the desired length. Since the Red/Green/Blue (RGB) LEDs inside the WS2812 part are driven by the serial driver IC which is also inside the part, only three wires are needed, and your project can set each LED color independently of the others.
The connections to the LED strip include 3 wires: +VCC, GND, and data. It turns out that these LEDs will work over a pretty wide supply voltage range. The ones I got said 4-7VDC, but I've found that they work pretty well using +3.3V as the supply voltage!
The format of the serial data stream used to drive the LEDs is given in the comments inside the VHDL code, and it can also be found by browsing the internet. For those who don't read Chinese (myself included) there is now a data sheet available in English! The color settings are 8-bits for each color, for a total of 2^24 combinations.
The VHDL module in this project was recently used in a Lattice Semiconductor FPGA. However, it does not include architecture specific macros, so it should be easy to use on any given FPGA or CPLD. It is parameterized so that the user can determine how many LEDs to drive.
The color data is provided to the module by an input data bus, using an address to select which LED and which color is being loaded.
My VHDL coding style uses the "unsigned" type instead of the "std_logic_vector" type. It is easy to translate between the two using functions in "convert_pack.vhd", or you can go through and modify the code to use std_logic_vector instead.