blaz-r / pi_pico_neopixel

Pi Pico library for NeoPixel led-strip written in MicroPython. Works with ws2812b (RGB) and sk6812 (RGBW).
MIT License
254 stars 54 forks source link

Reading Neopixel data #15

Closed MichaelMuckKremtz closed 1 year ago

MichaelMuckKremtz commented 1 year ago

Well, I know this is a bit offtopic but since the code of the neopixel class looks so gorgeous I thought I might just give it a try:

I'm desperately looking for a way to read the first 3 RGBW pixels (3x 32 bit) of a Neopixel datastream with the pico using micropython and PIO. I'd love to use the data to drive stepper motors.

Could someone give me a hint if this is even possible?

Thanks a lot in advance :-)

blaz-r commented 1 year ago

Hello.

This library offers reading of any pixel value using get_pixel function, where you can specify the index. Would that work for you case?

MichaelMuckKremtz commented 1 year ago

Not in my case unfortunately cause the Neopixel signal is not generated inside the pico but comes in via a GPIO pin.

My idea was to have one state machine look out for the neopixels reset code of the data line being low for 80 microseconds and triggering a second state machine to measure the length of the PIN HIGH condition and send the measured time (in clock cycles) to the main core that saves the first 3x 32 bit in an array for further processing.

But all 96 bits that I need to catch arrive in just 115 microseconds. After that there is plenty of time to process them: 30 milliseconds until it all starts over again.

The second core would then be used to run threads that care of sending the steps to the A4988 stepper driver..

It's a lot of work but in the end it would open up so many possibilities! See here what I'd love to move: https://github.com/orgs/micropython/discussions/11873

blaz-r commented 1 year ago

I see. How come that you can't control the stepper driver by the same controller that sends the signal to leds?

Anyway, I'm not sure I can help you much with implementation of this, but from what I see, you want sort of a signal analyzer? There is one blog about this, the code is in C though, but can be of some help.

MichaelMuckKremtz commented 1 year ago

Thanks for the link!

I can't control the stepper driver by the same controller that sends the signal to leds cause it would be too far away from where the motors would need to be. The installation is around 3m in diameter and the led driver might be another 10m away while beeing busy pumping out thousands of pixels.

My naive idea was to just embed the necessary data for the motors as 3 additional RGBW pixels in the data stream. But since that's likely too tricky to get them back out I'll need a second cable connection for the motor unit that uses DMX instead. Next to the pixel data there will be a DMX line for classic fixtures anyway. But the less cables the better...

Do you have an idea where I might find someone who could be interested in providing such a function to the community? There is so much stuff that could be done with pixel data... gif_moving_heads

blaz-r commented 1 year ago

Okay, I understand this thing now. I think that it's certainly possible, but quite tricky to use neopixel protocol for that. I don't really know who could provide this function, but wish you all the best with the project. It looks quite interesting.

MichaelMuckKremtz commented 1 year ago

thanks!