I spent quite some time, but I wasn't able to find the answer (and found other interesting sources like changing pwm frequency 1 and changing the frequency 2), and I lack the equipment to find out by myself.

I'm on a Raspberry Model B, using NodeJS along with wiring-pi. To initialize and setup PWM on Pin12 = WiringPiPin1 = GPIO1 = BCM18 = the hardware-PWM-enabled-PIN I'm using the following code:

var wpi = require('wiring-pi'); 

var wiringPiMotorPin = 1;
wpi.pinMode(wiringPiMotorPin, wpi.modes.PWM_OUTPUT);
var motorState = 0;

// target state ranges from 0-1024
var setMotor = function(targetState) {
    if (motorState != targetState) {
        wpi.pwmWrite(wiringPiMotorPin, targetState);
        motorState = targetState;

So I didn't change anything to the PWM-divider using e.g. pwmSetClock. What is 'default' settings for duty cycle/frequency of the hardware-PWM? I need to know, because I need to setup a RC-lowpass-filter (PWM-frequency is audible from the connected motor).

Thank you very much in advance.


Based on RyanO suggestion, I setup pi-gpio with the commands

cd /opt/
sudo mkdir piscope
cd piscope
sudo wget abyz.me.uk/rpi/pigpio/pigpio.zip
sudo unzip pigpio.zip
sudo make
sudo make install

and then setup piscope with the commands

cd /opt/piscope
sudo wget abyz.me.uk/rpi/pigpio/piscope.tar
sudo tar xvf piscope.tar
sudo make hf
sudo make install

and then started pi-gpio-deamon and piscope with

sudo pigpiod

After some zooming and with a PWM value of 256 (with 1024 being the max-value) I ended up with the following image:


which indicates a duty cycle of 20us. The frequency should be (in case the duty cycle doesn't depend on the value) therefore 50000Hz = 50kHz

  • 1
    You can use the left/right arrow keys to move to the previous/next edge. If you press the g key a gold marker will be highlighted on the edge. Now the difference between the gold marker and blue marker will be displayed as you move edge to edge. – joan Dec 15 '14 at 18:17
  • That's what I did! I just screwed up taking the screenshot. It gave me the 20us I used for the calculation ! – Boern Dec 15 '14 at 21:37

Apologies if this isnt the correct format for presenting this information, I'm new to StackExchange.

While I dont have the short answer you're looking for (default duty cycle and frequency), I've been working on some software PWM and, likewise, dont have the equipment to validate the output of the GPIO's.

I came across this software which acts as a logic analyser, run on the pi, and should allow you to work out the answer for yourself:


I've not got round to trying it out for myself, but I hope it helps.

  • Hello and welcome! If the link you provided contains detailed information specific to the question please feel free to include those details in your answer (just in case the link dies later on). Don't copy that source to the letter though ;) – Ghanima Dec 15 '14 at 15:08

I doubt there is an easy answer. You may need to look at the wiringPi source code and the wrapper you are using.

If the gpio is in balanced rather than mark/space mode (pwmSetMode) there will be no fixed PWM update frequency. It will vary with dutycycle, clock divider, and range.

If the gpio is in mark/space the update frequency will be the source clock frequency (probably 19200000) divided by the clock divider (pwmSetClock) divided by the range (pwmSetRange).

You'll need to check the defaults in the various wrappers you are using.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.