Skip to main content
replaced http://abyz.co.uk/ with http://abyz.me.uk/
Source Link

To answer the question "Long story short: Can anyone tell me how I can achieve a duty cycle with a pulse width of 0,8ms to 2,1ms for controlling a servo using the hardware PWM on the Raspberry Pi.".

Recent Pis (the ones with the 40 pin expansion header) have two hardware PWM channels available.

Channel 0 is available on GPIO 12 and 18. Channel 1 is available on GPIO 13 and 19.

So you can have hardware PWM on GPIO 12/13/18/19. However 12 and 18 will have the same settings as will 13 and 19.

pigpiopigpio has C, Python, and command line methods to choose the settings.

From the command line

pigs hp GPIO 50 dutycycle

will start PWM at 50 Hz on GPIO (12, 13, 18, or 19) with dutycycle. dutycycle is 0 for 0% (off) or 1000000 for 100% (fully on).

0,8 ms is 0,8 / 20 % or a dutycycle of 40000. 2,1 ms is 2,1 / 20 % or a dutycycle 0f 105000

So for GPIO 18 with 0,8 ms pulses use

pigs hp 18 50 40000

By the way pigpio and servoblaster will let you generate servo PWM on any of the GPIO.

The pigpio method to generate a servo pulse of 0,8 ms on GPIO 23 is

pigs servo 23 800 # 800 denotes the desired pulse width in microseconds

To answer the question "Long story short: Can anyone tell me how I can achieve a duty cycle with a pulse width of 0,8ms to 2,1ms for controlling a servo using the hardware PWM on the Raspberry Pi.".

Recent Pis (the ones with the 40 pin expansion header) have two hardware PWM channels available.

Channel 0 is available on GPIO 12 and 18. Channel 1 is available on GPIO 13 and 19.

So you can have hardware PWM on GPIO 12/13/18/19. However 12 and 18 will have the same settings as will 13 and 19.

pigpio has C, Python, and command line methods to choose the settings.

From the command line

pigs hp GPIO 50 dutycycle

will start PWM at 50 Hz on GPIO (12, 13, 18, or 19) with dutycycle. dutycycle is 0 for 0% (off) or 1000000 for 100% (fully on).

0,8 ms is 0,8 / 20 % or a dutycycle of 40000. 2,1 ms is 2,1 / 20 % or a dutycycle 0f 105000

So for GPIO 18 with 0,8 ms pulses use

pigs hp 18 50 40000

By the way pigpio and servoblaster will let you generate servo PWM on any of the GPIO.

The pigpio method to generate a servo pulse of 0,8 ms on GPIO 23 is

pigs servo 23 800 # 800 denotes the desired pulse width in microseconds

To answer the question "Long story short: Can anyone tell me how I can achieve a duty cycle with a pulse width of 0,8ms to 2,1ms for controlling a servo using the hardware PWM on the Raspberry Pi.".

Recent Pis (the ones with the 40 pin expansion header) have two hardware PWM channels available.

Channel 0 is available on GPIO 12 and 18. Channel 1 is available on GPIO 13 and 19.

So you can have hardware PWM on GPIO 12/13/18/19. However 12 and 18 will have the same settings as will 13 and 19.

pigpio has C, Python, and command line methods to choose the settings.

From the command line

pigs hp GPIO 50 dutycycle

will start PWM at 50 Hz on GPIO (12, 13, 18, or 19) with dutycycle. dutycycle is 0 for 0% (off) or 1000000 for 100% (fully on).

0,8 ms is 0,8 / 20 % or a dutycycle of 40000. 2,1 ms is 2,1 / 20 % or a dutycycle 0f 105000

So for GPIO 18 with 0,8 ms pulses use

pigs hp 18 50 40000

By the way pigpio and servoblaster will let you generate servo PWM on any of the GPIO.

The pigpio method to generate a servo pulse of 0,8 ms on GPIO 23 is

pigs servo 23 800 # 800 denotes the desired pulse width in microseconds

Source Link
joan
  • 71.6k
  • 5
  • 74
  • 107

To answer the question "Long story short: Can anyone tell me how I can achieve a duty cycle with a pulse width of 0,8ms to 2,1ms for controlling a servo using the hardware PWM on the Raspberry Pi.".

Recent Pis (the ones with the 40 pin expansion header) have two hardware PWM channels available.

Channel 0 is available on GPIO 12 and 18. Channel 1 is available on GPIO 13 and 19.

So you can have hardware PWM on GPIO 12/13/18/19. However 12 and 18 will have the same settings as will 13 and 19.

pigpio has C, Python, and command line methods to choose the settings.

From the command line

pigs hp GPIO 50 dutycycle

will start PWM at 50 Hz on GPIO (12, 13, 18, or 19) with dutycycle. dutycycle is 0 for 0% (off) or 1000000 for 100% (fully on).

0,8 ms is 0,8 / 20 % or a dutycycle of 40000. 2,1 ms is 2,1 / 20 % or a dutycycle 0f 105000

So for GPIO 18 with 0,8 ms pulses use

pigs hp 18 50 40000

By the way pigpio and servoblaster will let you generate servo PWM on any of the GPIO.

The pigpio method to generate a servo pulse of 0,8 ms on GPIO 23 is

pigs servo 23 800 # 800 denotes the desired pulse width in microseconds