Bela Mini, from PD running on mac
Control Neopixel with Pure Data
And what neopixel board?
it is a stripe >> https://www.adafruit.com/product/1507
- Edited
do you know what chips it comes with ? I see that since June 2022 it ships with these https://cdn-shop.adafruit.com/product-files/1655/SKC6812RV__12VOP0274E_REV.A1_EN%2812%29.pdf
The timing of the low signal here is slightly different from what's in O2L. Try changing
{.min = 750, .max = 950}, // T0L
in AddressableLeds.h to
{.min = 850, .max = 1000}, // T0L
and change
static constexpr double kSpiLeadingZerosNs = 50000; // determined empirically
to
static constexpr double kSpiLeadingZerosNs = 220000; // determined empirically
See if that changes anything.
Now for the real stuff: according to the electric specs in the datasheet the power supply Vdd needs to be 3.7V < Vdd < 5.5V and the high "Input signal flip threshold" VIH has to be at least Vdd*0.7, so if you are powering it from 5V, the 3.3V signal from Bela will not be enough.
This means you need some way of providing an in-spec voltage. A few options:
- power the LED board not from 5V but from 5V in series with a power diode. The dropout on the diode 0.6V will give a Vdd of 4.4V and a VIH = 0.7 * 4.4V = 3.08V so the Bela's output should be sufficient to drive the data line. As the PWM drivers are supposedly constant-current, then the drop in power shouldn't affect brightness, but if you have many LEDs, then you may have to be careful about the current limits of the diode: I recommend an 1n4007 or better. This is probably the easiest to try out (as it's common to have spare power diodes around).
- level shifter: add a 3.3V to 5V non-inverting level shifter
- transistor: use a transistor as an inverting amplifier to turn 3.3V into 0V and 0V into 5V. I think this needs the following changes in the code, but I cannot test it:
- set kSpiLeadingZerosNs = 0;
- change
in AddressableLeds.cpp toif(value)
if(!value)
Thanks for the reply! Yes! it works
The first trick you've mentioned (changing the timing) did not work. It goes crazy when signals are not sent.
I inverted the signal with transistor (2N7000) with 1k resistor (see the attached schematic note).
From the code side, I changed on AddressableLeds.h
- {.min = 750, .max = 950}, // T0L to {.min = 850, .max = 1000}, // T0L
I changed the timing, but the original timing also works when signal is inverted
- static constexpr double kSpiLeadingZerosNs = 0;
and AddressableLeds.cpp
if(value) to if(!value)
I am feeding 3.3V to neopixel strip with signal level 3.3v and it is running very stable now.
On the oscilloscope, the inverted signal looks rounded, but it is working. I guess it is coming from the transistor (this one's Turn on delay time is 10ns). Maybe one can use faster transistor.
That's great news, thanks for coming back to us with your findings. The turn-on time is 2 orders of magnitude smaller than the rising time you are seeing, so it shouldn't be the main culprit here. To fix those smoothed edges I'd try adding a ceramic capacitor (100n or more) between 3.3V and GND very close to the 2N7000.
Hi @giuliomoro - in case analog I/O isn't needed, is it enough to just disable that from the project settings and then update main.cpp of O2L with PinmuxUtils::set("P9_18", "spi") to use the BBB SPI0 without having to bend pins?
yes that should work. However, I recommend you check out the "pixelbone" branch. That one uses P8.35 without sacrificing neither the analogs nor the audio ins.
- Edited
giuliomoro It seems the BelaArduino library is missing, is that some custom port of the Arduino headers for Bela, similar to RasPiArduino? Also, is it still necessary to load the device tree overlay with the pixelbone version?
Try the latest commit from that branch, which removes that dependency.
giuliomoro Would you please elaborate a bit on how to use the pixelbone branch? For context im using ws2812b and was able to install O2L and setup program as service but was not able to test. I tried both example files and nothing happened, is P8.35 one below analogue input row? I intend to work in wiring as im not fimilar with pd or supercollider, would you pls share some insight on how that will work. Thanks
You can see it here, you have to count pins from the edge. Trying to align it to the analog headers is error-prone.
With the correct pin, just run the project, download the patch local.pd
to your computer and run it with Pd. That will use your computer's microphone to make a vumeter and send OSC to the board, which will translate them to the neopixel.