rpi-ws281x / rpi-ws281x-python

Python library wrapping for the rpi-ws281x library
BSD 2-Clause "Simplified" License
326 stars 103 forks source link

Can't use rpi_ws281x together with second PWM channel #19

Closed olivierswinkels closed 1 year ago

olivierswinkels commented 5 years ago

I'm using rpi_ws281x (via python) in PWM mode on PWM0 (GPIO 12) and this works fine standalone. However when I try to initialize another PWM channel on PWM1 (GPIO 13) (Using either wiringpi or pigpio) the rpi_ws281x signal stops. (I'm using rpi_ws281x 4.2.2 on a Raspberry Pi 3B+ running Raspbian.)

Is this a known issue, or is there another way to use the rpi_ws281x library together with a 'raw' hardware PWM signal on the other channel?

dallen98 commented 4 years ago

Did you get a solution to this as I want the same thing kind of, I want to change all availabe GPIO pins to pwm using pigpio and then my question becomes does the rpi_ws281x work on pigpio virtual pins ?

I have repeated the question here sort of... https://github.com/jgarff/rpi_ws281x/issues/419

Gadgetoid commented 4 years ago

If a pin does not have PWM hardware physically connected to it, then it will not be able to output a hardware PWM signal. rpi_ws281x requires hardware PWM.

pigpio - IIRC - just uses software tricks on non-hardware PWM pins, if not all pins.

If you want to send the same PWM signal to multiple strips of LEDs... then just wire them to the same pin.

Edit: Note the above statement is unrelated to the use of PWM0 alongside PWM1 for different purposes. I do not know exactly why it's not possible to use these simultaneously with different libraries, but I'd very strongly suspect that either rpi_ws281x or whatever othere library is attempting to output PWM is setting up pins or features it shouldn't be. Or that certain shared hardware peripherals or techniques make using both together impossible.

dallen98 commented 4 years ago

"If you want to send the same PWM signal to multiple strips of LEDs... then just wire them to the same pin." this is a large led matrix i,m trying to build hence my need for a large number of output pins outputting different signals at the same time so from your reply it suggests that what i,m trying to do is impossible NB i,m confined to pin 18 and 19 only ? for unique signal outputs, thanks

Gadgetoid commented 4 years ago

Indeed, it's impossible short of some programming wizard coming along and figuring out this - https://github.com/jgarff/rpi_ws281x/issues/417#

At best you can get four simultaneous outputs - if I remember correctly - using PCM and PWM.

mfaccin commented 3 years ago

Hi @Gadgetoid. I have an application running in parallel using the pwm1 and accessing the registers directly.

Configuring the rpi_ws281x to use only the pwm0 / GPIO18 pin mess up with the other service. Is this limitation you described here?

Edit: Note the above statement is unrelated to the use of PWM0 alongside PWM1 for different purposes. I do not know exactly why it's not possible to use these simultaneously with different libraries, but I'd very strongly suspect that either rpi_ws281x or whatever othere library is attempting to output PWM is setting up pins or features it shouldn't be. Or that certain shared hardware peripherals or techniques make using both together impossible.

d8ahazard commented 3 years ago

Indeed, it's impossible short of some programming wizard coming along and figuring out this - jgarff/rpi_ws281x#417

At best you can get four simultaneous outputs - if I remember correctly - using PCM and PWM.

Hi, could you please elaborate on how it would be possible to get four simultaneous outputs using a Raspi 4B?

I would assume that's using GPIO 18/19 for PWM, and 21 for PCM...but what is the other GPIO? 31 is not available on the 4b.

dallen98 commented 3 years ago

there are only 2 unique outputs on rpi 18/19 the other 2 pwm pins repeat the data coming out of 18 and 19

NeusAap commented 2 years ago

Hi @Gadgetoid. I have an application running in parallel using the pwm1 and accessing the registers directly. Configuring the rpi_ws281x to use only the pwm0 / GPIO18 pin mess up with the other service. Is this limitation you described here?

I have tried the same. I use rpi_ws281x to drive PWM channel 0, and use channel 1 with 'rpi-hardware-pwm 0.1.4' library. To no effect. Every time I open my application with rpi-ws281x, it STILL keeps messing with channel 1.

I have tried recompiling rpi_ws281x, with removing all references to channel 1 (especially in pwm.h, pwm.c and ws2811.c), but no effect. Even though it never makes a call to channel 1, this library still seems to overwrite my excisting PWM signal on channel 1...

Really a bummer. This means i'll have to redesign my whole application if I can't find a solution to this problem.

sporubcan commented 2 years ago

Hello, I have the same problem. I have FAN PWM control connected to GPIO13 and NeoPixel to GPIO12. Both are working standalone well. But when I start FAN PWM on GPIO13 (channel 1), it interferes NeoPixel on GPIO12 (channel 0). Did you find the solution please? Thank you in advance!

Gadgetoid commented 1 year ago

Issues with the underlying rpi_ws281x (https://github.com/jgarff/rpi_ws281x/) are outside the scope of this wrapper library and cannot be fixed here.