PWM Servomotor Preset Snippet (pwm-servo)
west build -S pwm-servo [...]
Overview
This snippet is quite board specific and prepares a dedicated PWM channel exclusively for the standard Servomotor sample from Zephyr.
Board specific setups
Only selected boards are supported by this snippet. There is no basic configuration.
Supported boards are:
Cytron Maker Pi RP2040
Cytron Maker Pi RP2040
Connect a servomotor MG996R to the first on-board PWM channel for servomotors, the 4×3 pin header block at position 19. See the board positions diagram for details.
The corresponding PWM pulse widths for a range of -90° to +90° (180°) are 500 ㎲ to 2,500 ㎲ with a period of 50 ㎐. All these servomotor specific parameters are preset by the snippet PWM Servomotor Preset Snippet (pwm-servo) that have to use to get access to this dedicated PWM channel together with the original Zephyr Servomotor sample. Invoke west build and west flash with this snipped and optional mixed with others, for example:
west build -b cytron_maker_pi_rp2040 -p -S usb-console -S pwm-servo -d build/cytron_maker_rp2040 zephyr/samples/basic/servo_motor
west flash -r uf2 -d build/cytron_maker_rp2040
1servo: &pwm_servo0 {
2 compatible = "pwm-servo";
3 min-pulse = <PWM_USEC(500)>;
4 max-pulse = <PWM_USEC(2500)>;
5};
How to add support of a new board
add board devicetree overlay to this snippet;
which add following options to the dedicated PWM node:
compatible = "pwm-servo";
min-pulse = <PWM_USEC(500)>;
max-pulse = <PWM_USEC(2500)>;