vanshksingh / Pi5Neo

Library to Control Neopixel on Raspberry Pi 5 using python
MIT License
10 stars 5 forks source link

Longer LED chains do not work correctly #2

Open jrwrodgers opened 1 month ago

jrwrodgers commented 1 month ago

@vanshksingh When using this library and the example code with 256 LEDs - some after #178 are not the expected colour and then some beyond around #200 don't light up at all. I logged the data pin with an analyser and got the following for a single red led instruction.

Is the data packet terminated correctly and should it stay low? Is this why as more LED's are using bits might be lost? Is the full data packet being sent with xfer? or is xfer2 needed? image

vanshksingh commented 1 month ago

Library uses xfer3 right now , previously it was xfer2

My best guess why it fails is , the 3.3v line , jut not enough power for long length transmission...

Can you tell me more about how you are powering the setup ? And any step up that you have/may implement for 3.3v to 5v conversion ?

I recently got an 1 meter strip of neopixel to test the lib , but I think it will fall short of the 256 mark

jrwrodgers commented 1 month ago

@vanshksingh I'm using a dedicated 5v power supply for the LED's - its a XLSEMI XL4016 .. and able to deliver 8A. I think 255 LEDs draws (50mA each on white) ~ 3A so should have plenty of headroom. The digital signal is from the raspi 5 on GPIO 10 (MOSI). See image of an attempt to light all LEDs in red. If I reduce the number of LEDs then it works fine. image

I wondered if its because the expected digital signal should have a low between each LED packet but with the MOSI line it stays high? image Then at some point it misses one of the color bytes and changes red to blue... and then doesnt have enough info to have any color?

Apologies if I'm talking nonsense, this is all new to me so I'm on a steep learning curve.

Are there any tests you would like me to try?

Also for reference this is the code I'm using: from pi5neo import Pi5Neo import time neo = Pi5Neo('/dev/spidev0.0', 255, 800) for i in range(1): print(i) neo.clear_strip() neo.fill_strip(50,0,0) neo.update_strip() time.sleep(5) time.sleep(1) neo.clear_strip() neo.update_strip()

vanshksingh commented 1 month ago

I would say this is an very good issue being pointed out

I can only guess at this point of time , as xfer 3 should have eliminated the issue , see here

I think ill have to buy a similar strip and test it myself to fix it (if it can be fixed)

My only guess is voltage drop OR it can also the be type of the led at play like 1 and 2

Apologies if I'm talking nonsense, this is all new to me so I'm on a steep learning curve.

I am actually quite impressed with the oscilloscope readings

wdebusschere commented 1 month ago

@jrwrodgers @vanshksingh

I’m experiencing an issue where only a maximum of 171 LEDs work on my 300 LED strip. Here are the details:

•   With 171 LEDs, all light up red as expected.
•   With 200 LEDs, the first 29 are blue, and the next 142 are red (totaling 171 functional LEDs).
•   With 172 LEDs, the first is blue, and the remaining 170 are red. (see photo)
•   With 300 LEDs, the first 129 are blue, and only 42 are red.

Screenshot 2024-10-01 at 11 04 02

I also tested with neopixel_spi i can access more leds, but its also behaving weird, random lights light up..

yerkyerk commented 3 weeks ago

I can confirm the issue, if I set up to 171 leds it works fine, but if I set the maximum of leds anything higher, than anything past 171 lights up red and on the wrong position (actually, led 171 corresponds to position 0 on the ledstrip, 172 to led 1 and so on). The first few leds will be less bright and start blinking. The higher I set the max leds, the more the first few leds will be working poorly, as if it somehow loops back to the beginning after 171 and starts messing with itself. A shame, as this is so far the only library I got to work smoothly with a pi5.

wdebusschere commented 2 weeks ago

@yerkyerk If you increase the SPI buffer you can control more leds.. BUT it will still not work 100%, leds flicker, random colors,..

anico97as commented 4 days ago

Hi @vanshksingh ,

changing the SPI buffer size worked well for me. Adding spidev.bufsiz=32768 to /boot/firmware/cmdline.txt and rebooting afterwards did it for me as well. For my usage scenario i could´nt detect any issue with flickering, random colors etc..

Thanks @wdebusschere

Thank you very much for providing this lib

anico97as commented 3 days ago

How can brightness level be adjusted?

vanshksingh commented 3 days ago

How can brightness level be adjusted?

Using this example on line 15:

control_single_led(neo, 2, (0, 255, 0)) #RGB Values Range 0-255

Right now it is set to show Green color on full brightness, if you change it to:

control_single_led(neo, 2, (0, 128, 0)) #RGB Values Range 0-255

You effectively set the brightness of the green to ~50%

0-255 is the 8bit range of the brightness/intensity values it can take

for example this is white at max brightness : control_single_led(neo, 2, (255,255,255)) #RGB Values Range 0-255

For ~50% brightness just remove 127 from all values

white at ~50% brightness : control_single_led(neo, 2, (128,128,128)) #RGB Values Range 0-255

vanshksingh commented 3 days ago

Hi @vanshksingh ,

changing the SPI buffer size worked well for me. Adding spidev.bufsiz=32768 to /boot/firmware/cmdline.txt and rebooting afterwards did it for me as well. For my usage scenario i could´nt detect any issue with flickering, random colors etc..

Thanks @wdebusschere

Thank you very much for providing this lib

Thank you for testing, I will add it into the notes for the time being , the better fix would be to make a kernel module and implement it that way. I want to retain the pip package manager support too , so I will have to research into all that.

anico97as commented 3 days ago

@vanshksingh Thank you very much for the infos.