Can't get WS2801 (SPI rgb leds strip) to work with Omega2
For a project, I'd like to replace my working Raspberry PI Zero with my brand new Omega 2 (mounted on an Arduino Shield).
The purpose is to drive a short led strip using the Omega's SPI interface, with a level shifter in between to have the 3V3 logic levelled up to 5V.
Small schematics :
Omega2 Level shifter Level shifter Led strip high side low side 5V VCC VCC 3V3 VCC GND GND GND GND pin6 io1 io1 SCK pin18 io2 io2 SI
This exact setup works with the raspberry pi (PI -> Level shifter -> Led Strip), so I know for a fact that the level shifter and led strip work fine.
But with the Omega2, I can't get the system to command the lights. I tried modifying Adafruit's WS2801python library to use OnionSpi lib instead of theirs, but with no success.
Eventually, I tried a more basic approach using the command line, just to try to switch on/off the first led like this :
spi-tool -b 1 -d 32766 --frequency 1000000 setup > SPI device already available > Initializing SPI parameters... > Set SPI mode: 0x500 > Set bits per word: 0 > Set max speed: 1000000 Hz (1000 KHz) > SPI Write to addr 0x00: 0x66 root@Omega-A24B:/www/ws2801# spi-tool -b 1 -d 32766 --mosi 18 --sck 6 --frequen cy 1000000 write 0x00 0x66 > SPI Write to addr 0x00: 0x66 root@Omega-A24B:/www/ws2801# spi-tool -b 1 -d 32766 --mosi 18 --sck 6 --frequen cy 1000000 write 0x01 0x66 > SPI Write to addr 0x01: 0x66 root@Omega-A24B:/www/ws2801# spi-tool -b 1 -d 32766 --mosi 18 --sck 6 --frequen cy 1000000 write 0x02 0x66 > SPI Write to addr 0x02: 0x66
... but nothing happens! (I got the 1MHz from Adafruit's lib).
Any idea on why that wouldn't work?
Side note :
Both of my Omega2 are making high pitch noises when powered, I don't know if it's normal or if they have a problem (I might be wrong, but I don't think it comes from the Arduino Shield).
You seem to be trying to do software SPI, using the /CS1 pin to bitbang a clock. That raises two questions which might be most easily checked with a scope, though perhaps someone who has made it work will be able to give you guidance without taking measurements.
Is pin 6 (/CS1) being succesufully manipulated as a GPIO, or is it still configured to be an (hardware) SPI chip select, such that the GPIO operations have no effect on it?
Does software SPI actually work and output data at the correct rate? Or are there issues with it that still need to be worked out for this particular system?
@Chris-Stratton Thanks for your answer.
I didn't know these pins were for software SPI. The leds strip is the only thing plugged on the system, so I'm willing to use whatever SPI is the simplest.
How should I plug everything to use hardware SPI (which might be easier or require less configuration to use)?
By the way, I don't have a scope around, so I'm not able to answer your questions...
Thanks for your answers !
I saw a comment from Onion saying there was no hardware SPI available. But it was about first version of the omega, maybe V2 has one now.
I used Pin6 as clock and pin18 as MOSI as it's what was described in the official help, but there is no specification there about it being hardware or software. Something I don't really understand, is why in the examples and in the questions in the forum, everyone connects to bus #0, device #1 while my strip is mounted as bus #1, device #32766. And I'm not sure this is relevant at all...
Also, the link to documentation provided in a previous question is no longer available (at least to me). I get a "Forbidden. This wiki is set to no-edit mode. " error.
I think your link is to an Omega (1) guide, the pins it recommends won't necessarily be appropriate for the Omega2, though there's also a question if the overall approach is even a match.
I took the pins numbers from the documentation for the Omega 2, so the page is probably not up-to-date !
So, thanks for pointing me in the right direction !
I now can drive my led strip ... but only the first 16 values !
If I do :
values =  * 16 # 16 or any lower number values = 255 spi.write(values) time.sleep(0.5) values = 0 spi.write(values) time.sleep(0.5)
I can see the led flashing.
But if instead of 16, I use a bigger number, I get :
onion-spi:: Trasferring 0x00, 17 bytes ERROR: SPI transfer failed
and the led doesn't blink anymore (I have way more than enough rgb leds, and they all work, so it shouldn't be a problem from this side). Also, I only switch one ON at a time, not to draw too much current.
So I told myself that maybe the Omega wasn't able to send more than 16 bytes, so I tried to directly send values to the pixels using their addresses, but this method doesn't work as expected (as I expected, at least). I get :
spi.writeBytes(5, [255, 0, 0]) # does the same as this : spi.write([5, 255, 0, 0]) # instead of being roughly an equivalent to this : spi.write([0, 0, 0, 0, 0, 255, 0, 0]) # or more exactly that wouldn't set previous values to 0
Am I missing something about SPI in general, or is there something about Omega's implementation? Adafruit's implementation for SPI doesn't contain any writeByte() equivalent, only a write(), so I can't really compare the way the bits are assigned...