Voltecx is in beta. The macOS build comes first; Windows and Linux packages are still being tested.Beta. macOS comes first; Windows and Linux are still in testing. What's new
Documentation

Phase-Locked Loop (single-phase) (pll)

Locks onto a single-phase signal and reports its frequency and phase.

pll

Component reference · 繁體中文

Group: Control · Kind: {"block":"pll","kind":"control"}

When to use it

Use it to sync an inverter or rectifier with the grid voltage, or to measure a frequency. Use Three-Phase SRF-PLL for a three-phase grid.

Pins

Pin Domain Meaning
in signal Signal to lock to, such as grid voltage
f signal Estimated frequency in hertz
theta signal Estimated phase in radians
locked signal 1 when locked, otherwise 0

Common parameters

  • f0: Normal frequency the loop starts at (Default: 50)
  • kp: Reaction to the phase error (Default: optional (off))
  • ki: Reaction to the phase error over time (Default: optional (off))
  • lockTol: Phase error that counts as locked (Default: 0.02)

Parameters

Key Unit Default Typical range Description
f0 Hz 50 Normal frequency the loop starts at
kp rad/s optional (off) Reaction to the phase error
ki rad/s² optional (off) Reaction to the phase error over time
fmin Hz optional (off) Lowest frequency the loop can follow
fmax Hz optional (off) Highest frequency the loop can follow
lockTol rad 0.02 Phase error that counts as locked

Parameter descriptions are in English in both languages.

Model

A second-order generalised integrator (SOGI, gain sqrt(2)), tuned to the tracked frequency, splits the input into an in-phase part v_alpha = Asin(phi) and a quadrature part v_beta = -Acos(phi). The phase error is e = (v_alphacos(theta) + v_betasin(theta))/A = sin(phi - theta), so the input amplitude does not matter. A PI controller drives the error to zero. The speed is w = wi + kpe, the integral part is d(wi)/dt = kie, both are held to the range 2pifmin to 2pifmax, and d(theta)/dt = w. The linearised loop is s^2 + kps + ki, with natural frequency sqrt(ki) and damping kp/(2sqrt(ki)). With the gains unset, wn = 2pi0.3f0 and the damping is 0.707, which settles a phase step in about six periods. The output f is the integral part, so a phase step does not kick it. The lock range is about kp rad/s, and from further away the loop pulls in slowly, up to fmin and fmax, which are f0/2 and 2f0 when unset. Locked becomes 1 once the phase error has stayed below lockTol for two periods. The SOGI uses the trapezoidal rule and is stable at any step.

Common mistakes

  • Keep the step well below one period and below 1/kp. At 50 Hz with the default gains, a step up to about 1 millisecond works, and a longer step makes the loop ring or lose lock.
  • A frequency outside fmin and fmax can never be reached, so the loop sits on the limit and locked stays 0. Set f0 near the expected frequency, and widen fmin and fmax for a source whose frequency varies, such as a generator during start-up.
  • Harmonics and a DC offset on the input show up as ripple on theta and f, because the SOGI reduces them but does not remove them. When the input is distorted, lower kp and ki, and accept a slower response.

Datasheet and sources

There is no datasheet. Set f0 to the nominal grid frequency, 50 or 60 Hz. The default gains follow phase jumps and frequency changes within a few cycles, as grid codes ask, and a lockTol of 0.02 radians, about 1 degree, suits grid synchronisation.

Example

Open the example with the command file.openExample and the name demo:pll.


Generated by cargo xtask reference from the usage texts and parameter specs. Do not edit by hand.