Page 1 of 1

Using the PWM pin

Posted: Mon Jan 06, 2014 8:31 pm
by JizzaDaMan
How do I use the PWM pin on my pi? I'm using RPi.GPIO

Is it just the same as the use of any other pin? In which case it would be really simple to write a function to do it given a mark:space ratio.

Also which pin number is it?

Thanks

Re: Using the PWM pin

Posted: Mon Jan 06, 2014 10:06 pm
by croston
Have a read of this page --> http://sourceforge.net/p/raspberry-gpio ... /wiki/PWM/

RPi.GPIO will do software PWM on any channel.

Re: Using the PWM pin

Posted: Tue Jan 07, 2014 9:54 am
by JizzaDaMan
That page implies I can do that on any pin (I am aware that I can softare PWM), but isn't there a specific pin designed for PWM?
Will using the module used on that page exploit the advantages of using that specific pin? (providing, of course, that I set it to the correct pin)
And which pin is it!?

Re: Using the PWM pin

Posted: Tue Jan 07, 2014 12:15 pm
by joan
Gpio 18 is the only accessible gpio which has a dedicated PWM function.

wiringPi (as far as I'm aware) is the only library which uses that function.

What are you trying to do?

Re: Using the PWM pin

Posted: Tue Jan 07, 2014 12:37 pm
by CopterRichie
joan wrote:Gpio 18 is the only accessible gpio which has a dedicated PWM function.

wiringPi (as far as I'm aware) is the only library which uses that function.

What are you trying to do?
Question please, is the GPIO 18 pin, 3.3 or 5 volts?

Re: Using the PWM pin

Posted: Tue Jan 07, 2014 12:38 pm
by croston
All GPIO pins on the Raspberry Pi are 3.3V. If you use 5V, you are at risk of damaging your Pi.

Re: Using the PWM pin

Posted: Tue Jan 07, 2014 12:42 pm
by joan
All gpios are 3.3V.

The Pi has a 5V rail (I think it is the unregulated input supply) which is brought out to several pins. The 3.3V rails, 5V rails, and ground rails are not controllable by software.

Re: Using the PWM pin

Posted: Tue Jan 07, 2014 12:47 pm
by CopterRichie
Thank you.

Re: Using the PWM pin

Posted: Tue Jan 07, 2014 4:12 pm
by JizzaDaMan
joan wrote:Gpio 18 is the only accessible gpio which has a dedicated PWM function.

wiringPi (as far as I'm aware) is the only library which uses that function.

What are you trying to do?

Thank you for your relevant answer :)

speed control of a pc case fan. From what I've been trying with LEDs, I'm happy to use software PWM to be honest, unless there's any reason I shouldn't?

Re: Using the PWM pin

Posted: Tue Jan 07, 2014 7:04 pm
by joan
Any Pi library you can find with PWM support will be good enough to drive a fan (any PWM jitter will be contained by the motor inertia).

Re: Using the PWM pin

Posted: Fri Jan 24, 2014 9:26 pm
by Tarcas
The hardware PWM (on pin 18, AKA GPIO 1) does the PWM in hardware, so the chip takes care of it silently in the background. The software PWM provided by WiringPi requires the processor to continually switch the state of the pin, so you need a program to be running the entire time in order to do this. As I have read, each pin doing software PWM requires about 0.5% of the CPU to accomplish this. This also means you can't do it from a shell script or the command line; it has to be Python or C, as far as I know.

If you don't mind the small amount of constant CPU usage and will have a program running continually to control your speed anyway, you can use either. If you do mind the extra CPU load or intend to "set it and forget it" by letting your program or script exit until you change the PWM duty cycle (in your case, fan speed) then use the hardware PWM.

Re: Using the PWM pin

Posted: Sat Jan 25, 2014 10:48 pm
by DominusPi
PWM = Pulse-width modulation right ?

http://www.youtube.com/watch?v=uUn0KWwwkq8

Best I can do for you ;)