|
Feetech STS Driver
|
: STS Servo Command API More...
Go to the source code of this file.
Macros | |
Hardware Constraints | |
Physical limits specific to the Feetech STS servo model (STS3215). | |
| #define | STS_MAX_POSITION 4095U |
| #define | STS_MAX_SPEED 3073U |
| #define | STS_MAX_ACCELERATION 150U |
| #define | STS_MAX_PWM 1000U |
| #define | STS_MAX_STEP 32767U |
| #define | STS_MAX_TORQUE 1000U |
| #define | EEPROM_UNLOCK 0U |
| #define | EEPROM_LOCK 1U |
Enumerations | |
| enum | sts_direction_t { STS_DIR_CCW = 0U , STS_DIR_CW = 1U } |
| Defines the rotational direction of the servo. More... | |
Functions | |
| sts_result_t | STS_SetTorqueEnable (sts_servo_t *servo, uint8_t enable) |
| Enables or disables motor torque output. | |
| sts_result_t | STS_SetOperatingMode (sts_servo_t *servo, sts_operating_mode_t mode) |
| Sets the operating mode of the servo. | |
| sts_result_t | STS_SetTargetPosition (sts_servo_t *servo, uint16_t position) |
| Sets the absolute target position for the servo. | |
| sts_result_t | STS_GetPresentPosition (sts_servo_t *servo, uint16_t *position_out) |
| Reads the current actual position from the servo. | |
| sts_result_t | STS_GetPresentSpeed (sts_servo_t *servo, int16_t *speed_out) |
| Reads the current rotational speed of the servo. | |
| sts_result_t | STS_SetTargetSpeed (sts_servo_t *servo, uint16_t speed, sts_direction_t dir) |
| Sets the target speed and direction of the servo. | |
| sts_result_t | STS_SetTargetAcceleration (sts_servo_t *servo, uint8_t acceleration) |
| Sets the acceleration profile for servo movements. | |
| sts_result_t | STS_SetTarget (sts_servo_t *servo, int32_t target) |
| Universal target wrapper that routes the command based on current mode. | |
| sts_result_t | STS_SetTargetStep (sts_servo_t *servo, uint16_t steps, sts_direction_t dir) |
| Commands the servo to move a relative number of steps. | |
| sts_result_t | STS_SetTargetPWM (sts_servo_t *servo, uint16_t pwm, sts_direction_t dir) |
| Sets the open-loop PWM duty cycle (effort) applied to motor coils. | |
| sts_result_t | STS_SetTorqueLimit (sts_servo_t *servo, uint16_t limit) |
| Sets the dynamic (RAM) maximum torque limit. | |
| sts_result_t | STS_GetPresentLoad (sts_servo_t *servo, int16_t *load_out) |
| Reads the current physical load/effort of the motor. | |
| sts_result_t | STS_GetPresentVoltage (sts_servo_t *servo, uint8_t *voltage_out) |
| Reads the current input voltage at the servo's power terminals. | |
| sts_result_t | STS_GetPresentTemperature (sts_servo_t *servo, uint8_t *temp_out) |
| Reads the internal temperature of the servo's MCU/Motor driver. | |
| sts_result_t | STS_GetMovingStatus (sts_servo_t *servo, uint8_t *status_out) |
| Reads the moving status flag to determine if the motor is currently in motion. | |
| sts_result_t | STS_SetEEPROMLock (sts_servo_t *servo, uint8_t lock) |
| Toggles the EEPROM write protection. | |
| sts_result_t | STS_SetID (sts_servo_t *servo, uint8_t new_id) |
| Assigns a new permanent ID to the servo. | |
: STS Servo Command API
Declares the high-level command API for Feetech STS servo control. Built on top of the service layer primitives, this header exposes motion control, torque management, and status query functions.
All commands require an initialised sts_servo_t handle. See sts_servo.h for bus and servo initialisation.
| #define EEPROM_LOCK 1U |
EEPROM write protection enabled
| #define EEPROM_UNLOCK 0U |
EEPROM write protection disabled
| #define STS_MAX_ACCELERATION 150U |
Maximum acceleration/deceleration ramp
| #define STS_MAX_POSITION 4095U |
Maximum valid encoder position (12-bit resolution)
| #define STS_MAX_PWM 1000U |
Maximum open-loop PWM value
| #define STS_MAX_SPEED 3073U |
Maximum velocity limit in steps per second
| #define STS_MAX_STEP 32767U |
Maximum relative steps
| #define STS_MAX_TORQUE 1000U |
Maximum dynamic torque limit
| enum sts_direction_t |
| sts_result_t STS_GetMovingStatus | ( | sts_servo_t * | servo, |
| uint8_t * | status_out | ||
| ) |
Reads the moving status flag to determine if the motor is currently in motion.
| servo | Pointer to an initialized servo handle. | |
| [out] | status_out | Pointer to store the moving flag (1: Moving, 0: Target reached). |
| sts_result_t STS_GetPresentLoad | ( | sts_servo_t * | servo, |
| int16_t * | load_out | ||
| ) |
Reads the current physical load/effort of the motor.
| servo | Pointer to an initialized servo handle. | |
| [out] | load_out | Pointer to store the signed load value. |
| sts_result_t STS_GetPresentPosition | ( | sts_servo_t * | servo, |
| uint16_t * | position_out | ||
| ) |
Reads the current actual position from the servo.
| servo | Pointer to an initialised servo handle. | |
| [out] | position_out | Pointer to store the 16-bit position. |
| sts_result_t STS_GetPresentSpeed | ( | sts_servo_t * | servo, |
| int16_t * | speed_out | ||
| ) |
Reads the current rotational speed of the servo.
| servo | Pointer to an initialised servo handle. | |
| [out] | speed_out | Pointer to store the 16-bit speed value. |
| sts_result_t STS_GetPresentTemperature | ( | sts_servo_t * | servo, |
| uint8_t * | temp_out | ||
| ) |
Reads the internal temperature of the servo's MCU/Motor driver.
| servo | Pointer to an initialized servo handle. | |
| [out] | temp_out | Pointer to store the temperature in degrees Celsius. |
| sts_result_t STS_GetPresentVoltage | ( | sts_servo_t * | servo, |
| uint8_t * | voltage_out | ||
| ) |
Reads the current input voltage at the servo's power terminals.
| servo | Pointer to an initialized servo handle. | |
| [out] | voltage_out | Pointer to store the voltage (in 0.1V units, e.g., 120 = 12.0V). |
| sts_result_t STS_SetEEPROMLock | ( | sts_servo_t * | servo, |
| uint8_t | lock | ||
| ) |
Toggles the EEPROM write protection.
| servo | Pointer to an initialized servo handle. |
| lock | EEPROM_LOCK to protect, EEPROM_UNLOCK to unprotect. |
| sts_result_t STS_SetID | ( | sts_servo_t * | servo, |
| uint8_t | new_id | ||
| ) |
Assigns a new permanent ID to the servo.
| servo | Pointer to an initialized servo handle. |
| new_id | The new ID (0 to STS_ID_BROADCAST_SYNC). |
| sts_result_t STS_SetOperatingMode | ( | sts_servo_t * | servo, |
| sts_operating_mode_t | mode | ||
| ) |
Sets the operating mode of the servo.
| servo | Pointer to an initialised servo handle. |
| mode | The desired operating mode (Position, Speed, PWM, Step). |
| sts_result_t STS_SetTarget | ( | sts_servo_t * | servo, |
| int32_t | target | ||
| ) |
Universal target wrapper that routes the command based on current mode.
| servo | Pointer to an initialized servo handle. |
| target | The desired target value. Bounds depend on active mode. |
| sts_result_t STS_SetTargetAcceleration | ( | sts_servo_t * | servo, |
| uint8_t | acceleration | ||
| ) |
Sets the acceleration profile for servo movements.
| servo | Pointer to an initialized servo handle. |
| acceleration | The acceleration rate (0 to STS_MAX_ACCELERATION). |
| sts_result_t STS_SetTargetPosition | ( | sts_servo_t * | servo, |
| uint16_t | position | ||
| ) |
Sets the absolute target position for the servo.
| servo | Pointer to an initialised servo handle. |
| position | 0 to STS_MAX_POSITION. |
| sts_result_t STS_SetTargetPWM | ( | sts_servo_t * | servo, |
| uint16_t | pwm, | ||
| sts_direction_t | dir | ||
| ) |
Sets the open-loop PWM duty cycle (effort) applied to motor coils.
| servo | Pointer to an initialized servo handle. |
| pwm | Raw PWM effort value (0 to STS_MAX_PWM). |
| dir | The direction to apply force (STS_DIR_CW or STS_DIR_CCW). |
| sts_result_t STS_SetTargetSpeed | ( | sts_servo_t * | servo, |
| uint16_t | speed, | ||
| sts_direction_t | dir | ||
| ) |
Sets the target speed and direction of the servo.
| servo | Pointer to an initialized servo handle. |
| speed | The target speed magnitude (0 to STS_MAX_SPEED). |
| dir | The desired rotation direction (STS_DIR_CCW or STS_DIR_CW). |
| sts_result_t STS_SetTargetStep | ( | sts_servo_t * | servo, |
| uint16_t | steps, | ||
| sts_direction_t | dir | ||
| ) |
Commands the servo to move a relative number of steps.
| servo | Pointer to an initialized servo handle. |
| steps | Number of relative steps to execute (0 to STS_MAX_STEP). |
| dir | The direction of rotation (STS_DIR_CW or STS_DIR_CCW). |
| sts_result_t STS_SetTorqueEnable | ( | sts_servo_t * | servo, |
| uint8_t | enable | ||
| ) |
Enables or disables motor torque output.
| servo | Pointer to an initialised servo handle. |
| enable | Non-zero to enable torque, zero to disable (free spin). |
| sts_result_t STS_SetTorqueLimit | ( | sts_servo_t * | servo, |
| uint16_t | limit | ||
| ) |
Sets the dynamic (RAM) maximum torque limit.
| servo | Pointer to an initialized servo handle. |
| limit | Max torque value (0 to STS_MAX_TORQUE). 0 disables torque. |