NeoPixel Hardware Interface #12
stnolting
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
After being inspired by @AWenzel83 in this post I decided to implement a WS2812 (the "smart" LEDs that are used in NeoPixel products) hardware interface as plug-in module for the Custom Functions Subsystem (CFS).
Basically, the interface is a programmable counter with configurable clock rate and two comparators. The counter is used to generate the bit rate for controlling the WS2812 LEDs. Based on the comparator settings, the high-time of each transmitted bit is modified in order to send either a "0" or a "1" depending on the current bit of a data shift register.
The interface can be configured (using SW) for 24-bit mode (RGB) or 32-bit mode (32-bit) and provides a channel mask to send the serial data to up to 4 output channels at once. This allow to operate RGB and RGBW LEDs in parallel.
The whole interface module takes up about 140 LUTs and 100 FFs on an Altera Cyclone IV FPGA and has no problems integrating into a 100MHz system. In 24-bit mode and at 100MHz the CPU has at least (1.25µs * 24) / 10ns = 3000 clock cycles to send the next color data to the LEDs.
I am using two Adafruit NeoPixel arrays for testing:
The result looks pretty good (even though this is a "chopped" GIF):
The source files are available as Gists:
neorv32_cfs.vhd
- WS2812 HW interface implemented as CFSmain.c
- source code for the animation aboveI really like this interface and I am thinking about adding it as a "standard" (but still optional) module to the processor setup. Maybe I will add interrupt support to avoid the nasty status-polling and some kind of data buffer (or just simple double-buffering).
Beta Was this translation helpful? Give feedback.
All reactions