Skip to content

3-Phase PLL ​

Synchronous-reference-frame phase-locked loop for a three-phase signal set (A, B, C). Each step it Park-transforms the inputs at its current angle, runs a PI controller on the q-component (divided by the d-q magnitude when Normalize is On) and integrates the resulting frequency. Outputs the tracked angle theta in [0, 2π) rad, the frequency in Hz, and the amplitude-invariant vd / vq. Theta uses the same cosine convention as the abc → dq0 block, so feeding that block the same signals with this theta gives d = peak amplitude and q = 0 once locked. The defaults (Kp = 178, Ki = 15800) give a natural frequency near 20 Hz with damping about 0.7. Use it to synchronise grid-following inverter controls, as a frequency meter, or to measure phase jumps.

Category: Continuous

How it works ​

The block is a synchronous-reference-frame PLL. Each time step it:

  1. Park-transforms the three inputs at its current angle θ (amplitude-invariant):
vd=23∑k=02xkcos(θ−k2π3),vq=−23∑k=02xksin(θ−k2π3)
  1. Forms the error e=vq/|v| with |v|=vd2+vq2 (Normalize On), or e=vq (Normalize Off).
  2. Runs a PI controller on the error to get the frequency deviation, Δω=Kpe+∫Kiedt. The integrator and Δω are both clamped to ±2πΔfmax.
  3. Outputs θ, f=(ωnom+Δω)/2π, vd and vq for this sample.
  4. Advances the angle: θ←θ+ωΔt, wrapped to [0,2π).

For a balanced set xk=Vcos⁡(φ−k2π/3) the q-component is vq=Vsin⁡(φ−θ). It is positive when the input leads the PLL, so the loop speeds up until θ=φ.

Angle convention ​

theta uses the same cosine convention as the abc → dq0 block. Feeding that block the PLL's inputs together with its theta gives d=Vpeak and q=0 once locked. This is the pairing a grid-following inverter control uses.

A voltage source set to a sine waveform produces Vsin⁡(ωt+φ)=Vcos⁡(ωt+φ−π/2). The PLL therefore locks at θ=ωt+φ−π/2, a quarter cycle behind the source's phase setting.

Tuning ​

With Normalize On, the small-signal loop is a second-order system whatever the input amplitude:

s2+Kps+Ki=0,ωn=Ki,ζ=Kp2Ki

The defaults Kp=178 and Ki=15800 give ωn≈126 rad/s (about 20 Hz) and ζ≈0.71. The loop settles within a few cycles of a phase jump.

  • To make the loop faster, raise Ki by the square of the speed-up and Kp in proportion to keep the damping.
  • A faster loop also passes more harmonics and unbalance into theta and freq.

With Normalize Off the error is in the input's units, so the effective gains scale with the input amplitude. Leave it On unless you are matching a specific reference design.

Notes ​

  • Unbalance. Negative-sequence voltage appears in vq as a ripple at twice the line frequency. A plain SRF-PLL passes part of that ripple into freq. Lower the gains if the frequency ripple matters.
  • Inputs from the electrical side. Voltages measured on the electrical network reach a control block one step late, and they read zero on the first step. With Normalize On a zero input gives zero error, so the loop simply holds the nominal frequency until a signal arrives.
  • Frequency limit. Δf max bounds both the integrator and the total deviation, so a long dropout does not wind the loop up. Set it to 0 to remove the clamp.

Ports ​

PortKindSignalNotes
in_aControl inputReal
in_bControl inputReal
in_cControl inputReal
thetaControl outputReal
freqControl outputReal
vdControl outputReal
vqControl outputReal

Parameters ​

ParameterTypeDefaultUnitsDescriptionID
f nominalNumber60Hz (also rad/s)Nominal frequency. The loop starts here at theta = 0, and the PI output is the deviation from it.frequency
KpNumber178—Proportional gain, in rad/s per unit of error. With Normalize On the error is sin(phase error), so the loop is amplitude-independent: natural frequency ωn = √Ki rad/s and damping ζ = Kp / (2√Ki).kp
KiNumber15800—Integral gain, in rad/s² per unit of error. Sets the natural frequency ωn = √Ki (rad/s); the default 15800 gives about 20 Hz.ki
Δf maxNumber10Hz (also rad/s)Largest allowed frequency deviation from nominal. Both the integrator and the total deviation are clamped to ± this value (anti-windup). 0 disables the clamp.freq_limit
NormalizeChoice: Off / OnOn—When On, the loop error is vq / |v| (|v| = √(vd² + vq²)), so the lock time does not depend on the input amplitude: 1 V and 100 kV lock identically. Off uses vq directly, so the effective gains scale with the amplitude.normalize