librpipServoConfigWrite

uint32_t librpipServoConfigWrite(uint32_t id, uint32_t range, uint32_t pmin, uint32_t pmax);

Description

Configures a servo on a PWM. The servo database is a good place to get the attributes needed,

Parameters

  • uint32_t id
    The PWM device to use. The PWM device needs to have been detected during the librpipInit().
  • uint32_t range
    The total range of the servo. Each servo has a angular range it can move. The value expected is the total, e.g. if a servo can move from -60° to 60° then the range is 120°.
  • uint32_t pmin
    The minimum pulse length in µs, e.g. if the servo can move from -60° to 60° then pmin is the pulse needed for the servo to move to -60°.
  • uint32_t pmax
    The maximum pulse length in µs, e.g. if the servo can move from -60° to 60° then pmax is the pulse needed for the servo to move to 60°.

Returns

0 on failure, 1 on success.

Example

Configure PWM0 for a HiTec HS-475HB servo:

uint32_t feature_set;
feature_set = librpipInit(LIBRPIP_BOARD_DETECT, LIBRPIP_FLAG_DEBUG_ON, 0);
if(feature_set & LIBRPIP_FEATURE_PWM0) { 
        librpipServoConfigWrite(0, 200, 900, 2100);
}
librpipClose();