How Resolver Angles Are Decoded: From IQ Demodulation to PLL
A three-stage mathematical walkthrough and worked numerical example for multi-pole resolver software decoding: why magnitude or atan2(Q,I) fails, why a Type-II PLL is required, and why outer corrections never write back into the inner loop.
Most engineers approaching software resolver-to-digital decoding hit the same two snags. First, equations overflow with and terms, making it easy to confuse the fast excitation carrier with the slow rotor angle. Second, once you recover quadrature sine and cosine envelopes, it is tempting to just call atan2 and stop — so why add a Phase-Locked Loop (PLL), harmonic feedforward, and coarse-fine vernier fusion on top?
This article documents the algorithm core behind Resolver — Dual-Core TMS320F28377D + CLA Resolver Decoding. Setting aside chip registers and assembly scheduling, we trace a 16-pole-pair fine resolver (, samples per carrier cycle, ADC rate) from raw ADC samples to an absolute mechanical angle, backed by a reproducible numerical example.
Overview: Three Stages, Strictly One-Way
The pipeline splits cleanly by time scale. Upstream stages hand results downstream and never accept state write-backs from outer corrections:
In short:
- Carrier stage (IQ correlation + signed projection) strips the high-frequency carrier and DC offset while preserving the exact sign of and .
- Electrical stage (ellipse calibration + Type-II PLL) turns a distorted ellipse back into a unit circle, then tracks electrical angle and velocity in closed loop.
- Mechanical stage (unwrap + outer corrections + vernier fusion) resolves the 16-way ambiguity of a 16-pole-pair resolver ( mechanical per electrical cycle) into a single absolute mechanical angle.
1. IQ Demodulation: Peeling Rotor Angle Off the Carrier
Signal Model
Neglecting higher spatial harmonics, the two fine secondary-coil channels are:
Keep the two angles strictly separate:
- is the high-frequency excitation carrier phase; are fixed carrier phase lags from analog filtering and sampling delay.
- is the electrical rotor angle, carried solely in the slow signed envelopes and .
- are DC offsets and are sample noise.
Full-Cycle Quadrature Correlation
Multiply one complete carrier cycle ( samples) against local quadrature references and , then average:
By product-to-sum identities:
Over an exact integer carrier cycle, the double-frequency terms and every nonzero harmonic sum to exactly zero. DC offsets also vanish against zero-mean references, and uncorrelated noise variance drops by . What remains is a clean 2D vector per channel:
Why Magnitude and atan2(Q, I) Both Fail
- The angle of is the hardware carrier delay , not the rotor angle . Calling only measures analog lag.
- Taking the magnitude destroys the sign of , collapsing and into the same value.
The right operation is a signed dot-product projection onto the calibrated carrier phase :
and identically for the cosine channel. Because is flat near zero, a – phase calibration error produces only negligible second-order amplitude shrinkage and zero angle error.
Calibrating Without Spinning the Motor
Writing and (where is the signed rotor envelope), double-angle identities square away both rotor position and sign:
Because , can be estimated at standstill. The sole trade-off is that half-angle resolves , so global polarity must be fixed once against a reference direction.
2. Ellipse Calibration Before Normalization
Ideally traces a centered circle as the shaft rotates. Residual offsets and channel gain mismatch () skew it into an off-center ellipse, injecting periodic angle error.
Correct the ellipse linearly first, then normalize jointly onto the unit circle:
The two steps are not interchangeable: normalization removes common-mode drift (excitation voltage or temperature swings) and keeps PLL loop gain constant, whereas ellipse calibration removes differential gain and offset errors that normalization cannot touch.
3. Tracking PLL: Closed-Loop Angle Estimation via 2D Cross Product
Direct atan2(Vs, Vc) passes every sample of noise straight to the output, and finite-differencing it for velocity amplifies noise dramatically. A tracking PLL maintains an internal angle estimate and drives the phase error to zero.
Phase Detector = 2D Cross Product
Take the 2D cross product between measured and estimated :
When lags , accelerates the loop; when it leads, pulls it back. Once locked (), linearizes automatically.
Why a Type-II Second-Order Loop
Feed through a PI controller to obtain electrical angular velocity , then integrate velocity into angle:
In continuous small-signal form:
Two integrators in the open loop make it a Type-II loop. A constant-speed shaft produces a ramp input ; only a double zero () in the error transfer function guarantees zero steady-state tracking error at constant velocity. Matching yields and . Note that the closed-loop numerator adds a zero, so step overshoot is higher than textbook all-pole formulas predict.
Low-Speed Integrator Bleed & Unwrapping
At standstill or creep speed, double integration can slowly wind up on tiny residual bias. When both velocity and phase error stay below threshold, applying a gentle leak () trades a tiny static offset for zero standstill drift.
Finally, unwrap the electrical angle incrementally and divide by :
Increment unwrapping stays unambiguous only while , which sets a hard mathematical upper bound for velocity clamping.
4. Outer-Loop Corrections: Fix the Output, Never the PLL State
Three outer corrections sit downstream of the unwrapped angle: harmonic feedforward, Anchor slow bias, and coarse-fine vernier fusion. None of them may write back into the PLL state, preserving inner-loop bandwidth and clean velocity estimates.
- Harmonic Feedforward: Subtracts residual 4th/8th electrical-angle periodic distortion directly from the output.
- Anchor Slow Bias: Compares raw
atan2(S, C)/Nagainst , filters valid residuals through a gated low-pass target , and slews via a critically damped actuator () much slower than PLL bandwidth so there are no output steps. - Coarse-Fine Vernier Fusion: A 16-pole-pair fine resolver repeats every . A single-pole coarse angle picks which sector the shaft occupies:
As long as coarse error stays within half a sector (), is exact: coarse resolves which sector, fine PLL resolves precision and dynamics inside the sector.
5. Worked Public Numerical Example
Let , , and . Set a synthetic ground truth and realistic front-end imperfections:
- True mechanical angle (sector , fine offset ), so true electrical angle .
- Channel amplitudes and DC offsets (4% gain mismatch): ; .
- True carrier phase shifts , with an intentional calibration error: .
- Coarse single-pole reading ( error, safely inside ).
| Stage | Input / Operation | Computed Output | Engineering Takeaway |
|---|---|---|---|
| 0. Carrier samples () | First 4 samples | 16-point carrier frame | Mixes carrier, DC offset, and 4% gain mismatch |
| 1. Full-cycle IQ correlation | Average against | vanish; and confirm this is hardware lag, not rotor angle | |
| 2. Signed projection | Dot product along | Uncalibrated : 4% gain mismatch adds electrical error | |
| 3. Ellipse cal + normalize | Scale by , then normalize | phase calibration error shrinks by only and leaves angle at exact | |
| 4. One Type-II PLL tick | From ( lag), , , () | (true ) | Cross product tracks small error linearly and pulls forward by in a single tick |
| 5. Coarse-fine fusion | Steady state with | Even with coarse bias, sector selection is exact and recovers |
Closing Thought: Separate Time Scales, Keep Flow One-Way
What keeps this pipeline stable on a real DSP is not any exotic trick, but strict time-scale separation and one-way data flow: carrier correlation strips excitation and DC at the fastest layer; ellipse calibration and a Type-II PLL handle dynamics and velocity in the middle; harmonic feedforward, Anchor bias, and vernier fusion resolve geometry and multi-turn ambiguity outside the loop.
For how these stages map onto dual-core TMS320F28377D CPUs, dual CLAs, and FPGA BiSS-C output, see the project page: Resolver — Dual-Core TMS320F28377D + CLA Resolver Decoding.