File sstep_internal.h¶
FileList > src > sstep_internal.h
Go to the source code of this file
#include <stdbool.h>#include <stdint.h>#include "sstep_ctrl.h"#include "sstep_math.h"
Classes¶
| Type | Name |
|---|---|
| struct | sstep_bridge_out Result of the power stage mapping. |
| struct | sstep_ctx Driver state behind the opaque sstep . |
| struct | sstep_motion Motion generator state. |
| struct | sstep_setpoint Setpoint handed from the slow loop to the fast loop. |
Public Functions¶
| Type | Name |
|---|---|
| void | sstep_bridge_map (enum sstep_topology topology, sstep_acc_t va, sstep_acc_t vb, const struct sstep_gain * inv_vbus, sstep_acc_t vbus, uint16_t period, struct sstep_bridge_out * out) Map requested phase voltages to leg compare values (averaged power stage). |
| uint32_t | sstep_isqrt64 (uint64_t x) Integer square root: floor(sqrt(x)). |
| uint8_t | sstep_motion_step (struct sstep_motion * mo) One slow loop period of the motion generator: trapezoidal velocity profile with one-period look-ahead braking for moves, exact stop on the target. |
| bool | sstep_stall_check (struct sstep_ctx * m) Stall decision of one slow loop period, against the command of the period that just ended (vel_cmd, ff_cmd). |
| void | sstep_stall_observe (struct sstep_ctx * m, const struct sstep_sincos * sc, const sstep_acc_t v_applied) Back-EMF observer of one fast loop period (fast loop, current drive). |
| void | sstep_stall_reset (struct sstep_ctx * m) Reset the stall detector when the outputs are enabled: empty voltage history, filters at zero, current history from the last measurement. |
| void | sstep_stall_status (const struct sstep_ctx * m, struct sstep_status * status) Fill the observer fields of a status (zero when stall detection is off). |
Public Static Functions¶
| Type | Name |
|---|---|
| struct sstep_ctx * | sstep_ctx_of (struct sstep * drv) Driver state of an instance. |
| const struct sstep_ctx * | sstep_ctx_of_const (const struct sstep * drv) Read-only variant of sstep_ctx_of(). |
Macros¶
| Type | Name |
|---|---|
| define | SSTEP_MODE_HOLD 0UMotion generator modes. |
| define | SSTEP_MODE_MOVE 1U |
| define | SSTEP_MODE_RUN 2U |
| define | SSTEP_MOTION_DONE 0x01UResult flags of sstep_motion_step(). |
| define | SSTEP_POS_ONE ((int64\_t)65536)Fixed point position: 1 microstep = 2^16. |
| define | SSTEP_POS_SNAP ((int64\_t)64)A move ends when it is closer than this to the target and slow enough (1/1024 microstep). |
| define | SSTEP_READY 0x53545043UValue of sstep_ctx::ready after a successfulsstep_init() ("STPC"). |
Public Functions Documentation¶
function sstep_bridge_map¶
Map requested phase voltages to leg compare values (averaged power stage).
void sstep_bridge_map (
enum sstep_topology topology,
sstep_acc_t va,
sstep_acc_t vb,
const struct sstep_gain * inv_vbus,
sstep_acc_t vbus,
uint16_t period,
struct sstep_bridge_out * out
)
The voltage vector is scaled down with its direction kept when the stage cannot produce it: full bridge |a|, |b| <= 1, shared leg max(a,b,0) - min(a,b,0) <= 1, a and b relative to the measured bus voltage. Shared leg: common leg centred.
Parameters:
topologyPower stage topology (compiled in).vaRequested phase voltages [pu of V_base].inv_vbusV_base / bus voltage.vbusBus voltage [pu of V_base], 0 .. 2.periodCompare value for 100 % duty cycle.outResult.
function sstep_isqrt64¶
Integer square root: floor(sqrt(x)).
Parameters:
xValue.
Returns:
floor(sqrt(x)).
function sstep_motion_step¶
One slow loop period of the motion generator: trapezoidal velocity profile with one-period look-ahead braking for moves, exact stop on the target.
Parameters:
moMotion state; pos and vel are updated.
Returns:
SSTEP_MOTION_DONE when a move reached its target in this period, else 0.
function sstep_stall_check¶
Stall decision of one slow loop period, against the command of the period that just ended (vel_cmd, ff_cmd).
Parameters:
mDriver state.
Returns:
true when the stall condition has persisted for stall_time_ms.
function sstep_stall_observe¶
Back-EMF observer of one fast loop period (fast loop, current drive).
void sstep_stall_observe (
struct sstep_ctx * m,
const struct sstep_sincos * sc,
const sstep_acc_t v_applied
)
Uses the voltage computed two periods ago (applied during the period that just ended), the measured currents and the commanded angle, then stores v_applied.
Parameters:
mDriver state; i_meas holds the currents of this period.scSine and cosine of the commanded angle of this period.v_appliedPhase voltages computed in this period [pu V].
function sstep_stall_reset¶
Reset the stall detector when the outputs are enabled: empty voltage history, filters at zero, current history from the last measurement.
Parameters:
mDriver state.
function sstep_stall_status¶
Fill the observer fields of a status (zero when stall detection is off).
Parameters:
mDriver state.statusStatus to complete.
Public Static Functions Documentation¶
function sstep_ctx_of¶
Driver state of an instance.
Note:
MISRA C:2012 Rule 11.3, deviation DEV-01 (docs/misra.md): sstep is the opaque storage of sstep_ctx; size and alignment are checked in sstep_ctrl.c.
Parameters:
drvDriver instance, may be NULL.
Returns:
Driver state, NULL if drv is NULL.
function sstep_ctx_of_const¶
Read-only variant of sstep_ctx_of().
Macro Definition Documentation¶
define SSTEP_MODE_HOLD¶
Motion generator modes.
define SSTEP_MODE_MOVE¶
define SSTEP_MODE_RUN¶
define SSTEP_MOTION_DONE¶
Result flags of sstep_motion_step().
define SSTEP_POS_ONE¶
Fixed point position: 1 microstep = 2^16.
define SSTEP_POS_SNAP¶
A move ends when it is closer than this to the target and slow enough (1/1024 microstep).
define SSTEP_READY¶
Value of sstep_ctx::ready after a successfulsstep_init() ("STPC").
A zeroed or never initialized instance holds another value: every function but sstep_init() then returns SSTEP_ERR_STATE instead of using an empty configuration.
The documentation for this class was generated from the following file src/sstep_internal.h