drekthrall
Posts: 44
Joined: Sat Oct 17, 2015 12:43 pm

raspberry pi 2 B PWM

Mon Nov 16, 2015 3:31 pm

Hello , I am working on project where i need atleast two hardware pwm. Now I have Raspberry pi B ( which should have only one hardware pwm pin). I am preparing to buy Raspberry pi 2 B because i saw there ( http://abyz.co.uk/rpi/pigpio/python.html#hardware_PWM ) that Raspberry pi 2 B should have two hardware pwm.

I just want to be sure before i buy it. Is true that Raspberry Pi 2 B have atleast two hardware pwm pins ?

Thanks..

BMS Doug
Posts: 3824
Joined: Thu Mar 27, 2014 2:42 pm
Location: London, UK

Re: raspberry pi 2 B PWM

Mon Nov 16, 2015 3:34 pm

drekthrall wrote:Hello , I am working on project where i need atleast two hardware pwm. Now I have Raspberry pi B ( which should have only one hardware pwm pin). I am preparing to buy Raspberry pi 2 B because i saw there ( http://abyz.co.uk/rpi/pigpio/python.html#hardware_PWM ) that Raspberry pi 2 B should have two hardware pwm.

I just want to be sure before i buy it. Is true that Raspberry Pi 2 B have atleast two hardware pwm pins ?

Thanks..
You can have plenty of hardware timed PWM on any Pi if you use Joan's PIGPIO library.
Doug.
Building Management Systems Engineer.

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

Re: raspberry pi 2 B PWM

Mon Nov 16, 2015 3:46 pm

There are two hardware PWM channels as follows:

Code: Select all

12  PWM channel 0  A+/B+/Pi2 and compute module only
13  PWM channel 1  A+/B+/Pi2 and compute module only
18  PWM channel 0  All models
19  PWM channel 1  A+/B+/Pi2 and compute module only

40  PWM channel 0  Compute module only
41  PWM channel 1  Compute module only
45  PWM channel 1  Compute module only
52  PWM channel 0  Compute module only
53  PWM channel 1  Compute module only
As BMS Doug points out you can also have hardware timed PWM on all the other GPIO, but the two hardware channels offer more flexibility and accuracy.

drekthrall
Posts: 44
Joined: Sat Oct 17, 2015 12:43 pm

Re: raspberry pi 2 B PWM

Mon Nov 16, 2015 4:40 pm

Thanks ;)

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

Re: raspberry pi 2 B PWM

Mon Nov 16, 2015 4:48 pm

drekthrall wrote:Thanks ;)
To clarify. There are two hardware channels, each hardware channel can have its own frequency and dutycycle. Each channel can be routed to none or several GPIO. But each GPIO which share a channel will have the same settings.

E.g. if you set channel 0 to 123456 Hz with a 23.45% dutycycle and set GPIO 12 and 18 to PWM mode then each will have 123456Hz with a 23.45% dutycycle.

Return to “General discussion”