File syn_autotune.c¶
FileList > control > syn_autotune.c
Go to the source code of this file
#include "../port/syn_port_system.h"#include "../util/syn_assert.h"#include "syn_autotune.h"#include <string.h>#include <stdio.h>
Public Functions¶
| Type | Name |
|---|---|
| void | syn_autotune_abort (SYN_AutoTune * at) Abort the auto-tune and stop the motor immediately. |
| void | syn_autotune_apply (SYN_AutoTune * at) Apply computed gains to the motor controller. |
| void | syn_autotune_calc_relay_gains (int32_t Ku, uint32_t Tu_ms, SYN_AutoTune_Method method, uint16_t multiplier_pct, int32_t * kp, int32_t * ki, int32_t * kd) Calculate Ziegler-Nichols / Tyreus-Luyben PID gains from ultimate gain (Ku) and period (Tu_ms). |
| SYN_Status | syn_autotune_init (SYN_AutoTune * at, SYN_MotorCtrl * ctrl, const SYN_AutoTune_Config * cfg) Initialize the auto-tuner. |
| SYN_Status | syn_autotune_start (SYN_AutoTune * at, SYN_MotorCtrl * ctrl, const SYN_AutoTune_Limits * limits, SYN_AutoTune_Flags flags, uint16_t gain_multiplier) Start a fully automatic tune sequence. |
| SYN_AutoTune_State | syn_autotune_update (SYN_AutoTune * at) Update the auto-tuner — call from main loop. |
Public Static Functions¶
| Type | Name |
|---|---|
| void | apply_raw_output (SYN_AutoTune * at, int32_t output) |
| void | emergency_stop (SYN_AutoTune * at, SYN_AutoTune_AbortReason reason) |
| int32_t | ramp_output (SYN_AutoTune * at, int32_t target, uint32_t elapsed) |
| bool | safety_ok (SYN_AutoTune * at, int32_t pos, int32_t velocity) |
| void | write_log (SYN_AutoTune * at) |
Public Functions Documentation¶
function syn_autotune_abort¶
Abort the auto-tune and stop the motor immediately.
Parameters:
atAuto-tuner instance.
function syn_autotune_apply¶
Apply computed gains to the motor controller.
Copies ff_kv, ff_scale, and PID gains into the motor controller. Only valid when state == DONE.
Parameters:
atAuto-tuner instance.
function syn_autotune_calc_relay_gains¶
Calculate Ziegler-Nichols / Tyreus-Luyben PID gains from ultimate gain (Ku) and period (Tu_ms).
void syn_autotune_calc_relay_gains (
int32_t Ku,
uint32_t Tu_ms,
SYN_AutoTune_Method method,
uint16_t multiplier_pct,
int32_t * kp,
int32_t * ki,
int32_t * kd
)
Parameters:
KuUltimate gain (scaled by pid_scale).Tu_msUltimate period in milliseconds.methodTuning rule (Ziegler-Nichols, Tyreus-Luyben, No-Overshoot).multiplier_pctGain safety multiplier percentage (1-200, e.g. 80 for 80%).kpOutput proportional gain.kiOutput integral gain.kdOutput derivative gain.
function syn_autotune_init¶
Initialize the auto-tuner.
SYN_Status syn_autotune_init (
SYN_AutoTune * at,
SYN_MotorCtrl * ctrl,
const SYN_AutoTune_Config * cfg
)
Parameters:
atAuto-tuner instance.ctrlMotor controller to tune (tuner takes control while active).cfgConfiguration. position_limit MUST be set.
Returns:
SYN_OK, or SYN_ERROR if position_limit is 0.
function syn_autotune_start¶
Start a fully automatic tune sequence.
SYN_Status syn_autotune_start (
SYN_AutoTune * at,
SYN_MotorCtrl * ctrl,
const SYN_AutoTune_Limits * limits,
SYN_AutoTune_Flags flags,
uint16_t gain_multiplier
)
Runs probe → FF identification → braking → relay PID tune → braking as a single self-sequencing state machine. The user only provides physical constraints.
Parameters:
atAuto-tuner instance.ctrlMotor controller to tune.limitsPhysical constraints (track limits, max velocity).flagsFeature flags (e.g., SYN_ATUNE_FLAG_ALL).gain_multiplierSafety margin for PID gains (percentage, e.g., 80).
Returns:
SYN_OK on success, or error code.
function syn_autotune_update¶
Update the auto-tuner — call from main loop.
Parameters:
atAuto-tuner instance.
Returns:
Current state. When DONE, results are in syn_autotune_result().
Public Static Functions Documentation¶
function apply_raw_output¶
function emergency_stop¶
function ramp_output¶
Ramp output from 0 toward target over ramp_ms. Returns current output.
function safety_ok¶
Check all safety conditions. Returns true if safe.
function write_log¶
The documentation for this class was generated from the following file src/syntropic/control/syn_autotune.c