41 SERVO_SYNC_RUNNING = 0,
47 SERVO_SYNC_FAULT_NONE = 0,
69 SERVO_SYNC_STAGE_CENTRE = 0,
70 SERVO_SYNC_STAGE_HIGH,
72 SERVO_SYNC_STAGE_COUNT,
76#define SERVO_SYNC_MAX_POINTS 9
102 float slew_us_per_ms;
119#define SERVO_SYNC_MIN_US 500u
120#define SERVO_SYNC_MAX_US 2500u
124 servo_sync_state_t state;
138 float worst_a[SERVO_SYNC_STAGE_COUNT];
144 int32_t win_centre_us;
147 uint32_t phase_start_ms;
188 uint16_t *cmd_a, uint16_t *cmd_b);
void servo_sync_step(servo_sync_t *sy, float total_a, uint32_t now_ms, uint16_t *cmd_a, uint16_t *cmd_b)
Advance the search with one reading of the pair's total current.
Definition servo_sync.c:277
#define SERVO_SYNC_MAX_POINTS
The most points one round of a scan may have.
Definition servo_sync.h:76
void servo_sync_defaults(servo_sync_cfg_t *cfg, uint16_t centre_us)
Defaults for a sync search.
Definition servo_sync.c:25
servo_sync_stage_t
Which of the three measurements the search is on.
Definition servo_sync.h:68
servo_sync_fault_t
Definition servo_sync.h:46
@ SERVO_SYNC_FAULT_NO_MINIMUM
The scan found no minimum distinguishable from the noise, or none inside its window.
Definition servo_sync.h:64
@ SERVO_SYNC_FAULT_OVERCURRENT
Current crossed the hard ceiling.
Definition servo_sync.h:51
void servo_sync_init(servo_sync_t *sy, const servo_sync_cfg_t *cfg)
Start a sync search at the centre stage.
Definition servo_sync.c:135
float servo_sync_progress(const servo_sync_t *sy)
0..1 across all three stages.
Definition servo_sync.c:330
Definition servo_sync.h:78
int16_t window_us
Definition servo_sync.h:82
uint16_t settle_ms
How long to wait after a move before a reading counts.
Definition servo_sync.h:101
uint16_t deflection_us
Definition servo_sync.h:80
uint8_t rounds
Definition servo_sync.h:84
float min_depth_a
How far the best reading of a scan must sit below the worst before the minimum counts.
Definition servo_sync.h:113
uint8_t points
Definition servo_sync.h:83
Definition servo_sync.h:122
uint32_t travel_ms
Definition servo_sync.h:148
float best_a[SERVO_SYNC_STAGE_COUNT]
What the pair draws at the best and the worst point of each stage.
Definition servo_sync.h:137
int16_t travel_lo_us
Definition servo_sync.h:131
int16_t travel_hi_us
Definition servo_sync.h:130
int16_t trim_us
Definition servo_sync.h:129