NEOPIXEL AS A LED RING LIGHT

HELLO
I WANT TO USE NEOPIXEL LED RING LIGHT , STANDARD MICROPYTHON LIBRARY WILL WORK?

http://docs.micropython.org/en/v1.8.2/esp8266/esp8266/tutorial/neopixel.html

It should work, if it doesn’t let us know and we’ll fix it.

import machine, neopixel

error no module name
kindly help

Regards

Hmm, this seems to be an ESP8266 only library. Should be portable to the M7 however. Please open up a github issue about this so it’s on our todo list.

Is there any news on using the neopixel library with openMV. I still get an unrecognized error.

Try this:

thanks so much excited to try it out

Jan Bednarik’'s ws2812.py does not work on OpenMV firmware V3.6.7, because when the first bit is 1, the SPI sets the MOSI pin high for a while before starting the clock. While this is not an issue for SPI communication, it disrupts the waveform timing required by the WS2812. Padding the buffer with leading zero keeps the MOSI pin low until the first byte of the WS2812 protocol reaches the MOSI pin.

Although this does not work reliably as the SPI randomly has a spike on MOSI pin before some transmissions that confuses the WS2812.


Also be sure to use filter RC on the Vcc of the neopixel LED (R=150, C - 0.1uF).

We have not changed the behavior of the pyb.SPI driver. That’s how the STM32 hardware SPI works. It’s not a firmware thing. This, this has been an issue with the code posted from day 1 in this case.

When you load data into the SPI peripheral the leading bit is put on the wire before the clock starts.

The random spike you are seeing probably is data getting shifted in… the SPI hardware uses a circular shift register.

Padding with 16 zeros provides the >50us reset time and reduced the glitches from this spurious pulse on the OpenMV SPI MOSI line. However glitches still occur and may be due to the period on the SPI of 1.6us being more than spec of 1.25us spec for the WS2812.


Is there a way to bit-bang a pin in OpenMV to generate pulse widths of sub 1us for the WS2812 protocol?

Yes, use the machine spi module: class SPI – a Serial Peripheral Interface bus protocol (master side) — MicroPython 1.15 documentation

It’s bit banged spi.

Do you have some example code for the bitbanging (software) implementation of SPI?

The WS2812 is a single wire protocol. Can the bitbang SPI be setup to only use one of the OpenMV Pins for MOSI and not tie up 2 other pins for MISO and SCK that will not be used?

Just make the line high and low and use delay_us().

The STM32 has a lot of interrupts however. So, it probably won’t work. The OpenMV Cam has a lot going on. You kinda need to use the hardware features to get any timing control. (You could disable interrupts… but, that would not be a good idea)

Just make the line high and low and use delay_us().

The STM32 has a lot of interrupts however. So, it probably won’t work. The OpenMV Cam has a lot going on. You kinda need to use the hardware features to get any timing control. (You could disable interrupts… but, that would not be a good idea)

There is about 4us of overhead in the pyb.udelay. A 1 us pulse width comes out closer to 4 us (without interrupts). The WS2812 protocol calls for pulse period of 1.25 us.

pyb.udelay(1)
clk_pin.value(1)
pyb.udelay(1)
clk_pin.value(0)
Annotation 2020-08-25 121624.jpg

Let’s just try to get the SPI hardware working like you need:

https://www.st.com/resource/en/reference_manual/dm00314099-stm32h742-stm32h743-753-and-stm32h750-value-line-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf

See page 2180.

Here’s the SPI code:

To note, on the H7… SPI.receive() is broken in DMA mode. You need to use send_recevive() in DMA mode. Then the receive is perfect. I think SPI.send() works fine in DMA mode. DMA mode should activate automatically as long as the data is longer than 1 byte and interrupts are on (and the data buffer is in a RAM segment DMA can access).

Let me know if you see a reason for the glitch.

Hi guys,

I’ve tried this driver with the Adafruit Neopixel RGB ring (24 LEDs). It works, but the first LED stays green when off. It seems to remain at the intensity of about 50 in the 8-bit intensity range. I can increase the intensity. However, when I set all LEDs to zero, the first one remains on in green.

Initially, I thought it was damaged. I unsoldered it so I ended up with 23 LEDs. Now, the second LED has the exact same issue.

I tried powering the ring with both external 5V (with common GND) and the OpenMV’s 3.3V power supply. The issue persists.

Any ideas?

Our MCU is not good for this because the SPI pheriphal doesn’t handle it well and the processor has a ton of interrupts. We recommend another MCU to control these.