File sstep_stall.c¶
FileList > src > sstep_stall.c
Go to the source code of this file
#include "sstep_internal.h"
Public Functions¶
| Type | Name |
|---|---|
| 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 |
|---|---|
| int64_t | abs_i64 (int64_t v) |v| for |v| < 2^63. |
| sstep_angle_t | atan2_turn (int32_t y, int32_t x) Angle of the vector (x, y), atan2(y, x), in 2^-32 turn (CORDIC, vectoring mode). |
| int32_t | emf_mv (const struct sstep_ctx * m, uint32_t axis) Filtered back-EMF of one axis (0 = d, 1 = q) [mV]. |
| uint64_t | muldiv_u64 (uint64_t a, uint64_t b, uint64_t d) a * b / d (truncated) without overflow for a < 2^42, b < 2^25, 0 < d < 2^35. |
Macros¶
| Type | Name |
|---|---|
| define | CDEG_PER_TURN 36000Centidegrees per turn. |
| define | CORDIC_NORM ((int32\_t)0x08000000)The CORDIC operands are scaled up to at least 2^27 for resolution; the CORDIC gain (1.65 * sqrt(2)) keeps them below 2^30. |
| define | CORDIC_STEPS 16UCORDIC iterations of atan2_turn() (last step atan(2^-15) = 0.0017 deg). |
| define | HALF_TURN 0x80000000UHalf a turn of sstep_angle_t . |
| define | OFF_ONE ((int64\_t)65536)Fixed point one of sstep_ctx::emf_off (mV * 2^16). |
| define | TURN ((int64\_t)4294967296)One turn of sstep_angle_t as a 64-bit value. |
| define | TWO_PI_DEN 113U |
| define | TWO_PI_NUM 710U2 pi = 710 / 113, as in the gain derivation. |
Public Functions Documentation¶
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 abs_i64¶
|v| for |v| < 2^63.
function atan2_turn¶
Angle of the vector (x, y), atan2(y, x), in 2^-32 turn (CORDIC, vectoring mode).
0 for the zero vector.
Parameters:
yComponents, |x|, |y| < 2^27.
function emf_mv¶
Filtered back-EMF of one axis (0 = d, 1 = q) [mV].
function muldiv_u64¶
a * b / d (truncated) without overflow for a < 2^42, b < 2^25, 0 < d < 2^35.
Macro Definition Documentation¶
define CDEG_PER_TURN¶
Centidegrees per turn.
define CORDIC_NORM¶
The CORDIC operands are scaled up to at least 2^27 for resolution; the CORDIC gain (1.65 * sqrt(2)) keeps them below 2^30.
define CORDIC_STEPS¶
CORDIC iterations of atan2_turn() (last step atan(2^-15) = 0.0017 deg).
define HALF_TURN¶
Half a turn of sstep_angle_t .
define OFF_ONE¶
Fixed point one of sstep_ctx::emf_off (mV * 2^16).
define TURN¶
One turn of sstep_angle_t as a 64-bit value.
define TWO_PI_DEN¶
define TWO_PI_NUM¶
2 pi = 710 / 113, as in the gain derivation.
The documentation for this class was generated from the following file src/sstep_stall.c