38 SERVO_LIMIT_RUNNING = 0,
44 SERVO_LIMIT_FAULT_NONE = 0,
64#define SERVO_LIMIT_MIN_US 500u
65#define SERVO_LIMIT_MAX_US 2500u
119 servo_limit_state_t state;
130 uint32_t phase_start_ms;
136 uint32_t elevated_since_ms;
float servo_limit_progress(const servo_limit_t *lf)
How far the search has gone, 0..1, for a progress bar.
Definition servo_limit.c:297
servo_limit_fault_t
Definition servo_limit.h:43
@ SERVO_LIMIT_FAULT_NO_LIMIT
The whole permitted travel was covered without binding.
Definition servo_limit.h:56
@ SERVO_LIMIT_FAULT_OVERCURRENT
Current crossed the hard ceiling.
Definition servo_limit.h:48
@ SERVO_LIMIT_FAULT_STALL
Current stayed above the knee for longer than the stall timeout.
Definition servo_limit.h:51
@ SERVO_LIMIT_FAULT_BAD_CONFIG
step_us is 0: no step can reach a stop.
Definition servo_limit.h:60
void servo_limit_init(servo_limit_t *lf, const servo_limit_cfg_t *cfg)
Start a limit search.
Definition servo_limit.c:90
uint16_t servo_limit_step(servo_limit_t *lf, float current_a, uint32_t now_ms)
Advance the search with one current reading, and return the pulse width the servo should be commanded...
Definition servo_limit.c:227
void servo_limit_defaults(servo_limit_cfg_t *cfg, uint16_t centre_us, bool positive)
Defaults for a hobby servo on a control surface.
Definition servo_limit.c:64
Definition servo_limit.h:67
float stall_above_a
Working hard: above this the servo is doing real work, and it may not do so for longer than stall_ms.
Definition servo_limit.h:101
int16_t step_us
Definition servo_limit.h:69
uint16_t measure_ms
Definition servo_limit.h:73
uint16_t settle_ms
Definition servo_limit.h:72
float hard_limit_a
Definition servo_limit.h:87
uint16_t max_travel_us
Definition servo_limit.h:70
uint16_t stall_ms
Definition servo_limit.h:102
float knee_ratio
The knee. Current must exceed the free-running baseline by both a ratio and an absolute margin before...
Definition servo_limit.h:84
uint16_t centre_us
Definition servo_limit.h:68
uint16_t backoff_us
Definition servo_limit.h:103
Definition servo_limit.h:117
uint16_t cmd_us
Definition servo_limit.h:122
uint16_t limit_us
Definition servo_limit.h:124
float baseline_a
Definition servo_limit.h:126
uint16_t last_free_us
Definition servo_limit.h:123
uint32_t baseline_steps
Definition servo_limit.h:134
float knee_a
Definition servo_limit.h:127