pigpio: PWM range for quadcopter ESC(electronic speed controller) command

Good day, I am currently working on a quadcopter project and am currently using the pigpio library for the PWM used to command the ESC's of the quadcopter motors.

Will increasing the range of the values used let say (0-40000) from (0-255), will there be a noticable improvement with the fineness or precision of the response of the motors?

I am currently using the default range of 0-255 and a frequency of 400Hz.

int gpioSetPWMrange(unsigned user_gpio, unsigned range); from: http://abyz.me.uk/rpi/pigpio/cif.html#gpioSetPWMrange

No, changing the range will make no difference to the underlying number of steps between off and fully on.

The following table shows the permitted PWM frequencies at each sample rate.

``````                      Hertz

1: 40000 20000 10000 8000 5000 4000 2500 2000 1600
1250  1000   800  500  400  250  200  100   50

2: 20000 10000  5000 4000 2500 2000 1250 1000  800
625   500   400  250  200  125  100   50   25

4: 10000  5000  2500 2000 1250 1000  625  500  400
313   250   200  125  100   63   50   25   13
sample
rate
(us)  5:  8000  4000  2000 1600 1000  800  500  400  320
250   200   160  100   80   50   40   20   10

8:  5000  2500  1250 1000  625  500  313  250  200
156   125   100   63   50   31   25   13    6

10:  4000  2000  1000  800  500  400  250  200  160
125   100    80   50   40   25   20   10    5
``````

So for a sample rate of 5 µs the permitted frequencies are 8000, 4000, 2000, 1600, 1000, 800, 500, 400, 320, 250, 200, 160, 100, 80, 50, 40, 20, and 10 Hz.

The number of steps between off and fully on depends on both the sampling rate and the frequency and is given by the following formula

steps = 1000000 / (sample rate * frequency)

For example a sample rate of 5 µs and frequency 1600 Hz has

1000000 / (5 * 1600) = 125 steps

For a sample rate of 5 µs and frequency of 400 Hz

1000000 / (5 * 400) = 500 steps

You can use any range which is convenient for your application, perhaps 0-100 if percents make sense, 0-360 if it is an angle.

However, whatever range (0-X) you use, behind the scenes it will automatically be scaled to (0-steps).

• Thank you so much, I was very close to wasting my time recalculating pid constants because of this due to the rescaling :) Mar 20, 2016 at 11:07