File syn_foc.c¶
Go to the source code of this file
Fixed-point Field-Oriented Control transforms. More...
#include "../common/syn_defs.h"#include "../util/syn_assert.h"#include "syn_foc.h"
Public Functions¶
| Type | Name |
|---|---|
| void | syn_foc_clarke (const SYN_FOC_ABC * abc, SYN_FOC_AB * ab) Clarke transform: 3-phase (a,b,c) → 2-phase (α,β). |
| bool | syn_foc_field_weakening (q16_t v_d, q16_t v_q, q16_t v_max, q16_t * id_cmd) Automatic Field-Weakening Controller. |
| void | syn_foc_inv_clarke (const SYN_FOC_AB * ab, SYN_FOC_ABC * abc) Inverse Clarke: 2-phase (α,β) → 3-phase (a,b,c). |
| void | syn_foc_inv_park (const SYN_FOC_DQ * dq, q16_t theta, SYN_FOC_AB * ab) Inverse Park: rotating (d,q) → stationary (α,β). |
| void | syn_foc_inv_park_fast (const SYN_FOC_DQ * dq, q16_t theta, SYN_FOC_AB * ab) Inverse Park: rotating (d,q) → stationary (α,β) using ultra-fast sincos. |
| void | syn_foc_park (const SYN_FOC_AB * ab, q16_t theta, SYN_FOC_DQ * dq) Park transform: stationary (α,β) → rotating (d,q). |
| void | syn_foc_park_fast (const SYN_FOC_AB * ab, q16_t theta, SYN_FOC_DQ * dq) Park transform: stationary (α,β) → rotating (d,q) using ultra-fast sincos. |
| void | syn_foc_svpwm (const SYN_FOC_AB * ab, q16_t v_bus, q16_t * duty_a, q16_t * duty_b, q16_t * duty_c) Compute Space Vector PWM duty cycles from (α, β). |
Macros¶
| Type | Name |
|---|---|
| define | Q16_2_INV_SQRT3 75674Precomputed 2/√3 in Q16.16 (≈ 1.15470). |
| define | Q16_INV_SQRT3 37837Precomputed 1/√3 in Q16.16 (≈ 0.57735). |
| define | Q16_SQRT3 113512Precomputed √3 in Q16.16 (≈ 1.73205). |
| define | Q16_SQRT3_OVER_2 56756Precomputed √3/2 in Q16.16 (≈ 0.86603). |
Detailed Description¶
All transforms use Q16.16 arithmetic with int64_t intermediates. No floating point, no heap allocation.
Public Functions Documentation¶
function syn_foc_clarke¶
Clarke transform: 3-phase (a,b,c) → 2-phase (α,β).
Power-invariant form: α = a β = (a + 2b) / √3
Assumes balanced 3-phase: a + b + c = 0.
Parameters:
abcInput 3-phase values.abOutput (α, β).
function syn_foc_field_weakening¶
Automatic Field-Weakening Controller.
Injects negative d-axis current (Id < 0) when commanded voltage magnitude exceeds maximum available bus voltage limit (V_max = V_bus / sqrt(3)), allowing high-speed motor operation above rated base speed.
Parameters:
v_dCurrent D-axis voltage command (Q16).v_qCurrent Q-axis voltage command (Q16).v_maxMaximum available phase voltage magnitude (Q16).id_cmd[in/out] Current D-axis command (Q16). Adjusted if over-voltage occurs.
Returns:
true if field weakening active, false if operating normally.
function syn_foc_inv_clarke¶
Inverse Clarke: 2-phase (α,β) → 3-phase (a,b,c).
Parameters:
abInput (α, β).abcOutput 3-phase values.
function syn_foc_inv_park¶
Inverse Park: rotating (d,q) → stationary (α,β).
α = d·cos(θ) − q·sin(θ) β = d·sin(θ) + q·cos(θ)
Parameters:
dqInput rotating-frame values.thetaElectrical rotor angle in Q16 radians.abOutput stationary-frame values.
function syn_foc_inv_park_fast¶
Inverse Park: rotating (d,q) → stationary (α,β) using ultra-fast sincos.
function syn_foc_park¶
Park transform: stationary (α,β) → rotating (d,q).
d = α·cos(θ) + β·sin(θ) q = −α·sin(θ) + β·cos(θ)
Parameters:
abInput stationary-frame values.thetaElectrical rotor angle in Q16 radians.dqOutput rotating-frame values.
function syn_foc_park_fast¶
Park transform: stationary (α,β) → rotating (d,q) using ultra-fast sincos.
function syn_foc_svpwm¶
Compute Space Vector PWM duty cycles from (α, β).
void syn_foc_svpwm (
const SYN_FOC_AB * ab,
q16_t v_bus,
q16_t * duty_a,
q16_t * duty_b,
q16_t * duty_c
)
Maps (α, β) voltages to three-phase PWM duty cycles in the range [0, Q16_ONE]. Uses standard 7-segment SVPWM pattern.
Parameters:
abInput (α, β) voltage commands (Q16).v_busDC bus voltage in Q16 (for normalization).duty_aOutput duty cycle for phase A [0, Q16_ONE].duty_bOutput duty cycle for phase B [0, Q16_ONE].duty_cOutput duty cycle for phase C [0, Q16_ONE].
Macro Definition Documentation¶
define Q16_2_INV_SQRT3¶
Precomputed 2/√3 in Q16.16 (≈ 1.15470).
define Q16_INV_SQRT3¶
Precomputed 1/√3 in Q16.16 (≈ 0.57735).
define Q16_SQRT3¶
Precomputed √3 in Q16.16 (≈ 1.73205).
define Q16_SQRT3_OVER_2¶
Precomputed √3/2 in Q16.16 (≈ 0.86603).
The documentation for this class was generated from the following file src/syntropic/motor/syn_foc.c