Controlling WS2812 device (RGB LED strip)
@administrators : Is the solution proposed by @Lukas-Zeller the one to follow to work with WS2812 and the first Omega, or have you been able to finish your neopixel library ?
@Lukas-Zeller : There is a dependency error now, when we try to install the opkg.
It gives this :
root@Omega-XXXX:/tmp# opkg install /tmp/kmod-ws2812-draiveris_3.18.29+0.1-9_ar71 xx.ipk Installing kmod-ws2812-draiveris (3.18.29+0.1-9) to root... Collected errors: * satisfy_dependencies_for: Cannot satisfy the following dependencies for kmod-ws2812-draiveris: * kernel (= 3.18.29-1-ec3c73d5690ecfdba6d7368603798b4e) * * opkg_install_cmd: Cannot install package kmod-ws2812-draiveris.
There probably has been some updates to the linux kernel since you posted, but I don't know how to lake it work.
@Brice-Parent This is an issue that has been around for quite some time. Generally it means that the kernel version the package was compiled for does not match the kernel version on the Omega.
This issue occurs for some other packages as well and has been drawn to the attention of the Omega guys though a resolution is still awaited.
It may be worth trying the command
opkg --force-depends install <package>to do the install ignoring dependency issues.
This may work OK so long as the kernel differences are not significant for the package.
AFAIK there's no way yet (due to a few missing files) to setup an OpenWrt build environment that exactly matches the official builds, so that's a problem we have to live with for now.
The WS2812 driver is very simple regarding kernel infrastructure it uses, so the kernel version mismatch is not a problem here.
The real problem one should be aware of when using this driver is that it blocks interrupts for several milliseconds when updating the LED chain (see my post above). This might break timing in other parts of the system - probably streaming audio would not work in parallel, and maybe it will also affect network performance.
In my experiments with an Omega not doing much except nice LED animations, I didn't notice any side effects, though :-)
Hi...as per my knowledge the Omega has General Purpose and Watchdog timers that you should be able to use to get the timing down.However, an easier option might be to use the Arduino Dock since the ATmega can very precisely control its output timing with probably less hassle than the above. Then you can use the Omega to send the Arduino chip instructions on what colors to set and the Arduino chip will do all of the low-level stuff.
awesome work @Lukas-Zeller. should start saving for a big roll of ws2812 asap :)
[Updated because of confusion between WS2813 and APA102]
@youlian-troyanov Before investing into WS2812 LEDs, you might want to check out
Only very recently a colleague told me about the
WS2813APA102, I wasn't aware of these before.
The big advantage of the
WS2813APA102 is that it uses standard SPI protocol, which almost any SOC can generate without dirty tricks, including Omega1 and 2. In addition, the WS2813APA102 seem to have a much higher PWM rate, which means that they are now suitable for POV (persistence of vision, fast moving LEDs e.g. mounted along fan blades creating the illusion of an image).
That's what I've read and have been told so far - I just ordered a WS2813 based LED strip to try it out, hopefully it will arrive soon ;-)
[Update: I meant to get the APA102, but I ordered WS2813 and so I got exactly these. Only then I found out about the confusion with the APA102, aka DotStar. The WS2813 also has two data lines, but the second is a backup line that keeps a chain working even when some LEDs fail. Otherwise, WS2813 uses the same data format as WS2812, with a few improvements: 2kHz PWM rate vs 400Hz, longer reset time of 250µS vs 50µS.]
@Ira-Burns yes, the AR9331 in the Omega1 has some timers, but unfortunately (being designed for WLAN routers, not IoT) it does not have PWM outputs that can be controlled by these timers.
Using the timers for generating interrupts does not work either because that's way too slow to meet the tight WS2812 timing. So for the Onion1, the only way to do it is blocking interrupts and then bit-banging output lines as the ws2812-draiveris driver does, or using the Arduino dock as you suggested.
But I don't like spending room and power for operating a second, much inferior CPU, just to move the ugly stuff (block IRQs, bitbang data, there's no other way to do it on the Arduino either) outside.
The Omega2's MT7688 chip however was designed for IoT and does have PWM outputs - I guess it will be possible to create a WS2812 driver using timers, PWM and DMA that works without blocking interrupts. We'll see when the Omega2 arrives…
For the Omega1, using
WS2813APA102 instead might be a elegant solution.
thank you @Lukas-Zeller. excellent advice, especially about pov, that's something i wanted to experiment with, you just read my mind :)
@Lukas-Zeller Great, looking forward to hear from your test. I'm planning to install lots of LED STRIP (Addressable) in my house but didn't find a low cost controller expendable to connect all my sensors until I saw Omega1. Now with Omega2 power and even cheaper with Led Strip WS2813 sound like a perfect match for my project. Did you also look at the SK6812 who support RGBW (True white not RGB composite which take way less power)?
@Eric I recently bought a SK6812 based strip but haven't found the time yet to try it out. Having RGBW should make these much more suitable for actual lighting, not only decoration. I will post a followup here once I have tried these, probably I'll do it along with the WS2813 tests.
@luz : I'm really interested about your feedback about those WS2813 and the ability to use them directly from our Omegas. I've just order a few of them, but they'll be sent from China to Europe and won't arrive until a few weeks, so in the meantime, if you can make it work, I'd be glad to know how you did.
And if not, or if you needed extra components, I'm all hears too!
@Brice-Parent I just tested my SK6812 strip and it works fine! :-)
As each LED now needs 4 bytes of data (instead of 3 with WS2812), I had to modify the ws2812-draiveris kernel driver to add an option for RGBW LEDs.
insmod /lib/modules/4.1.23/ws2812-draiveris.ko gpios=7 leds_per_gpio=20 rgbw=1
Please note that I falsely thougth the WS2813 LEDs were the new SPI interfaced ones - they are not, just improved WS2812 using same data format with an additional wire (keeps chains working when one chip fails). The new SPI ones are called APA102 (of which I now also ordered some samples, but will take another few weeks to arrive). I edited my earlier posts above accordingly.
So the status is:
- WS2812 (RGB, 3 wires) : works with original ws2812-draiveris
- WS2813 (RGB, 4 wires) : also works with original ws2812-draiveris
- SK6812 (RGBW, 3 wires) : work with my modified ws2812-draiveris with extra "rgbw" module parameter
- APA102 or "DotStar" (RGB, 4 wires, SPI) : should work with standard SPI, but can't test until I get samples in a few weeks.
@luz Too late for me, I've ordered the WS2813 (but I won't get them until some weeks).
So, it means that I need an interface between my Omega and the led strips, like an Arduino for example? Or is it still possible to drive the strips directly from the Omega, even with some other running service which could make a synchronised communication hard?
I tried your cool way to control leds.
Driver is working correct, and I can echo some colors to the leds.
But sadly messagetorch is not working for me.
Installation was ok, but start fails with "-ash: messagetorch: not found"
Binary is in "/usr/bin/" folder.
Same message appears if I try to open it via "/usr/bin/messagetorch".
I'm on latest 0.1.4 b330 version of omega and also resetted it to factory. But still the same.
Do you have an idea what else I can try?
Thanks in advance.
@Brice-Parent No need for extra hardware, you can drive WS2812 and WS2813 directly from the Omega, using the ws2812_draiveris kernel module. I mentioned the fact that the driver blocks the kernel for relatively long time because it will affect other kernel timing that is in the sub-millisecond range.
In practice however, I haven't noticed any delays in the usual services running in parallel on the Omega (ssh, onion desktop etc.).
So it's basically just a thing to keep in mind, in case you experience strange behaviour with other peripherals that might rely on tight timing. But otherwise, just use ws2812_draiveris and enjoy the colors :-)
@Thomas-Mueller Hmm, im about to leave for a week of vacation - but on one of my Omegas indeed messagetorch does not work (it does on another one, though). I guess it must be something with libary dependencies, probably my build depends on a newer version of libstcpp or librt, which might be fixable/hackable by symlinks. I'll look into it when I'm back in a week.
thanks for having a look into this.
I have compiled the source now on myself and now it seems to work.
If I have a couple of hours freetime in the next days I will build a "test torch".
If someone is interested in the binary which is working on stock Onion firmware then let me know and I will upload it somewhere.
Genieß deinen Urlaub!
I actually saw this post a few days ago, and I had previously been planning on having 5050 RGB strips in my room. I was planning on using the esp8266 but when I realized that it would take some time and programming understanding to control the rgb's, so I decided to use an LED amplifier because they generally cost less than $2 even with a remote. So I am going to use an arduino ir receiver to read the encoding from the remote and replicate it, so that the arduino/omega can send the ir signals to the RGB strips and I dont have to do much work.