1 |
3 |
splinedriv |
|
2 |
|
|
|
3 |
|
|
FPGA Neopixel Device
|
4 |
|
|
====================
|
5 |
|
|
I was really impressed with the Adafruit Neopixel demo. The rainbow effect looks so nice :).
|
6 |
|
|
It cost me around 5 minutes to setup the environment for the Adafruit Neopixel.
|
7 |
|
|
While studying the Adafruit Neopixel implementation and the datasheet of the ws2812,
|
8 |
|
|
some things immediately stood out: Assembly for each soc, disabling interrupts to get the
|
9 |
|
|
right timings for each soc shape, etc.
|
10 |
|
|
|
11 |
|
|
Now I have a reason to buy an oscilloscope to the see the output of the 1-wire.
|
12 |
|
|
I experiemented with my own assembly implementation counting the machinecode cycles of
|
13 |
|
|
ATmega328 to setup ws2812 leds over one wire. The protocol has heavy time constraints +-150ns and the the data of
|
14 |
|
|
leds has to transmit one after another (https://cdn-shop.adafruit.com/datasheets/WS2812.pdf).
|
15 |
|
|
Here is an example of a 36 foot long neopixel strip https://www.youtube.com/watch?v=I-lR19_kigs.
|
16 |
|
|
The conclusion is that it makes no sense for me, since it is not portable.
|
17 |
|
|
To disable interrupts in impeded environments with sensitive application is not ideal.
|
18 |
|
|
There are some exceptions, such as the Rasperry Pi which has a real-time implementation
|
19 |
|
|
by using PWM with supported DMA (https://learn.adafruit.com/neopixels-on-raspberry-pi/overview).
|
20 |
|
|
Keeping timings conditions on a ATmega328 is feasible but on a CORTEX-A without HW-Support
|
21 |
|
|
running a sensitive application with caches, disabling interrupts is a bit extreme.
|
22 |
|
|
So I started my FPGA hobby project and dove right into FPGA programing and verilog.
|
23 |
|
|
My approach is using a SPI to collect 24-RGBs-Strips-Data and a SYNC from a impeded SoC.
|
24 |
|
|
Another approach I came up with is to reuse the Adafruit-Neopixel-Library.
|
25 |
|
|
I attached my FPGA_NeoPixel.h file. Technically it inherits from Adafruit_NeoPixel and overwrites
|
26 |
|
|
the void show() with SPI-Code so you are able to use the methods from Adafruit_Neopixel to set
|
27 |
|
|
leds or calculate color spaces. I have tested it on an Arduiono-Nano but it is easy to
|
28 |
|
|
port the Libs to other SoCs. The only things that matter are the SPI and Neopixel managment.
|
29 |
|
|
|
30 |
|
|
The implementation is based on an iceFun (ice40-hx8k, https://www.robot-electronics.co.uk/icefun.html). It is easy to port it to another FPGA,
|
31 |
4 |
splinedriv |
you only have to specify the frequency and pins. The current implementation is using a 1024-Fifo (ice40-hk8),
|
32 |
|
|
maybe you can even try to control an 1024 strip with it. The possibility to control over 5K with ice40-hx8 (128k/24 ~ 5.3k)
|
33 |
|
|
is given. You have only to modify the ADDRESS_LINE parameter of ram_sync in ws2812_ctl.v
|
34 |
3 |
splinedriv |
|
35 |
4 |
splinedriv |
A short video shows the result https://www.youtube.com/watch?v=IhsmrSM3q_E of my implementation.
|
36 |
|
|
|
37 |
3 |
splinedriv |
A FPGA has many I/Os just extend it to many 1-wire-outputs to handle more strips in parallel.
|
38 |
|
|
I will make my fpga project available on github and if you find the time to take a
|
39 |
|
|
look and tinker with it, I would be grateful for any feedback.
|
40 |
|
|
Some background why I started this project.
|
41 |
|
|
|
42 |
|
|
I searched for an open source command based verilog compiler and I found
|
43 |
|
|
Icarus Verilog (http://iverilog.icarus.com/) + gtkwave from Stephen Williams.
|
44 |
|
|
In this context I found verilator which is awesome. (https://www.veripool.org/)
|
45 |
|
|
Probably by accident I found the icestorm project by Mr.
|
46 |
|
|
Cliffword and I was so impressed by yosys and arachne-pnr/nextpnr because Synthesis is a domain
|
47 |
|
|
of some companies like synopsis, cadence, mentor graphics with very expensiv license costs.
|
48 |
|
|
In my opinion Mr. Cliffword changed the rules in circuit design (http://opencircuitdesign.com/).
|
49 |
|
|
I am very greatful to him. Now we have compilers for programming languages,
|
50 |
|
|
operating systems and circuit design tools FOSS like - it is so amazing.
|