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

Two LED strip on RPI 4 #40

Open
MdotWym opened this issue Feb 3, 2020 · 6 comments
Open

Two LED strip on RPI 4 #40

MdotWym opened this issue Feb 3, 2020 · 6 comments

Comments

@MdotWym
Copy link

MdotWym commented Feb 3, 2020

Hi

Thank you for your WS2812 server.

I tried your it with two LED strips. It worked from the beginning very nice with only one strip.
Then I connected a second, which is not working.
For the first, the setup is:
setup 1,256,3,0,255,18; init;

Using the second, the setup is:
setup 1,256,3,0,255,18; setup 2,60,3,0,255,13; init;

The first one uses PWM0, the second PWM1 (I guess). So in theory two strips can be connected.
Before going into details I'd like to know if I'm doing something fundamentally wrong.

Do you prefer another channel to ask such basic questions?

BR
Wym

@MdotWym
Copy link
Author

MdotWym commented Feb 3, 2020

Update:
I'm really sorry for my request.
It works fine if using the right GPIO on the board!
After checking all possible root causes, finaly found the bug.
--> Issue closed.

BR
Wym

@MdotWym
Copy link
Author

MdotWym commented Feb 4, 2020

Hi
Basically the problem (wiring) is solved. After some tests and reading the documentation the following problem has arisen:
As it seems it is not possible to operate both LED bands at the same time.

If a command is sent via TCP for the first strip, and shortly afterwards a command for the second, both processes are aborted.
After the first command is completed, the TCP connection is closed. As soon as the second TCP command opens again, the first process is stopped. Interestingly, the second process starts but is also stopped (I think when closing TCP connection). This is partly in accordance with the note in the documentation under the topic "thread".

Is it possible to run two strips independently of each other?
Could theoretically the server be started twice? One for Stripe 1 and the other for Stripe 2?

BR
Wym

@tom-2015
Copy link
Owner

tom-2015 commented Feb 4, 2020

Sorry, not possible to do this unless you can combine commands for strip 1 and 2 in the same loop/thread.

Try running 2 servers on different ports.

@MdotWym
Copy link
Author

MdotWym commented Feb 5, 2020

Ok, tried running with two servers. In summary, the following can be said.

The first instance of the server is set up and initialized on channel 1 with PWM0 with the pin used for LED strip 1. TCP port 9999.

The second instance of the server is set and initialized on channel 1 with PWM0 and a UNUSED pin and on channel 2 with PWM1 and the pin used for LED strip 2. TCP port 9998.

Channel 1 cannot be used together with PWM1 since an error during setup is thrown by the server. So I had to setup an "unused" channel 1 with an unused pin on this second server.

If messages are now sent one after the other, Strip 1 and Strip 2 will work properly. However, if the processes run parallel, the LEDs of both strips light up, but they influence each other. So it does not work just like that.

Could this be because both servers or the rpi_ws281x library use the same DMA channel? Maybe you have to assign different DMA channels to each server?

Thank you for your support.

@MdotWym
Copy link
Author

MdotWym commented Feb 5, 2020

Update:
If both servers are setup with two different DMA channels, nothing works anymore.
Both channels are dead. For the first server DMA 5 is used, for the second server DMA 4.
I tried DMA 8 as well, but it doesn't work either.

At https://github.com/jgarff/rpi_ws281x it can be found, that DMA 5 should not be used.
From your main.c source code I see you use DMA 5.
What is confusing me, is that calling
init;
works fine, but
init 5;
does not work at all.

@tom-2015
Copy link
Owner

tom-2015 commented Feb 8, 2020

You forgot the first argument of the init command is the operating frequency.
try:
init 800000,10;

but I've changed the default DMA number to 10 anyway in the source code.

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

2 participants