Hallo,
ich wollte mein Projekt auf
https://github.com/splinedrive/fpga_neo_pixel vorstellen.
Es geht darum, das ein Device (Soc, whatever)
ueber SPI LED-RGB-Daten an das FPGA schicken kann und mit einem Syncwort
werden die Daten vom FPGA zu den ws2812-LEDs gerecht uebertragen.
Die Methoden der Adafruit-Library lassen sich auch nutzen,
wie das geht steht sieht man unter
https://github.com/splinedrive/fpga_neo_pixel/tree/master/src
Die Adafruit-Library laesst sich leicht auf andere Plattformen
portieren, da man die Show-Methode, die fuer die die Uebertragung
verantwortlich ist, nicht mehr braucht. Der Rest verwaltet den Zustand
der Leds. Die Show-Methode braucht nur eine SPI-Schnittstelle zur Not
ein BitBang (wir muessen ja keine Timings einhalten). Es ist leicht den
verilog-Code auf mehr Outputpins zu erweitern. Am Besten schickt man vor
dem Synch noch ein Datum welches angibt, auf wieviel Pins die Daten
aufgeteilt werden sollen. Das ist mein erstes verilog-Projekt und hat
Spass gemacht und meinen Weihnachtsurlaub ausgefuellt.
Weitere Infos unter
https://github.com/splinedrive/fpga_neo_pixel/blob/master/Readme.md
LG
Hirosh
Hi Chris,
ja das ganze laeuft stabil, ich habe es mit 60 Leds ueber Tage in
Kombination mit einem Arduino laufen lassen. Ich wollte ein Device
schaffen das die Timingconstraints fuer den ws2812 uebernimmt.
Man muss die RGB-Daten ueber SPI schicken und den Rest uebernimmt der
FPGA. Das schoene daran ist, das man die Adafruit-Neopixel-Library in
gewohnterweise nutzen kann und es kein grosser Aufwand ist, diese auf
andere Plattformen zu portieren, da man den ganzen Assemblercode nicht
mehr braucht. Die Show-Routine braucht nur SPI, zur Not implementiert
man dies ueber SPI-Bitbang.
Das Thema ist fuer mich durch, ich habe FPGAs neu entdeckt. Da gibt es
soviele Themen noch zu entdecken und nachzuimplementieren von
Filterstrukturen, AI, CPUs (RISCV), Controller, etc.
Das Projekt war eine gute Uebung fuer mich bzgl.: Crossclockdomains,
Statemachines, verilog, ...
Vielleicht hat ja jemand eine Anwendung dafuer.
LG
Hirosh
Hirosh D. schrieb:> ja das ganze laeuft stabil, ich habe es mit 60 Leds ueber Tage in> Kombination mit einem Arduino laufen lassen. Ich wollte ein Device> schaffen das die Timingconstraints fuer den ws2812 uebernimmt.> Man muss die RGB-Daten ueber SPI schicken und den Rest uebernimmt der> FPGA.
Damit das klappen kann, muss der FPGA aber Speicher haben, um die Daten
zu puffern, richtig?
Also habe ich die Wahl, einen zusätzlichen FPGA und zusätzlichen
Speicher zu verwenden oder einfach Programmieren zu lernen, um das
Problem mit dem µC zu erschlagen. Richtig?
Also ich ziehe Variante 2 deutlich vor... Hab' allerdings auch nix mit
Arduino am Hut...
c-hater schrieb:> Also habe ich die Wahl, einen zusätzlichen FPGA und zusätzlichen> Speicher zu verwenden oder einfach Programmieren zu lernen, um das> Problem mit dem µC zu erschlagen. Richtig?
Bei sehr vielen LEDs und hohen Bildwiederholraten kann der FPGA schon
nötig werden
FPGA Neopixel Device
====================
I was really impressed with the Adafruit Neopixel demo. The rainbow
effect looks so nice :).
It cost me around 5 minutes to setup the environment for the Adafruit
Neopixel.
While studying the Adafruit Neopixel implementation and the datasheet of
the ws2812,
some things immediately stood out: Assembly for each soc, disabling
interrupts to get the
right timings for each soc shape, etc.
Now I have a reason to buy an oscilloscope to the see the output of the
1-wire.
I experiemented with my own assembly implementation counting the
machinecode cycles of
ATmega328 to setup ws2812 leds over one wire. The protocol has heavy
time constraints +-150ns and the the data of
leds has to transmit one after another
(https://cdn-shop.adafruit.com/datasheets/WS2812.pdf).
Here is an example of a 36 foot long neopixel strip
https://www.youtube.com/watch?v=I-lR19_kigs.
The conclusion is that it makes no sense for me, since it is not
portable.
To disable interrupts in impeded environments with sensitive application
is not ideal.
There are some exceptions, such as the Rasperry Pi which has a real-time
implementation
by using PWM with supported DMA
(https://learn.adafruit.com/neopixels-on-raspberry-pi/overview).
Keeping timings conditions on a ATmega328 is feasible but on a CORTEX-A
without HW-Support
running a sensitive application with caches, disabling interrupts is a
bit extreme.
So I started my FPGA hobby project and dove right into FPGA programing
and verilog.
My approach is using a SPI to collect 24-RGBs-Strips-Data and a SYNC
from a impeded SoC.
Another approach I came up with is to reuse the
Adafruit-Neopixel-Library.
I attached my FPGA_NeoPixel.h file. Technically it inherits from
Adafruit_NeoPixel and overwrites
the void show() with SPI-Code so you are able to use the methods from
Adafruit_Neopixel to set
leds or calculate color spaces. I have tested it on an Arduiono-Nano but
it is easy to
port the Libs to other SoCs. The only things that matter are the SPI and
Neopixel managment.
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,
you only have to specify the frequency and pins. The current
implementation is using a 16K-Fifo (ice40-hk8),
maybe you can even try to control an 16k strip with it ;)
A short video shows the result
https://www.youtube.com/watch?v=bKlIKz7Y1Lk of my implementation.
A FPGA has many I/Os just extend it to many 1-wire-outputs to handle
more strips in parallel.
I will make my fpga project available on github and if you find the time
to take a
look and tinker with it, I would be grateful for any feedback.
Some background why I started this project.
I searched for an open source command based verilog compiler and I found
Icarus Verilog (http://iverilog.icarus.com/) + gtkwave from Stephen
Williams.
In this context I found verilator which is awesome.
(https://www.veripool.org/)
Probably by accident I found the icestorm project by Mr.
Cliffword and I was so impressed by yosys and arachne-pnr/nextpnr
because Synthesis is a domain
of some companies like synopsis, cadence, mentor graphics with very
expensiv license costs.
In my opinion Mr. Cliffword changed the rules in circuit design
(http://opencircuitdesign.com/).
I am very greatful to him. Now we have compilers for programming
languages,
operating systems and circuit design tools FOSS like - it is so amazing.
Moin,
nettes Projekt. Du koenntest auch gleich noch eine CPU mit in den ICE40
reinbauen, sollte locker fuer einige LEDs reichen.
Ich hab' so einen WS2812-Spass etwas anders aufgezogen und eine PWM-Bank
(eigentlich fuer Motoren gedacht) drauf angesetzt.
Pro Pixel schreibt man dann nur noch je einen 32-bit-Wert (effektiv 24
benoetigt) in die entsprechende PWM-Unit, die PWM clockt dann je nach
Bit das eingestellte Pulssignal ein.
Kann man dann im Timer-Interrupt machen, derweil die CPU dann
irgendwelche lustigen Farbanimationen berechnen darf. Fuer die grossen
LED-Panels hat's dann allerdings DMA gebraucht. Mit einem uC waere das
in der Form eine heillose Frickelei geworden.
Hallo Martin,
hoert sich gut an. Der Ice40 war halt zur Hand und habe auch billige
FPGAs von Gowin, da hat die Portierung 10 Minuten gedauert. Ich wollte
die Komplexitaet auf SW-Ebene weg haben. Ich hatte ja selber in
AVR-Assembler was ausprobiert mit WS2812 und hatte die Adafruit-Library
studiert und dachte mir, das kann es doch nicht sein :). Und auf einem
Cortex-A ist die Sache richtig schwer hinzubekommen, siehe z.B.
Raspi-Implementierung (Realtime nur ueber DMA-PWM).
LG
Hirosh D. schrieb:> A FPGA has many I/Os just extend it to many 1-wire-outputs to handle> more strips in parallel.> I will make my fpga project available on github and if you find the time> to take a
But this has already been done a lot of times so far, if i have a closer
look on the open source projects. I also recognized several projects in
the industrial invironment. Most 2D-LED large scale graphic arrays are
organized this way. The only issue compared to DIY project is update
rate.