Skip to content

Interactive explainer

The synchronous reference frame PLL

A grid-connected converter needs the grid's angle at every instant. The SRF-PLL finds it by turning a Park frame until qq is zero. Below, the loop runs block by block with every wire's signal on it: tune it by its gains or by how fast you want it to settle, then throw a phase jump, a frequency step or ramp, a sag, unbalance or harmonics at it.

From the courses Analysis and Control of Modern Power Electronics Dominated Power Systems (UPC Barcelona) and Control of Electrical Machines and Power Electronics (UPC Barcelona).

vabc±1.2 pugridαβ|v| 1.00vα -1.00vβ 0.00Clarked qq 0.00Park at θ̂e0.000÷ |v|Δω0.0 rad/sPIω̂50.00 Hz+θ̂180°1/sω₀

Tap a block, or reach it with Tab, to read its equation and its numbers now.

angle less ω₀t: θ and θ̂±60°0 ms100 ms200 ms300 msfrequency: f and f̂50 ± 20 Hz0 ms100 ms200 ms300 msangle error θ − θ̂±45°0 ms100 ms200 ms300 ms
30 ms
What the run did
Error now0°
Largest after 40 ms40.0°
At the end0°

Back within 2 % of the largest error (0.8°) 38.4 ms after the change.

The loop
Set it
180 /s
16,200 /s²

ωn = 127.3 rad/s (20.3 Hz), ζ = 0.71; −3 dB at 41.7 Hz, phase margin 65.5°; within 2 % of a phase jump in 38.4 ms by the linear model.

The grid, from 40 ms
+40°
0 Hz
0 Hz/s
1.00 pu
0.00 pu
0.00 pu
0.00 pu
The PI is given
The loop block by block: Clarke, Park at the PLL's angle θ^\hat\theta, the division by ∣v∣|v|, the PI, + ω0+\,\omega_0 and the integrator, whose angle goes back to Park; each wire carries its signal over the last 40 ms, and a block shows its equation when you focus it. Under it, over 300 ms with the change at 40 ms: the grid's angle and the PLL's less ω0t\omega_0 t, the two frequencies, and the angle error.

What it is

The grid's voltage, phase aa a cosine, is a vector of length VV at the grid's angle θ\theta in the αβ plane of the Clarke transformation. The PLL keeps its own angle, θ^\hat\theta, and takes the Park transformation at it, dd on phase aa's axis at θ^=0\hat\theta = 0 and qq 90∘90^\circ ahead:

vα+j vβ=Vejθ,vd+j vq=(vα+j vβ) e−jθ^=Vej(θ−θ^),vq=Vsin⁡(θ−θ^)v_\alpha + j\,v_\beta = V e^{j\theta}, \qquad v_d + j\,v_q = (v_\alpha + j\,v_\beta)\,e^{-j\hat\theta} = V e^{j(\theta - \hat\theta)}, \qquad v_q = V\sin(\theta - \hat\theta)
(1)

So vqv_q says how far the frame is behind the grid: positive when it lags, zero when it is on the vector, and then vd=Vv_d = V. Divided by the vector's length it is the angle error itself for small errors, e=vq/∣v∣=sin⁡(θ−θ^)≈θ−θ^e = v_q/|v| = \sin(\theta - \hat\theta) \approx \theta - \hat\theta. A PI controller turns that error into a correction of the frequency, and an integrator turns the frequency into the angle:

ω^=ω0+Kp e+Ki ⁣∫e dt,θ^=∫ω^ dt,ω0=2π⋅50 rad/s\hat\omega = \omega_0 + K_p\,e + K_i\!\int e\,dt, \qquad \hat\theta = \int \hat\omega\,dt, \qquad \omega_0 = 2\pi\cdot 50\ \text{rad/s}
(2)

The integrator does what the voltage-controlled oscillator does in an analogue PLL, and ω0\omega_0 fed forward means the PI only has to supply the difference. Dividing by ∣v∣|v| makes KpK_p (in 1/s) and KiK_i (in 1/s²) the same whatever the voltage, so a sag doesn't slow the loop; without it the gains are per volt, and a sag to half the voltage halves them.

Who writes it otherwise

Papers and tools differ in which axis they drive to zero and in what units their gains are. A paper with its PI acting on a voltage in volts has gains per volt: multiply them by the voltage they were written for to get this page's, Kp=kpVK_p = k_p V and, where the PI is written kp(1+sτ)/(sτ)k_p(1 + s\tau)/(s\tau), Ki=kpV/τK_i = k_p V/\tau.

WhoPhase aaDriven to zeroThe errorThe gainsTo get this page's
This pagecosineqqq/∣v∣q/|v|, radiansKpK_p, KiK_i
imperix TN103not statedqqnormalisedKp=2ζωcK_p = 2\zeta\omega_c, Ki=ωc2K_i = \omega_c^2the same; its ωc\omega_c is ωn\omega_n here
TI SPRABT4Acosineqqqq in per unitKpK_p and TiT_i; a Tustin PI's B0B_0, B1B_1Ki=Kp/TiK_i = K_p/T_i; B0=Kp+KiT/2B_0 = K_p + K_i T/2, B1=−(Kp−KiT/2)B_1 = -(K_p - K_i T/2)
Chung; Egea-Alvarez and others; the UPC course's modelscosinedd (qd order)dd in voltsKpK_p and τ\tau, or kpk_p, kik_i per voltKp=kpVK_p = k_p V, Ki=kpV/τK_i = k_p V/\tau; their qq axis is dd here

Where it comes from

With e≈θ−θ^e \approx \theta - \hat\theta, (2) is linear. Write the PI and the integrator as one open loop L(s)L(s) from the error to θ^\hat\theta, and close it:

L(s)=Kps+Kis2,H(s)=θ^θ=Kps+Kis2+Kps+Ki,E(s)=θ−θ^θ=s2s2+Kps+KiL(s) = \frac{K_p s + K_i}{s^2}, \qquad H(s) = \frac{\hat\theta}{\theta} = \frac{K_p s + K_i}{s^2 + K_p s + K_i}, \qquad E(s) = \frac{\theta - \hat\theta}{\theta} = \frac{s^2}{s^2 + K_p s + K_i}
(3)

The denominator is a second-order loop's, so the loop has a natural frequency and a damping, and the poles are where they put them:

ωn=Ki,ζ=Kp2Ki,s=−ζωn±j ωn1−ζ2\omega_n = \sqrt{K_i}, \qquad \zeta = \frac{K_p}{2\sqrt{K_i}}, \qquad s = -\zeta\omega_n \pm j\,\omega_n\sqrt{1 - \zeta^2}
(4)

At the figure's gains, Kp=180K_p = 180 and Ki=16,200K_i = 16{,}200, that is ωn=127.3\omega_n = 127.3 rad/s and ζ=0.707\zeta = 0.707, the poles at −90±90j-90 \pm 90j. Move them below: ζ\zeta sets the angle of the poles from the real axis (cos⁡φ=ζ\cos\varphi = \zeta), and so the shape of the answer; ωn\omega_n sets their distance from the origin, and so only how fast it happens.

The closed loop's poles (×) and the PI's zero (○) on the s-plane, the dashed circle of radius ωn\omega_n; beside them the angle error after a phase jump of 1 with the ±2 % band, how far it swings back and when it is in the band for good. Dashed, the same poles without the zero.

H(s)H(s) also has a zero, at s=−Ki/Kp=−ωn/(2ζ)s = -K_i/K_p = -\omega_n/(2\zeta), which a textbook's second-order system doesn't. It makes the PLL's angle overshoot more: at ζ=1/2\zeta = 1/\sqrt2 the error after a phase jump Δφ\Delta\varphi swings 20.8 % of the jump the other way, not the 4.3 % the same poles give without it. For ζ<1\zeta < 1 the error is

e(t)=Δφ e−ζωnt(cos⁡ωdt−ζωnωdsin⁡ωdt),ωd=ωn1−ζ2e(t) = \Delta\varphi\,e^{-\zeta\omega_n t}\left(\cos\omega_d t - \frac{\zeta\omega_n}{\omega_d}\sin\omega_d t\right), \qquad \omega_d = \omega_n\sqrt{1 - \zeta^2}
(5)

How long it takes to stay within 2 % of the jump has no formula: it is the last time ∣e∣|e| leaves the band, N(ζ)/ωnN(\zeta)/\omega_n, with NN found by scanning (5). The usual rule, 4/(ζωn)4/(\zeta\omega_n), reads the envelope e−ζωnte^{-\zeta\omega_n t} and is 15.6 % long at ζ=0.707\zeta = 0.707 and 26 % short at ζ=1\zeta = 1, because above about 0.7 the slow part of the answer is no longer the envelope. NN also jumps where a lobe of the swing drops inside the band: from 6.39 at ζ=0.62\zeta = 0.62 to 4.78 at 0.63. So 1/21/\sqrt2 sits just on the good side of a cliff, a better reason for it than habit.

By damping, with ωn=1\omega_n = 1: the time to stay within 2 % of a jump, the envelope rule beside it, the swing, the phase margin and the −3 dB bandwidth, all computed from (3) to (6).
ζ\zetaNN, 2 %4/ζ4/\zetaSwing backPhase margin−3 dB / ωn\omega_n
0.57.518.0029.8 %51.8°1.82
0.66.886.6724.9 %59.2°1.93
0.7074.895.6620.8 %65.5°2.06
0.85.055.0018.0 %69.9°2.18
1.05.394.0013.5 %76.3°2.48
1.55.622.677.6 %83.7°3.33
2.05.052.004.8 %86.4°4.25

What the loop leaves for good follows from E(s)E(s) and the final-value theorem, e(∞)=lim⁡s→0s E(s) θ(s)e(\infty) = \lim_{s\to0} s\,E(s)\,\theta(s). The two integrators (the PI's and θ^\hat\theta's) cancel the 1/s1/s of a jump and the 1/s21/s^2 of a frequency step; a ramp of RR Hz/s, 2πR/s32\pi R/s^3, is one too many:

The gridθ(s)\theta(s)Left for good, with KiK_iWith Ki=0K_i = 0
A phase jump Δφ\Delta\varphiΔφ/s\Delta\varphi/s00
A frequency step Δf\Delta f2πΔf/s22\pi\Delta f/s^20sin⁡−1(2πΔf/Kp)\sin^{-1}(2\pi\Delta f/K_p): 4.00° for 2 Hz at Kp=180K_p = 180
A frequency ramp of RR Hz/s2πR/s32\pi R/s^32πR/Ki2\pi R/K_i: 0.0222° for 1 Hz/sgrows without end

A grid's ramp of a few hertz a second is slow for any sensible PLL: 0.089° at 4 Hz/s with the figure's gains, 0.45° with Ki=3,200K_i = 3{,}200. The frequency estimate has no lag at all; only the angle trails. Ruderman and others feed a frequency estimate forward into the loop so that even a ramp leaves nothing (Further reading).

The loop in the frequency domain

Three numbers say how fast and how safe the loop is. The crossover ωc\omega_c, where ∣L∣=1|L| = 1; the phase margin, how far the phase of LL is from −180∘-180^\circ there; and the closed loop's −3 dB bandwidth, how far up θ^\hat\theta still follows θ\theta:

ωc=12(Kp2+Kp4+4Ki2),PM=tan⁡−1Kp ωcKi,ω−3 dB=ωn1+2ζ2+(1+2ζ2)2+1\omega_c = \sqrt{\tfrac{1}{2}\big(K_p^2 + \sqrt{K_p^4 + 4K_i^2}\big)}, \qquad \text{PM} = \tan^{-1}\frac{K_p\,\omega_c}{K_i}, \qquad \omega_{-3\,\text{dB}} = \omega_n\sqrt{1 + 2\zeta^2 + \sqrt{(1 + 2\zeta^2)^2 + 1}}
(6)

At the figure's gains: ωc=197.8\omega_c = 197.8 rad/s (31.5 Hz), a margin of 65.5°, and a −3 dB bandwidth of 262.0 rad/s, 41.7 Hz: 2.06 times ωn\omega_n, not ωn\omega_n itself. A real loop also has a lag in it, a sampling delay or a filter, 1/(τs+1)1/(\tau s + 1), which takes tan⁡−1(ωcτ)\tan^{-1}(\omega_c\tau) off the margin: 63.8° at τ=150\tau = 150 µs, 48.8° at 1.5 ms.

The open loop's gain and phase from 1 Hz to 10 kHz with a delay τ\tau in it, for the page's gains, the course's and the symmetrical optimum for that delay; the crossover marked through both, the margin in red as the gap to −180∘-180^\circ.

One rule for everything a dirty grid carries

Anything in the voltage besides the positive sequence turns at its own speed, and in the PLL's frame it is a vector turning at the difference, Δω\Delta\omega. Its size aa (per unit of the positive sequence) pulls the vector's angle back and forth by aa radians at Δω\Delta\omega, and the loop passes that on as it passes any angle, by ∣H(jΔω)∣|H(j\Delta\omega)|:

θ^ ripples by ± a ∣H(jΔω)∣ rad,f^ by ± a ∣H(jΔω)∣ Δω2π Hz\hat\theta \text{ ripples by } \pm\,a\,|H(j\Delta\omega)| \text{ rad}, \qquad \hat f \text{ by } \pm\,a\,|H(j\Delta\omega)|\,\frac{\Delta\omega}{2\pi} \text{ Hz}
(7)

A negative sequence turns backward, so it is 2ω2\omega away: at the figure's gains ∣H(j2ω)∣=0.289|H(j2\omega)| = 0.289, and 0.1 pu shakes the angle by ±1.66° and the frequency by ±2.89 Hz at 100 Hz. The 5th harmonic turns backward at five times the speed and the 7th forward at seven, so both are 6ω6\omega away, at 300 Hz in the PLL's frame, and they add as ∣h7−h5∣|h_7 - h_5|: 5 % of either alone leaves ±0.274° (∣H(j6ω)∣=0.096|H(j6\omega)| = 0.096), 5 % of both cancels when each sits at its multiple of the fundamental's angle, and 5 % with 3 % leaves ±0.110°. An offset oo on one phase's measurement is a still vector of 23o\tfrac{2}{3}o, ω\omega away: 0.1 pu leaves ±2.25° (∣H(jω)∣=0.588|H(j\omega)| = 0.588). These are the three disturbances Chung's paper derives one by one; (7) is all of them.

Choosing the gains

From a settling time and a damping. Choose ζ\zeta (the swing you accept, the margin you need) and the time tst_s to stay within 2 % of a jump. Then

ωn=N(ζ)ts,Kp=2ζωn,Ki=ωn2,N(1/2)=4.893\omega_n = \frac{N(\zeta)}{t_s}, \qquad K_p = 2\zeta\omega_n, \qquad K_i = \omega_n^2, \qquad N(1/\sqrt2) = 4.893
(8)

For 40 ms at 1/21/\sqrt2 that is Kp=173.0K_p = 173.0 and Ki=14,966K_i = 14{,}966, and the simulated loop is back within 2 % after 40.0 ms, the sine in ee costing almost nothing at 40°. The rule of thumb Kp=8/tsK_p = 8/t_s, Ki=16/(ζts)2K_i = 16/(\zeta t_s)^2 gives 200 and 20,000 and a loop that settles in 34.4 ms, early by the 15.6 % the envelope rule overstates. TI's application note designs from the envelope too, so its loop asked for 30 ms to within 5 % is there after 27.3 ms.

By the symmetrical optimum, when the loop has a delay. With a lag τ\tau in the loop, L(s)=(Kps+Ki)/(s2(τs+1))L(s) = (K_p s + K_i)/(s^2(\tau s + 1)) has a phase that rises from −180∘-180^\circ after the PI's zero and falls again after 1/τ1/\tau. The optimum puts the crossover at the top of that hump, the geometric mean of the zero and 1/τ1/\tau, spaced by a factor aa each side:

Kp=1aτ,Ki=1a3τ2,ωc=1aτ,PM=tan⁡−1a−tan⁡−11aK_p = \frac{1}{a\tau}, \qquad K_i = \frac{1}{a^3\tau^2}, \qquad \omega_c = \frac{1}{a\tau}, \qquad \text{PM} = \tan^{-1}a - \tan^{-1}\frac{1}{a}
(9)

At a=1+2a = 1 + \sqrt2 the margin is 45° at any τ\tau; a=3a = 3 gives 53.1° and a triple pole. It is the fastest loop the delay allows: with τ=150\tau = 150 µs (1.5 samples at 10 kHz) Kp=2,761K_p = 2{,}761, Ki=3,158,569K_i = 3{,}158{,}569, a crossover of 439 Hz; with 1.5 ms, Kp=276K_p = 276 and Ki=31,586K_i = 31{,}586. On a clean laboratory grid that is fine. On a real one the same loop passes unbalance almost whole, ±6.3° for 0.1 pu, so the optimum says how fast the delay lets the loop be, not how fast the grid lets it be.

That is the trade every PLL makes, and why the settling time can't be asked for freely: a faster loop passes more of what the grid carries.

At ζ=1/2\zeta = 1/\sqrt2, against ωn\omega_n: the time back within 2 % of a jump (black, falling) and the angle ripple a negative sequence leaves (red, rising), the chosen loop marked on both; beside them, that loop's error over 100 ms after a 20° jump, the ±2 % band shaded.
Gains in use, in this page's units, and what each loop does: within 2 % of a jump by the linear model, the phase margin, the −3 dB bandwidth and the angle ripple 0.1 pu of negative sequence leaves.
WhoseKpK_p, 1/sKiK_i, 1/s²ωn\omega_n, rad/s (Hz)ζ\zeta2 %, msMargin−3 dB, Hz0.1 pu unbalance
This page's default180.016,200127.3 (20.3)0.70738.465.5°41.7±1.66°
imperix, ωn=2π⋅30\omega_n = 2\pi\cdot 30266.635,531188.5 (30.0)0.70726.065.5°61.7±2.47°
TI, 30 ms to 5 % at ζ=0.7\zeta = 0.7222.225,181158.7 (25.3)0.70030.865.2°51.7±2.06°
MathWorks' PLL (3ph) block180.03,20056.6 (9.0)1.59198.384.4°31.5±1.59°
The course's, ωn=2π⋅80\omega_n = 2\pi\cdot 80710.9252,662502.7 (80.0)0.7079.765.5°164.7±6.27°

When the grid isn't clean: the DDSRF-PLL and the DSOGI-PLL

A fault on one phase is where (7) hurts. Phase aa falling to zero with bb and cc whole is, by symmetrical components, 23\tfrac{2}{3} of positive sequence and 13\tfrac{1}{3} of negative (and a zero sequence a three-wire converter never sees). The vector's own angle then swings ±30° twice a cycle, and a plain SRF-PLL with the figure's gains follows 8.28° of it for good. Lowering the bandwidth only shrinks the ripple. The PLLs built for this separate the sequences first and lock on the positive one.

The DDSRF-PLL (decoupled double synchronous reference frame) takes Park at +θ^+\hat\theta and at −θ^-\hat\theta. In the positive frame the negative sequence is a vector turning at −2ω-2\omega, in the negative frame the positive one turns at +2ω+2\omega; each frame subtracts the other's filtered sequence turned by 2θ^2\hat\theta, and a low-pass at ωf=ω0/2\omega_f = \omega_0/\sqrt2 gives each sequence's size:

v+∗=vαβ e−jθ^−vˉ− e−j2θ^,vˉ+=ωfs+ωf v+∗v−∗=vαβ e+jθ^−vˉ+ e+j2θ^,vˉ−=ωfs+ωf v−∗\begin{aligned} v^{+*} &= v_{\alpha\beta}\,e^{-j\hat\theta} - \bar v^{-}\,e^{-j2\hat\theta}, & \bar v^{+} &= \frac{\omega_f}{s + \omega_f}\,v^{+*} \\ v^{-*} &= v_{\alpha\beta}\,e^{+j\hat\theta} - \bar v^{+}\,e^{+j2\hat\theta}, & \bar v^{-} &= \frac{\omega_f}{s + \omega_f}\,v^{-*} \end{aligned}
(10)

and the PI is given e=q+∗/∣v+∗∣e = q^{+*}/|v^{+*}|, the decoupled positive frame's qq. In parts, d+∗=d+−dˉ−cos⁡2θ^−qˉ−sin⁡2θ^d^{+*} = d^{+} - \bar d^{-}\cos 2\hat\theta - \bar q^{-}\sin 2\hat\theta and q+∗=q++dˉ−sin⁡2θ^−qˉ−cos⁡2θ^q^{+*} = q^{+} + \bar d^{-}\sin 2\hat\theta - \bar q^{-}\cos 2\hat\theta, and the negative frame's the same with the signs of the angle turned.

The DSOGI-PLL (double second-order generalised integrator) filters vαv_\alpha and vβv_\beta each through a SOGI tuned to the PLL's own ω^\hat\omega, which gives the signal (v′v') and a copy 90∘90^\circ behind it (qv′qv'); the positive sequence is then a sum:

v′v=kω^ss2+kω^s+ω^2,qv′v=kω^2s2+kω^s+ω^2,vα+=12(vα′−qvβ′),vβ+=12(qvα′+vβ′)\frac{v'}{v} = \frac{k\hat\omega s}{s^2 + k\hat\omega s + \hat\omega^2}, \quad \frac{qv'}{v} = \frac{k\hat\omega^2}{s^2 + k\hat\omega s + \hat\omega^2}, \qquad v^+_\alpha = \tfrac12(v'_\alpha - qv'_\beta), \quad v^+_\beta = \tfrac12(qv'_\alpha + v'_\beta)
(11)

with k=2k = \sqrt2, and the PI is given q/∣v∣q/|v| of Park at θ^\hat\theta on v+v^+. Here are the three with the same PI on one fault.

Phase aa falls at 40 ms, bb and cc whole: the angle error and the frequency of the SRF-PLL (red), the DDSRF-PLL (teal) and the DSOGI-PLL (blue), all three with Kp=180K_p = 180, Ki=16,200K_i = 16{,}200, integrated every 10 µs; 5 % of 5th on top if you switch it on.
The fault in the figure, from 40 ms, the end read over the last 20 ms.
Phase aa to 0Largest errorLeft at the endWithin 1° afterFrequency at the endWith 5 % of 5th
SRF-PLL13.04°±8.28°never±14.46 Hz±7.84°, ±15.97 Hz
DDSRF-PLL6.53°0.000°16.5 ms±0.000 Hz±0.40°, ±2.07 Hz
DSOGI-PLL4.19°±0.007°57.6 ms±0.012 Hz±0.05°, ±0.26 Hz

The two are one filter. Held at ω\omega, the DDSRF's two low-passes seen from the stationary frame have the characteristic polynomial s2+2ωfs+ω2s^2 + 2\omega_f s + \omega^2, the SOGI's s2+kωs+ω2s^2 + k\omega s + \omega^2: with ωf=ω/2\omega_f = \omega/\sqrt2 and k=2k = \sqrt2 they are the same, poles at −222±222j-222 \pm 222j, a time constant of 4.5 ms. What differs is what the PI is given. The DDSRF-PLL locks on the decoupled signal before its filter, so it is quicker (16.5 ms to within 1°) and lets the 5th through; the DSOGI-PLL locks on the filtered one, which passes the 5th at 0.113 and the 7th at 0.115 of their size, so it is slower (57.6 ms) and cleaner.

These are two of many. Golestan, Guerrero and Vasquez sort the advanced three-phase PLLs by the filter they add before or inside the loop (moving-average, notch, complex-coefficient, delayed signal cancellation, the DDSRF and the DSOGI) and show that several are the same system written two ways. imperix's MSOGI-PLL adds a SOGI per harmonic.

Large jumps. sin⁡(θ−θ^)\sin(\theta - \hat\theta) is small near 180∘180^\circ as well as near 0∘0^\circ, so a jump close to 180∘180^\circ starts slowly: back within 2° after 34.1 ms for 40°, 40.9 ms for 120°, 51.0 ms for 175°. Taking the error as the angle itself, atan2⁡(q,d)\operatorname{atan2}(q, d), removes that: 34.0, 38.9, 40.0 ms.

The loop a microcontroller runs

A controller runs (2) once every sample TT. The plainest way is forward Euler for both integrals, each new value from the old one and its rate:

ek=qk∣vk∣,ω^k=ω0+Kpek+Ik,Ik+1=Ik+KiTek,θ^k+1=θ^k+Tω^k (wrapped)e_k = \frac{q_k}{|v_k|}, \qquad \hat\omega_k = \omega_0 + K_p e_k + I_k, \qquad I_{k+1} = I_k + K_i T e_k, \qquad \hat\theta_{k+1} = \hat\theta_k + T\hat\omega_k \ (\text{wrapped})
(12)

It puts the poles at z=1+sTz = 1 + sT, the continuous poles stretched along a line from z=1z = 1 instead of bent onto esTe^{sT}, so the loop is stable while T<Kp/KiT < K_p/K_i for ζ≤1\zeta \le 1: 11.11 ms at the figure's gains, 2.81 ms at the course's. TI's note writes the PI by Tustin instead, uk=uk−1+B0ek+B1ek−1u_k = u_{k-1} + B_0 e_k + B_1 e_{k-1} with B0=Kp+KiT/2B_0 = K_p + K_i T/2 and B1=−(Kp−KiT/2)B_1 = -(K_p - K_i T/2), which keeps the damping far better, stable while T<2/KpT < 2/K_p and T<2Kp/KiT < 2K_p/K_i.

The sampled loop on the z-plane near z=1z = 1: forward Euler's poles (blue) and the Tustin PI's (teal), the rings where the continuous poles land exactly, and the unit circle; beside them each one's error after a phase jump, sample by sample, over the continuous loop's (dashed).
What each method makes of ζ=0.707\zeta = 0.707, whose continuous loop swings back 20.8 %: the damping its poles behave as, ζ=−ln⁡∣z∣/ln⁡2∣z∣+arg⁡2z\zeta = -\ln|z|/\sqrt{\ln^2|z| + \arg^2 z}, and its swing.
GainsSampled atωnT\omega_n TForward Euler: as if ζ\zeta, swingTustin PI: as if ζ\zeta, swing
Kp 180, Ki 16,20010 kHz0.0130.704, 21.1 %0.707, 21.0 %
Kp 180, Ki 16,2001 kHz0.1270.672, 24.1 %0.707, 22.9 %
The course's10 kHz0.0500.694, 22.0 %0.707, 21.6 %
The course's1 kHz0.5030.520, 39.1 %0.701, 33.1 %

At 10 kHz the method hardly matters. A fast loop on a slow processor is where forward Euler eats the damping. Two more things the sampled loop needs: a low-pass on the frequency estimate (imperix suggests about 15 Hz) when something else uses it, since f^\hat f carries every ripple (7) gives it; and care with a SOGI, which forward Euler puts out of quadrature, so a forward-Euler DSOGI-PLL sits ωT/4\omega T/4 off the grid's angle for good, 0.450° at 10 kHz.

Try this

  1. Choose "By what you want" and ask for 40 ms at ζ = 0.71, the 40° jump left as it is. Then hold the 40 ms and drag ζ from 0.60 to 0.65. The gains become Kp=173.0K_p = 173.0 and Ki=14,966K_i = 14{,}966, and the error is back within 2 % (0.8°) after 40.0 ms. Dragging ζ\zeta, the gains jump between 0.62 and 0.63: the second swing drops inside the band, and the same settling time needs a slower loop.
  2. Set the jump to 0 and the 5th harmonic to 0.05 pu; then the 7th to 0.05 pu too. A ripple of ±0.27° at 300 Hz in the PLL's frame, and with the 7th it is gone: both are 6ω6\omega away and cancel.
  3. Back to clean, add 0.10 pu of unbalance; ask for 10 ms instead of 40; then press "A fault on phase a". ±1.66° and ±2.9 Hz at 100 Hz at the default gains, ±6.16° with the 10 ms loop. The fault turns the αβ wire's circle into an ellipse, and the default loop's angle shakes ±8.2° for good: the case the DDSRF and DSOGI were built for.
  4. A sag to 0.5 pu. Then set "The PI is given" to "q alone" and jump the phase by 20°. Divided by ∣v∣|v| the sag does nothing, at any depth. Given qq alone, the PI's gains fall with the voltage, ωn\omega_n to 90 rad/s and ζ\zeta to 0.50, and the jump takes 83.4 ms to settle instead of 38.3.

Worked examples

The figure's gains are Kp=180K_p = 180 /s and Ki=16,200K_i = 16{,}200 /s². By (4),

ωn=16200=127.3 rad/s (20.3 Hz),ζ=1802⋅127.3=0.707\omega_n = \sqrt{16200} = 127.3\ \text{rad/s}\ (20.3\ \text{Hz}), \qquad \zeta = \frac{180}{2 \cdot 127.3} = 0.707

the damping of 1/21/\sqrt2, a settling time to 2 % of N/ωn=4.893/127.3=38.4N/\omega_n = 4.893/127.3 = 38.4 ms, and a −3 dB bandwidth of 41.7 Hz. Now the grid's phase jumps by 40∘40^\circ. At that instant the error is the whole jump, e=sin⁡40∘=0.643e = \sin 40^\circ = 0.643, and the proportional part lifts the PLL's frequency at once by Kpe/2π=18.4K_p e/2\pi = 18.4 Hz, to 68.4 Hz, the highest it goes.

The simulated loop is within 2∘2^\circ after 34.1 ms, sooner than 38.4 ms, since 2° is 5 % of 40°. On the way the error crosses zero and swings to −8.42° at 17.5 ms after the jump. The linear model (5) swings to −8.32° at 17.5 ms: at 40° the sine in ee is 8 % short of the angle, and that is all the difference it makes.

Last, take KiK_i away and step the frequency by 2 Hz. The PLL ends at 52 Hz but an angle behind: 2π⋅2/180=0.06982\pi \cdot 2/180 = 0.0698 rad, 4.0°.

Design 1: back within 2 % of a jump in 40 ms

Take ζ=1/2\zeta = 1/\sqrt2, for which N=4.893N = 4.893. By (8), ωn=4.893/0.040=122.3\omega_n = 4.893/0.040 = 122.3 rad/s (19.5 Hz), Kp=2ζωn=173.0K_p = 2\zeta\omega_n = 173.0 /s and Ki=ωn2=14,966K_i = \omega_n^2 = 14{,}966 /s². By (6), the crossover is 190.1 rad/s, the margin 65.5° and the −3 dB bandwidth 40.1 Hz.

A 40° jump lifts the frequency estimate at once by Kpsin⁡40∘/2π=17.7K_p \sin 40^\circ/2\pi = 17.7 Hz; the error swings back 8.32° by (5) and 8.42° in the simulated loop, which is within 2 % (0.8°) after 40.0 ms. What it costs, by (7) and the final-value theorem: 0.1 pu of negative sequence leaves ±1.59° and ±2.78 Hz; 5 % of 5th ±0.26°; a ramp of 1 Hz/s 0.024°; a 2 Hz step peaks at 2.70° and goes back to zero.

Design 2: the course's PLL, 2π·80 rad/s on a 22 kV grid

The UPC course's parameters ("Parameters.m" in the folder Activity 2 on its page) ask for a PLL bandwidth of 2π⋅802\pi\cdot 80 rad/s at ζ=1/2\zeta = 1/\sqrt2, with the PI acting on a voltage in volts on a 22 kV grid, whose phase voltage peaks at 22,000⋅2/3=17,96322{,}000\cdot\sqrt2/\sqrt3 = 17{,}963 V. In the model's own units that is kp=2ζωn/V=0.03957k_p = 2\zeta\omega_n/V = 0.03957 and τ=2ζ/ωn=2.813\tau = 2\zeta/\omega_n = 2.813 ms. In this page's: ωn=502.7\omega_n = 502.7 rad/s, Kp=710.9K_p = 710.9 /s and Ki=252,662K_i = 252{,}662 /s².

It is back within 2 % of a jump in 9.74 ms, four times quicker than the figure's default, with the same 65.5° of margin and a −3 dB bandwidth of 164.7 Hz. The price is in (7): ∣H(j2ω)∣=1.095|H(j2\omega)| = 1.095, above 1, so 0.1 pu of negative sequence shakes the angle by ±6.27° and the frequency by ±10.9 Hz, against ±1.66° and ±2.9 Hz at the default. Forward Euler is stable below T=Kp/Ki=2.81T = K_p/K_i = 2.81 ms, and at the model's 20 µs step ωnT\omega_n T is 0.010. A design for a clean, stiff grid, which is the grid the course's model has.

Mistakes people make

  1. The mistake

    Copying a paper's KpK_p and KiK_i into a loop whose error is divided by ∣v∣|v|.

    Why it's wrong

    A paper whose PI acts on a voltage in volts has gains per volt: Chung's 1.43 at 311 V is 444 /s here.

    The right one

    Multiply by the peak voltage the gains were written for (Kp=kpVK_p = k_p V), or check which error the paper's PI is given before using its numbers.

  2. The mistake

    Calling ωn\omega_n the PLL's bandwidth.

    Why it's wrong

    At ζ=0.707\zeta = 0.707 the −3 dB bandwidth is 2.06 times ωn\omega_n: the figure's "20 Hz" loop passes up to 41.7 Hz.

    The right one

    Say which: ωn\omega_n, the crossover ωc\omega_c or the −3 dB bandwidth, each from (6).

  3. The mistake

    Expecting 4.3 % of overshoot at ζ=0.707\zeta = 0.707.

    Why it's wrong

    That is a second-order loop without a zero. The PI's zero at −ωn/(2ζ)-\omega_n/(2\zeta) makes the PLL's error swing back 20.8 %.

    The right one

    Read the swing from (5) or the table by damping.

  4. The mistake

    Taking 4/(ζωn)4/(\zeta\omega_n) as the settling time at any damping.

    Why it's wrong

    It is the envelope's: 15.6 % long at 0.707 and 26 % short at ζ=1\zeta = 1.

    The right one

    Use N(ζ)/ωnN(\zeta)/\omega_n, from the table or by scanning (5).

  5. The mistake

    Raising the gains to get rid of a 100 Hz ripple.

    Why it's wrong

    The integral removes a steady error, not one at 100 Hz, and a faster loop passes more of it: ±1.66° at the default, ±6.27° at 2π·80.

    The right one

    Lower the bandwidth, or separate the sequences first (DDSRF, DSOGI).

  6. The mistake

    Looking for the 5th and the 7th at 250 and 350 Hz in the PLL's frequency.

    Why it's wrong

    In the PLL's frame both are 6ω6\omega away, at 300 Hz, and equal ones cancel.

    The right one

    Expect one ripple at 6ω6\omega of size ∣h7−h5∣ ∣H(j6ω)∣|h_7 - h_5|\,|H(j6\omega)|.

  7. The mistake

    Expecting a balanced sag to throw the PLL off.

    Why it's wrong

    With the error divided by ∣v∣|v| it changes nothing at any depth; without the division the loop only gets slower and less damped.

    The right one

    Test it with unbalance or a phase jump during the sag, which is what a real fault brings.

  8. The mistake

    Running a fast loop by forward Euler at a slow sampling rate.

    Why it's wrong

    It is stable only while T<Kp/KiT < K_p/K_i, and at ωnT=0.5\omega_n T = 0.5 a loop designed for 0.707 already behaves as 0.52.

    The right one

    Sample ten times faster than ωn/2π\omega_n/2\pi at least, or write the PI by Tustin.

  9. The mistake

    Mixing conventions: a sine for phase aa, or dd driven to zero, with this page's equations.

    Why it's wrong

    Either turns the angle by 90∘90^\circ, and the PLL locks a quarter of a cycle off.

    The right one

    Check against the conventions table which axis the source drives to zero and how its phase aa is written.

  10. The mistake

    Plotting the angle error as θ−θ^\theta - \hat\theta without wrapping it.

    Why it's wrong

    Both angles wrap at different moments, so the difference spikes by 360° once a cycle.

    The right one

    Wrap the difference into (−180∘,180∘](-180^\circ, 180^\circ], or take it as atan2⁡(q,d)\operatorname{atan2}(q, d).

The same in Python

import numpy as np

zeta, ts, dt = 1 / np.sqrt(2), 0.040, 1e-4          # design 1: back within 2 % of a jump in 40 ms
x = np.arange(0, 20, 1e-5)                          # time in units of 1/ωn
wd = np.sqrt(1 - zeta**2)
r = np.exp(-zeta * x) * (np.cos(wd * x) - zeta / wd * np.sin(wd * x))  # (5) with ωn = 1
N = x[np.nonzero(np.abs(r) > 0.02)[0][-1] + 1]      # the last time it is outside ±2 %
kp, ki = 2 * zeta * N / ts, (N / ts) ** 2           # (8)
print(f"N = {N:.3f}, Kp = {kp:.1f} /s, Ki = {ki:,.0f} /s²")

t = np.arange(0, 0.3 + dt / 2, dt)
v = np.exp(1j * (2 * np.pi * 50 * t + np.radians(40) * (t >= 0.04)))  # vα + jvβ, a 40° jump at 40 ms
th_hat, integral, err = 0.0, 0.0, np.empty_like(t)
for i in range(len(t)):
    dq = v[i] * np.exp(-1j * th_hat)                # Park at the PLL's angle
    err[i] = np.angle(dq)                           # θ − θ̂
    e = dq.imag / abs(dq)                           # q/|v|, what the PI is given
    th_hat += (2 * np.pi * 50 + kp * e + integral) * dt
    integral += ki * e * dt

after = np.abs(err - err[-1])[t >= 0.04]
late = np.nonzero(after > 0.02 * after.max())[0][-1] + 1
print(f"within 2 % ({np.degrees(0.02 * after.max()):.1f}°) after {late * dt * 1000:.1f} ms, {-np.degrees(err.min()):.2f}° the other way")

It prints:

N = 4.893, Kp = 173.0 /s, Ki = 14,966 /s²
within 2 % (0.8°) after 40.0 ms, 8.42° the other way

Worked design 1 from the settling time to the gains, then the loop run as the figure runs it: NN, KpK_p and KiK_i from (5) and (8), and the 40° jump back within 2 % after 40.0 ms, swinging 8.42° the other way on the way.

Questions people ask

What does SRF-PLL stand for, and what is it for?

Synchronous reference frame phase-locked loop. It finds the grid voltage's angle and frequency by turning a Park frame until the voltage has no qq component. A grid-following converter uses that angle for its own Park transformation, so its dd current is active power and its qq current reactive.

What is the transfer function of an SRF-PLL?

Linearised, from the grid's angle to the PLL's, H(s)=(Kps+Ki)/(s2+Kps+Ki)H(s) = (K_p s + K_i)/(s^2 + K_p s + K_i), (3): a second-order loop with ωn=Ki\omega_n = \sqrt{K_i}, ζ=Kp/(2Ki)\zeta = K_p/(2\sqrt{K_i}) and a zero at −Ki/Kp-K_i/K_p. The error is E(s)=1−H(s)E(s) = 1 - H(s).

How do I choose Kp and Ki?

Pick a damping (0.707 is usual) and the time to settle within 2 % of a jump, then ωn=N(ζ)/ts\omega_n = N(\zeta)/t_s, Kp=2ζωnK_p = 2\zeta\omega_n, Ki=ωn2K_i = \omega_n^2, (8). If the loop has a known delay, the symmetrical optimum (9) gives the fastest loop it allows. Then check what the result passes of unbalance and harmonics with (7).

What bandwidth should a grid PLL have?

The gains in use in the table above run from ωn=2π⋅9\omega_n = 2\pi\cdot 9 to 2π⋅802\pi\cdot 80 rad/s. Slower rides through unbalance and harmonics with little ripple; faster follows phase jumps sooner. Around 2π⋅202\pi\cdot 20 to 2π⋅302\pi\cdot 30 (−3 dB at 41 to 62 Hz) is a common middle for a plain SRF-PLL; behind a DDSRF or DSOGI it can be faster, since the unbalance no longer reaches it.

Why is q driven to zero, and why do some papers drive d?

It depends on where a paper puts its axes. With dd on phase aa's axis at θ^=0\hat\theta = 0 and phase aa a cosine, the frame is on the vector when q=0q = 0. Papers that write the Park matrix in qd order (Chung, the UPC course's models) have their qq axis where this page has dd, and drive their dd to zero: the same loop.

What is the difference between the SRF-PLL, the DDSRF-PLL and the DSOGI-PLL?

The same PI and integrator, given different errors. The SRF-PLL locks on the whole voltage vector, so a negative sequence makes it ripple at 2ω2\omega. The DDSRF-PLL locks on its positive frame with the negative sequence subtracted (10); the DSOGI-PLL on the positive sequence built from two SOGIs (11). The two filters are the same at ωf=ω/2\omega_f = \omega/\sqrt2 and k=2k = \sqrt2; the DDSRF-PLL is quicker, the DSOGI-PLL cleaner of harmonics.

Why does my PLL's frequency ripple at 100 Hz?

A negative sequence in the voltage: it is 2ω2\omega away from the positive sequence, so the PLL sees a ripple at 100 Hz on a 50 Hz grid, of size a ∣H(j2ω)∣a\,|H(j2\omega)| in angle and that times 2ω/2π2\omega/2\pi in hertz, (7). 0.1 pu at the figure's gains is ±2.9 Hz. A 50 Hz ripple instead is an offset in a measurement.

What does a PLL do during a voltage sag or a fault?

A balanced sag changes nothing if the error is divided by ∣v∣|v|, and slows the loop if it isn't. An unbalanced fault adds a negative sequence: a plain SRF-PLL then shakes at 2ω2\omega for as long as the fault lasts, by many degrees, while a DDSRF or DSOGI-PLL settles on the positive sequence. A fault often comes with a phase jump too, which every PLL follows at its own speed.

Does it work on a single phase?

Not as it is: Park needs two axes. A single-phase PLL makes the second one, most often with a SOGI (its qv′qv' is the signal 90∘90^\circ behind), then runs the same loop.

The loop is (2) as blocks: Clarke, Park at the fed-back angle, the division by ∣v∣|v|, a PI, + 2π⋅50+\,2\pi\cdot 50 and an integrator wrapped to 2π2\pi. Check which axis the tool's Park block drives to zero and in what units its PI's gains are, using the conventions table; MathWorks' PLL (3ph) block defaulted to Kp=180K_p = 180 and Ki=3,200K_i = 3{,}200 with its own gain control, and imperix publishes Simulink and PLECS models of the SRF and DDSRF loops.

What does a grid-forming converter do instead of a PLL?

It sets its own angle and frequency, from its power (droop, a virtual machine's swing equation) rather than measuring the grid's, so it doesn't need a stiff grid to lock to. A grid-following converter with a PLL follows the grid and can lose step with it when the grid is weak; that interaction is one of the reasons grid-forming control is studied.

Where it's used

In every grid-following converter: solar and battery inverters, wind turbines' grid-side converters, STATCOMs and HVDC stations. The PLL's angle is the θ\theta of the converter's Park transformation, so idi_d sets the active power and iqi_q the reactive power. Its frequency feeds frequency measurement and protection, and a grid code's ride-through tests (phase jumps, frequency ramps, unbalanced faults) are tests of the PLL as much as of the converter. In weak grids the PLL's own dynamics interact with the grid's impedance, one of the reasons grid-forming control is studied as an alternative.

It belongs to two of my courses at UPC, and their pages are linked below. In Analysis and Control of Modern Power Electronics Dominated Power Systems, the folder Course site holds "PLL.pdf", Chung's paper in the IEE Proceedings listed under References, whose steady-state errors and three kinds of dirty grid are this page's table of errors and the cases of (7); "AMCPS_class3_vf.pdf", the third class's slides, which put the PLL between the voltage measurement and Park in a converter's control; and "Egea2011.pdf", the same design written in qd order with dd driven to zero (who writes it otherwise). The folder Weeks 2 to 4 holds "Model2_PLL.slx", the loop in Simulink on a 400 V grid with a 20° phase jump, its PI acting on −vd-v_d in volts and left at kp=1k_p = 1, ki=2.5k_i = 2.5 for you to tune. In this page's units that is Kp=327K_p = 327 /s and Ki=816K_i = 816 /s², ζ=5.7\zeta = 5.7: its poles are real, at −324 and −2.5 rad/s, so it takes the 20° jump within 2 % in 11 ms, as a loop with no integral would, while the error a frequency step leaves dies away over 0.4 s. The brief of Activity 1 in the same folder, "AMCPS___Activity_1__new_.pdf", asks for that jump, other gains and one phase changed; the folder Activity 0 is my report on the model; "Parameters.m" in Activity 2 is the course's own design, worked through as design 2; and Activity 3 sets a grid-following converter, which leans on its PLL, beside a grid-forming one.

In Control of Electrical Machines and Power Electronics the subject is a DC motor's speed and torque, controlled from Simulink on a TI LaunchPad whose processor, the F28379D, is a C2000: the family TI's PLL note under Further reading is written for. Its labs and my project, in the folders Labs and Project, build that controller for the board, where it runs one sample at a time: what the loop a microcontroller runs on this page does with the PLL's PI.

Further reading

References

  • S.-K. Chung, “A Phase Tracking System for Three Phase Utility Interface Inverters”, IEEE Transactions on Power Electronics, 15(3), 2000, pp. 431–438
  • S.-K. Chung, “Phase-locked loop for grid-connected three-phase power conversion systems”, IEE Proceedings – Electric Power Applications, 147(3), 2000, pp. 213–219
  • V. Kaura, V. Blasko, “Operation of a Phase Locked Loop System Under Distorted Utility Conditions”, IEEE Transactions on Industry Applications, 33(1), 1997, pp. 58–63
  • P. Rodríguez, J. Pou, J. Bergas, J. I. Candela, R. P. Burgos, D. Boroyevich, “Decoupled Double Synchronous Reference Frame PLL for Power Converters Control”, IEEE Transactions on Power Electronics, 22(2), 2007, pp. 584–592
  • P. Rodríguez, R. Teodorescu, I. Candela, A. V. Timbus, M. Liserre, F. Blaabjerg, “New Positive-sequence Voltage Detector for Grid Synchronization of Power Converters under Faulty Grid Conditions”, IEEE Power Electronics Specialists Conference (PESC), 2006
  • S. Golestan, J. M. Guerrero, J. C. Vasquez, “Three-Phase PLLs: A Review of Recent Advances”, IEEE Transactions on Power Electronics, 32(3), 2017, pp. 1894–1907
  • S. Golestan, M. Monfared, F. D. Freijedo, “Design-Oriented Study of Advanced Synchronous Reference Frame Phase-Locked Loops”, IEEE Transactions on Power Electronics, 28(2), 2013, pp. 765–778
  • P. Mao, M. Zhang, W. Zhang, “A Canonical Small-Signal Linearized Model and a Performance Evaluation of the SRF-PLL in Three Phase Grid Inverter System”, Journal of Power Electronics, 14(5), 2014, pp. 1057–1068
  • J. Steinkohl, X. Wang, P. Davari, F. Blaabjerg, “Analysis of linear Phase-Locked Loops in Grid connected Power Converters”, EPE '19, 2019
  • Ruderman, Brescia, Massenio, Cascella, Naso, “Robust Synchronous Reference Frame Phase-Locked Loop (PLL) with Feed-Forward Frequency Estimation”, IEEE Transactions on Control Systems Technology, 2026 (arXiv 2509.19111)
  • R. Teodorescu, M. Liserre, P. Rodríguez, Grid Converters for Photovoltaic and Wind Power Systems, Wiley-IEEE Press, 2011, chapter 8
  • A. Yazdani, R. Iravani, Voltage-Sourced Converters in Power Systems, Wiley-IEEE Press, 2010