Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LEDs laggy FPS normal #37

Open
k15866AL opened this issue Feb 21, 2021 · 15 comments
Open

LEDs laggy FPS normal #37

k15866AL opened this issue Feb 21, 2021 · 15 comments

Comments

@k15866AL
Copy link

k15866AL commented Feb 21, 2021

Hey mate, thanks for being so responsive to everyone so far. What I've found so far has helped me get lights on and seems somewhat responsive to music. I have similar issues to others where the lights are laggy, however in my case the FPS is consistently at 50/80

I have tried the 3 modes (Spectrum, scroll and energy and they all behave the same way.

Setup is Raspberry Pi charger > Rpi > Jumper cables (power, data, ground) > Neopixel Strip 60 (now 55 LEDs) due to learning to solder).

By laggy what I mean is that the lights may stay on one colour for 2-3secs before changing / become blank. The LEDs tend to display a rainbow of colours rather than having a gradual change from eg. red to orange to yellow
I have tried switching from GPIO 18 to GPIO 12 with slight improvement (more consistent lighting up), but still nowhere close to the video.

Strangely when I increase the amount of processes on the RPi, the LED strip behaves closer to a 50FPS flashing of lights but is limited to maybe the first 10 LEDs, LEDs after this only light up intermittently and are the laggy variety. Best performance occurred when the OS was frozen due to running multiple browsers incl youtube

I've tried leaving unplugged for a while which didnt change anything, tried rewiring parts of my connection without much change. I thought if I unplugged HDMI and decreased brightness it might reduce power usage and therefore improve performance but this did not help

I've also tested on another RPi with the same result and a different SD card with same result. I thought this would be more a hardware issue / bad soldering job, until the extra processes helped. The only way I could conceptualise it is if there is too much data input to the strip at normal conditions, then when RPi processor is overloaded, it slows things down so the strip behaves closer to normal? But even this I would expect to be choppy improvements.

I tried running this remotely with SSH but ended up with a 'Invalid Sample rate error' so thought I'd leave the remote access till lights are working.

@naztronaut
Copy link
Owner

What kind of power source are you using? And what version of the Pi are you using?

This could be a power issue, the strip may not be getting enough power. You could try using external power instead of powering through the Pi.

If you're using the official neopixel lights, check out the following post that recommends putting a resistor and capacitor in the circuit: https://learn.adafruit.com/adafruit-neopixel-uberguide/best-practices

The lights I use are generic and don't require either.

You can also unplug everything and then plug everything back in from scratch. Sometimes just starting from scratch is all the project needs.

@k15866AL
Copy link
Author

I'm using a 5.1V 2.5A plug into the RPi 3B
I was hoping to just replicate your build, but it seems since mine are official neopixels maybe I need to add as you said. I was hoping I wouldnt need to do more soldering lol

@naztronaut
Copy link
Owner

Maybe the neopixels are pulling more power than my generic strip. That's my only guess.

I don't think you need to solder. If you look at that post, they just jam the capacitors and resistors in circuit without soldering.

Two other things you can try is get a power supply with higher current, maybe 3A or 3.5A. OR use external power for the LEDs (a separate 2A power supply could do the trick).

Last thing to try, instead of trying to light 55 leds, try 10 or 20 and see if that makes a difference. The Neopixel hardware could still need a resistor and capacitor but this is probably the easiest thing to try without making any changes.

@k15866AL
Copy link
Author

Thanks, I've been wondering for a while how that capacitor is actually staying in place, how graceful a solution.
Just wondering how much capacity was your powerbank and how long did it last for your number of pixels?

I'm not great around the electronics, just checking if I find a power supply that is 3-3.5A could this still be connected to the RPi? or do you mean as a separate power source for the strips

If I change N_PIXELS =10 in config.py, would that replicate what you are saying? I find when I do that most LEDs flash at the FPS however the the first 10 are still most active. Or do you mean cut the strip to 10 LEDs?

@naztronaut
Copy link
Owner

The power bank I have outputs around 3A and has a charge of 16Ah. It can last hours. I don't think I ever put it to a full test but the longest I've had it run was probably 3-4 hours.

You can connect a 3.5A power supply to the pi without a problem, it'll draw whatever power it needs. It's the voltage that needs to be around 5V. The current can be higher or lower without problems.

And I kinda meant both, you can try to power your Pi with more power OR use a separate power supply for the strips.

And yes! The N_PIXELS is exactly what I meant. You don't have to cut it. It's worth a try, I'm not sure if it'll work, it's just an easy test.

@k15866AL
Copy link
Author

Ok I'll give these a go

Yeh so even if I change N_PIXELS to 10, all LEDs (1-55) still light up but none ever get to white light.
If I set N_PIXEL to 60 then the first 10ish are flashing mostly white light

this makes me think a power issue. But it's still weird that I have to be doing things that consume power in RPi's OS for the above to happen.

@naztronaut
Copy link
Owner

That is strange. The python code should only be sending a signal to the first 10 LEDs. I wonder if Neopixels are wired differently.

One thing to know about these lights is that they are directional. Can you double check that they are connected the right way? There should be arrows on the strip pointing which way the current should flow.

@k15866AL
Copy link
Author

k15866AL commented Feb 21, 2021

Yep can confirm it is in Din side and arrow point away from the side my cables are on

If I am using an external power source eg Powerbank > usb cable split with + to LEDs, I read in one comment that the ground for the power supply needs to be split between the ground of the strip and ground of the Pi.

I currently have a cable from Strip to Pi, could I just add the power supply's ground cable to this existing cable (would look like a T junction)

EDIT: Or perhaps even just a separate ground cable into a separate ground pin on the Pi?
EDIT2: I beginning to wonder, does the Power DOut and Ground on the other side need to connect to anything? I just assumed since lights were on that this was enough, but perhaps wrong

Thanks

@k15866AL
Copy link
Author

k15866AL commented Feb 21, 2021

Rpi
This is what I ended up with
2amp powerbank was best I could find but Neopixel site suggests 2A should be enough for 60LEDs
Still does better with more processes running on RPi
Perhaps slightly better performance with the tail end lighting up slightly more but fairly similar.

The other end of the LED strips is still not connecting to anything

Also found this scottlawsonbc#325
but I thought I had a common ground before this setup with Neopixel ground > RPi Ground Pin. Not sure if my current setup is considered common ground as I have used two RPi ground pins

Further reading suggests may be I need to use a logic level shifter? to change data voltage from 3.3V to 5V that is required for LEDs

@k15866AL
Copy link
Author

k15866AL commented Feb 22, 2021

Have recreated the build in this (https://www.youtube.com/watch?v=Pxt9sGTsvFk), thought I had a winner with the changes to /boot/config,
No significant changes after adding logic level splitter. Perhaps a few more lights further away from Din are lighting up and rather than stay on for 2-3 sec, maybe 1 sec. Still does not follow N.PIXEL = x, and flashes are rainbow in colour mostly. still require other processes ongoing in OS to get higher frames of light changing. Doesnt really follow the pattern of energy/spectrum/scroll.

Also found a 2.4A USB source but no difference

I'm stumped, I feel like the not enough power hypothesis is less likely
Perhaps an issue with Data In? or something with how I am grounding, but having followed the diagram in the video so unlikely to be this
RPI FPS is good and have tried two RPis so seems RPi hardware is not the issue

I thought it might be a dodgy soldering job, but feel like the results would be more unpredictable if this were the case. But this feels like my only option left to try. Or maybe buy a generic neopixel strip

If it helps running strandtest.py does not reproduce expected results, only the first 3 LEDs light up during Rainbow Animations and might only change colours once, no lights during the other two modes. Not sure how to interpret this result

¯_(ツ)_/¯

@naztronaut
Copy link
Owner

Sorry just catching up to all of this.

I think your wiring is correct - It's a bit hard to tell since there's a lot of black wiring in front of the black cover of your pi. But I think I see where things are split.

And you tried both GPIO 18 and 12. You didn't cross the data and the ground pins, right? You probably wouldn't even see anything if you did.

strandtest.py was going to be my next suggestion to try but if that doesn't work either then something may be off with the lights themselves.

Since the Raspberry Pis both output fps and doesn't seem to error out (and strandtest doesn't work) I don't think this is a software issue.

I wonder if there's a break somewhere. One thing you could try is when the lights are running, jiggle your strip back and forth and see if you can get the connection working. It could be a minor break somewhere along the copper.

Besides that, I can't think of any other way to test without using another set of LEDs. You could get some cheap generic ones instead of neopixel lights just to test.

Last thing you can try is maybe go back to the basics and try strandtest with minimal hardware. Connect power, ground, and data directly from your Pi and try the test. The file is just basic loops and data writes so it uses very little power.

@k15866AL
Copy link
Author

Hey all good, appreciate all the help your giving. I'm inclined to think it's a LED strip issue, there's no way I can make changes to everything else without anything changing significantly.

I tried attaching power and ground on the other end - no difference
Cut off 1 LED on the Data In side and re soldered data cable - only difference is strandedtest lights up one less LED - perhaps there is an issue on the next LED, but the jiggle test did not help. This LED can still light up during scroll / spectrum / energy

Tbh I'm surprised I haven't had a combination that hasnt managed to light up.
I'll try the basic strandtest setup and if still nothing will give up on this neopixel strip.

@k15866AL
Copy link
Author

k15866AL commented Mar 6, 2021

Finally got it working. Solution is below

A rough summary of my issues is

  • strandtest.py does not follow the expected pattern
  • only a few LEDs light up (in my case 2-3 during rainbow phase)
  • reducing N.PIXEL has no effect
    During visualization.py lights
  • appear laggy - only updating every 1-3 secs at best in random colours
  • may improve when playing youtube video / other processes but still random lighting up without specific patterns
  • ruled out hardware / power issue

Solution here pypi.org/project/rpi-ws281x/
Going to the section ‘Limitations’ for PWM tried blacklisting snd_bcm2835, rebooted and ran audio reactive LEDs

Interestingly there are links in this suggesting that using DMA = 5 may conflict with ? OS also using this DMA since 2018, and that DMA = 10 is safer. But this was not an issue for me (just left it as = 5

Hopefully someone find this useful.

@naztronaut
Copy link
Owner

Awesome! Thanks for sharing the solution @k15866AL! Great job finding it and I'm glad you got this working.

Hope you're having fun with the project :)

@jakubgorsky
Copy link

My god you saved me man, few hours of digging and trying to find out what's wrong :) Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants