File syn_actuator.h¶
FileList > motor > syn_actuator.h
Go to the source code of this file
Linear actuator with potentiometer feedback. More...
#include "../common/syn_defs.h"#include "../motor/syn_dc_motor.h"#include "../motor/syn_motor_ctrl.h"#include <stdbool.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_Actuator Linear actuator instance — motor controller + stroke mapping. |
| struct | SYN_Actuator_Config Actuator configuration. |
Public Functions¶
| Type | Name |
|---|---|
| void | syn_actuator_clear_stall (SYN_Actuator * act) Clear stall condition and re-enable. |
| void | syn_actuator_init (SYN_Actuator * act, const SYN_Actuator_Config * cfg) Initialize linear actuator. |
| void | syn_actuator_set_position (SYN_Actuator * act, int16_t pct_x10) Set desired position. |
| void | syn_actuator_stop (SYN_Actuator * act) Stop the actuator immediately. |
| int16_t | syn_actuator_update (SYN_Actuator * act) Update — read pot, run PID, drive motor. |
Public Static Functions¶
| Type | Name |
|---|---|
| bool | syn_actuator_at_target (const SYN_Actuator * act) Check if actuator has reached its target. |
| bool | syn_actuator_is_stalled (const SYN_Actuator * act) Check if stalled. |
| int16_t | syn_actuator_position (const SYN_Actuator * act) Get current position (0-1000, i.e. 0.0-100.0%). |
Detailed Description¶
Wraps motor_ctrl + sensor into a turnkey position-controlled linear actuator. The potentiometer reading is mapped to a percentage position (0.0% – 100.0%, stored as 0–1000).
Usage:
static SYN_Actuator act;
static SYN_DCMotor motor;
static SYN_ADC pot_adc;
SYN_Actuator_Config cfg = {
.dc_motor = &motor,
.read_pos = my_pot_read, // returns ADC value
.read_ctx = &pot_adc,
.stroke_min = 100, // ADC at fully retracted
.stroke_max = 3900, // ADC at fully extended
.update_hz = 50,
};
syn_actuator_init(&act, &cfg);
syn_actuator_set_position(&act, 500); // move to 50.0%
// In your loop:
syn_actuator_update(&act);
Public Functions Documentation¶
function syn_actuator_clear_stall¶
Clear stall condition and re-enable.
Parameters:
actActuator.
function syn_actuator_init¶
Initialize linear actuator.
Parameters:
actActuator instance.cfgConfiguration.
function syn_actuator_set_position¶
Set desired position.
Parameters:
actActuator instance.pct_x10Position in 0.1% units (0 = retracted, 1000 = extended).
function syn_actuator_stop¶
Stop the actuator immediately.
Parameters:
actActuator instance.
function syn_actuator_update¶
Update — read pot, run PID, drive motor.
Call from your scheduler task at the configured update_hz.
Parameters:
actActuator instance.
Returns:
Current position (0-1000).
Public Static Functions Documentation¶
function syn_actuator_at_target¶
Check if actuator has reached its target.
Parameters:
actActuator.
Returns:
true if within ±0.5% of target.
function syn_actuator_is_stalled¶
Check if stalled.
Parameters:
actActuator.
Returns:
true if motor is stalled.
function syn_actuator_position¶
Get current position (0-1000, i.e. 0.0-100.0%).
Parameters:
actActuator.
Returns:
Position in 0.1% units.
The documentation for this class was generated from the following file src/syntropic/motor/syn_actuator.h