File syn_foc.h¶
Go to the source code of this file
Fixed-point Field-Oriented Control transforms (Clarke & Park). More...
#include "../common/syn_defs.h"#include "../util/syn_qmath.h"
Classes¶
| Type | Name |
|---|---|
| struct | SYN_FOC_AB 2-phase stationary frame (α, β). |
| struct | SYN_FOC_ABC 3-phase values (a, b, c). |
| struct | SYN_FOC_DQ 2-phase rotating frame (d, q). |
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 (α, β). |
Detailed Description¶
Provides the mathematical transforms needed for BLDC/PMSM motor control:
- Clarke transform: 3-phase (a, b, c) → 2-phase stationary (α, β)
- Inverse Clarke: (α, β) → (a, b, c)
- Park transform: Stationary (α, β) → rotating (d, q) using rotor angle θ
- Inverse Park: Rotating (d, q) → stationary (α, β)
All values are Q16.16 fixed-point. No floating point, no heap allocation.
** **
SYN_FOC_AB ab;
SYN_FOC_DQ dq;
SYN_FOC_ABC phase_currents = { ia, ib, ic }; // measured currents
q16_t theta = electrical_angle; // rotor angle
// Forward: ABC → αβ → dq
syn_foc_clarke(&phase_currents, &ab);
syn_foc_park(&ab, theta, &dq);
// Now dq.d and dq.q are the field-aligned currents.
// Run PID on dq, then inverse transform for PWM:
syn_foc_inv_park(&dq_cmd, theta, &ab);
syn_foc_inv_clarke(&ab, &phase_voltages);
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].
The documentation for this class was generated from the following file src/syntropic/motor/syn_foc.h