Pioreactor / rpi_hardware_pwm

Access the hardware PWM of a Raspberry Pi
Other
56 stars 13 forks source link

No PWM output on GPIO12 (PWM0) #16

Open yahaggach opened 2 months ago

yahaggach commented 2 months ago

HI,

Thanks for the effort in putting the library up.

I have issues getting the PWM to output. I followed all the steps and i can see that the pwm module is correctly initialized with grep on terminal. But I do not get any output on the pin... This is my overlay : dtoverlay=pwm-2chan,pin=12,func=4,pin2=13,func2=4

I actively use GPIO 18, GPIO 13 and GPIO 19 could it be that PWM when instanciated necessarily is routed to all pins defined in overlay and some conflict is happening that I am not aware of ?

Thanks for any tip

JonasGUHasselt commented 2 months ago

Hello yahaggach

I don't know if you made the same mistake as I did, but your problem seems similar to mine. So I will give you the solution to my problem, hoping that it will help you with yours.

I received no PWM output on either of my pins too. So I started looking around for a solution. I found out that if you declare your PWM pin as output or input, your GPIO pin gets connected to a different circuitry, than when you don't declare it as output or input at all. In the latter case it will get connected to the PWM circuitry. (I found this as a response on the solution for this question from the user joan: https://raspberrypi.stackexchange.com/questions/143651/how-to-set-hardware-pwm-pins).

So after removing the line: GPIO.setup(pin, GPIO.OUT) with pin being the pin you want the PWM signal to be on, the PWM started working. Hope this helps!

P.S If the author of the library would read this answer, could you please add this information to the README.md so future users will not make the same mistake as I did. Thank you in advance!

Kind regards

JonasGUHasselt