GianniDPC
Posts: 13
Joined: Tue Oct 11, 2016 2:56 pm

wiringpi PWM python

Fri Apr 21, 2017 7:56 pm

Hello,

I want to generate a 50Hz signal with a 50% duty cycle with hardware PWM (I'm using pin 18). As I read that is the only pin that supports hardware pwm?

I want to use python as the programming language, and I imported the wiringpi library (not the one that comes with Raspbian btw). But how do I calculate the frequency and the duty cycle? Could someone explain or give me an example? I saw this link https://raspberrypi.stackexchange.com/q ... -frequency but I don't understand it that well.

Thanks in advance

FYI: I'm using a Raspberry Pi Zero

User avatar
joan
Posts: 14936
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: wiringpi PWM python

Fri Apr 21, 2017 8:19 pm

No pin 12 (GPIO18) is not the only pin supporting hardware PWM. There are two hardware PWM channels. Channel 0 may be used on GPIO 12 and 18. Channel 1 may be used on GPIO 13 and 19.

GianniDPC
Posts: 13
Joined: Tue Oct 11, 2016 2:56 pm

Re: wiringpi PWM python

Fri Apr 21, 2017 10:55 pm

joan wrote:No pin 12 (GPIO18) is not the only pin supporting hardware PWM. There are two hardware PWM channels. Channel 0 may be used on GPIO 12 and 18. Channel 1 may be used on GPIO 13 and 19.
Can you show me an example for a 50Hz frequency and a 50% duty cycle. Or at least how I can calculate everything and set the parameters to do so.

User avatar
joan
Posts: 14936
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: wiringpi PWM python

Sat Apr 22, 2017 7:26 am

GianniDPC wrote:
joan wrote:No pin 12 (GPIO18) is not the only pin supporting hardware PWM. There are two hardware PWM channels. Channel 0 may be used on GPIO 12 and 18. Channel 1 may be used on GPIO 13 and 19.
Can you show me an example for a 50Hz frequency and a 50% duty cycle. Or at least how I can calculate everything and set the parameters to do so.
I don't use the module so all I could do is interpret the same documentation.

Return to “Python”