Doug Howard
Posts: 9
Joined: Mon Feb 27, 2017 12:18 pm

RPi3 BCM2837 PWM GPIO Output Pins

Wed Jul 19, 2017 12:07 am

On a RPi3, What GPIO pins can be used as PWM outputs? I would like to flash more than one LED.
I'm having trouble in my Python code changing the PWM output pin.
Why is this so hard to find?
Thanks in advance,
Doug.

drgeoff
Posts: 9915
Joined: Wed Jan 25, 2012 6:39 pm

Re: RPi3 BCM2837 PWM GPIO Output Pins

Wed Jul 19, 2017 12:19 am

Eh? Why do you want to use a PWM GPIO to flash a LED?

Doug Howard
Posts: 9
Joined: Mon Feb 27, 2017 12:18 pm

Re: RPi3 BCM2837 PWM GPIO Output Pins

Wed Jul 19, 2017 3:04 am

It appears to me that on a Raspberry Pi 3 only one output at a time will work as a PWM output. I believe any of the outputs on the CanaKit "T" board will work as a PWM channel. I have verified outputs 4, 5, 6, 12, 13, 16, 17, 18, 19, 20. I assume outputs 21, 22, 23, 24, 25, 26 and 27 would work also.
Also, when a new p = GPIO.PWM(6, 0.5) command is executed, at 0.5 Hz., the previous PWM channel will go to a logic 0 or low. The new PWM channel, in this case output 6 will not turn on until a new p.start(50) command is executed in this case at 50% duty cycle. I think this might be my problem in my function calls. I also need to look at some of the YouTube PWM videos with robotics in addition to the PWM videos with a singular LED that I watched. I would think one would need more than one PWM channel for robotics?
I hope that this gets a dialog started on RPi3 PWM.
Cheers,
Doug.
Last edited by Doug Howard on Wed Jul 19, 2017 3:44 am, edited 1 time in total.

Doug Howard
Posts: 9
Joined: Mon Feb 27, 2017 12:18 pm

Re: RPi3 BCM2837 PWM GPIO Output Pins

Wed Jul 19, 2017 3:36 am

drgeoff wrote:Eh? Why do you want to use a PWM GPIO to flash a LED?
I assume you mean instead of using software? I'm simulating new CSX railroad signals that were just installed near us for positive train control. They look like three traffic signals stacked on top of each other for nine lamps plus a clear, lunar LED. There are sixteen aspects, rules or combinations. I created definitions for the sixteen Rules and Aspects which are in list that are displayed on a 20 x 4 LCD display.
In the same for loop I call one of the sixteen LED combinations.
I'm a hardware type and not a programmer so using the PWM function seemed simpler to me?
I have a lot of it working with 457 line of Python 2.7 code and comments.

Doug Howard
Posts: 9
Joined: Mon Feb 27, 2017 12:18 pm

Re: RPi3 BCM2837 PWM GPIO Output Pins

Wed Jul 19, 2017 3:41 am

Doug Howard wrote:It appears to me that on a Raspberry Pi 3 only one output at a time will work as a PWM output. I believe any of the outputs on the CanaKit "T" board will work as a PWM channel. I have verified outputs 4, 5, 6, 12, 13, 16, 17, 18, 19, 20. I assume outputs 21, 22, 23, 24, 25, 26 and 27 would work also.
Also, when a new p = GPIO.PWM(6, 0.5) command is executed, the previous PWM channel will go to a logic 0 or low. The new PWM channel, in this case output 6 will not turn on until a new p.start(50) command is executed in this case at 50 Hz. I think this might be my problem in my function calls. I also need to look at some of the YouTube PWM videos with robotics in addition to the PWM videos with a singular LED that I watched. I would think one would need more than one PWM channel for robotics?
I hope that this gets a dialog started on RPi3 PWM.
Cheers,
Doug.
Make that 50% duty cycle, not frequency at 0.5 Hz.
Sorry for the error.

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

Re: RPi3 BCM2837 PWM GPIO Output Pins

Wed Jul 19, 2017 7:50 am

There are four GPIO which can be used for hardware PWM, but only two channels so GPIO 12/18 share a setting as do GPIO 13/19.

See http://abyz.co.uk/rpi/pigpio/python.html#hardware_PWM

Hardware timed PWM can be used on any GPIO, albeit not with same range of settings available on the hardware driven GPIO.

See http://abyz.co.uk/rpi/pigpio/python.htm ... _dutycycle and http://abyz.co.uk/rpi/pigpio/python.htm ... _frequency

Return to “Beginners”