Skip to main content

Module coordinate_transforms

Module coordinate_transforms 

Source
Expand description

Clarke/Park coordinate transforms — the standard change of basis between a three-phase abc signal, its stationary two-axis alpha/beta (plus zero-sequence) projection, and a rotating d/q (plus zero-sequence) frame locked to a reference angle theta. Used to turn a three-phase grid or motor-drive quantity into DC-like d/q values a Pid can regulate directly, and the matching angle-tracking utility (anglewrap) that closes the loop (a synchronous-reference-frame PLL is Clarke -> anglewrap -> Park, feeding a Pid on the q output back into the tracked angle).

Every function here is a pure, stateless function of its instantaneous inputs (no integration, no memory) — the same category as crate::math_ops and crate::waveform_arithmetic, just multi-output. CoordinateTransform groups them the same way crate::MathFn1/crate::MathFn2 group the single-output functions, so dae-runtime’s block graph can dispatch by one enum instead of one bespoke BlockKind variant per transform.

clarke_park/clarke_park_inv are convenience compositions of clarke/park (and their inverses) directly against abc, skipping the alpha/beta intermediate — see clarke_park_matches_clarke_then_park below for the equivalence this relies on. Amplitude convention throughout is the standard “2/3” (non-power-invariant) scaling: a balanced three-phase signal of peak amplitude A transforms to a d/q pair of magnitude A, not A * sqrt(3/2).

Enums§

CoordinateTransform
One of the six Clarke/Park coordinate transforms, grouped for dispatch by dae-runtime’s block graph the same way crate::MathFn1/crate::MathFn2 group the single-output waveform-arithmetic functions.

Functions§

anglewrap
(alpha, beta) -> theta, wrapped to [0, 2*pi) — the angle-tracking half of a synchronous-reference-frame PLL: atan2(beta, alpha), shifted by a full turn when negative instead of the usual (-pi, pi] range, so theta is a monotonically-sensible input to park/clarke_park across a full mechanical/electrical revolution.
clarke
abc -> (alpha, beta, zero).
clarke_inv
(alpha, beta, zero) -> abc. Exact inverse of clarke.
clarke_park
(a, b, c, theta) -> (d, q, zero) — a convenience composition of clarke then park, skipping the alpha/beta intermediate for the common case of going straight from a three-phase signal to its rotating-frame d/q value. Kept as its own function purely for netlist/call-site ergonomics (one call instead of wiring Clarke into Park) — calls through to clarke/park directly rather than re-deriving the trig, since a family exactly like this one (a combined transform hand-expanded separately from its two-step composition) is documented to have shipped with d/q swapped once already in the upstream library this crate’s formulas were adapted from; there is exactly one real implementation of each direction now, not two that could silently drift apart.
clarke_park_inv
(d, q, zero, theta) -> (a, b, c) — the same convenience-composition treatment as clarke_park, calling through to park_inv then clarke_inv. Exact inverse of clarke_park.
park
(alpha, beta, zero, theta) -> (d, q, zero) — projects the stationary frame onto a frame rotating at angle theta (radians). Zero-sequence passes through unchanged.
park_inv
(d, q, zero, theta) -> (alpha, beta, zero). Exact inverse of park at the same theta.