Kalman Filter Synchronization
Single-phase Kalman Filter Synchronization component in Schematic Editor. It outputs sine and cosine signals synchronized with the fundamental component of the input signal, together with the estimated amplitude and frequency.

Description
The Kalman Filter Grid Synchronization algorithm is based on three main blocks. The first one is a state observer that contains the model of the grid, driven by the error between the model output and the measured grid voltage. The second block is the Kalman Filter algorithm, which computes the optimum observer gains. The third block is a frequency identifier, which tunes the observer model to the fundamental frequency of the input signal.
The states of the grid model are the fundamental component of the grid voltage and its quadrature signal:
where A(k), ω(k) and θ(k) are the amplitude, angular frequency and phase of the fundamental component at the sampling instant tk. Note that x2 leads x1 by 90 degrees. The single-phase grid is modeled in discrete time as:
where the perturbation vector [γ1 γ2] models amplitude and phase variations of the signal (process noise, with covariance Q) and v(k) is the measurement noise (with covariance R). A state observer for this model is defined as:
where Kk is the observer gain computed by the Kalman Filter algorithm, which finds the optimum compromise between tracking speed and noise rejection defined by the Q and R covariances. The estimated amplitude of the fundamental component is obtained from the estimated states:
and the synchronization outputs are the estimated states (optionally normalized by A(k), see the Output normalized property).
Finally, the third block identifies the fundamental frequency, whose value tunes the observer model. The frequency identifier is based on the internal model principle, with the following state space representation:
where e(k) is the error between the reference input (the normalized synchronization signal generated by the observer) and the internal model output yω(k). The frequency error is evaluated as:
and the identified frequency is updated by the integrator:
The full derivation of the error identification and frequency update equations is detailed in [1].
Behavior and Features
The Kalman Filter Synchronization presents quick convergence and an accurate phase equivalence between the synchronization signals and the fundamental component of the input signal. The outputs are the filtered state estimates of the current simulation step, in phase with the input sample of the same step.
The Kalman gain converges very quickly to the optimum values: the gain tuning algorithm runs during the first ten nominal periods after the simulation start, where the nominal period is defined by the Grid Frequency property. After this window the gains are constant and the synchronization algorithm behaves like a state observer with optimum fixed gains. The state estimates start from zero, so the outputs ramp in within a few fundamental cycles; the frequency identification settles in approximately six nominal periods (for example, 0.1 s at 60 Hz). It is good practice to wait for this settling time before using the synchronization signals.
The internal gains of the frequency identification algorithm are automatically adjusted to the Grid Frequency property and to the selected execution rate, so the component keeps consistent dynamics over its whole nominal frequency range: the frequency identification always converges in the same number of nominal periods, and its stability does not depend on the chosen nominal frequency. Above 60 Hz the adjustment is partially relaxed to keep the f[Hz] output ripple low.
The algorithm behavior is independent of the input amplitude scale, so the component can be used directly in volt-scale, kilovolt-scale or per-unit models.
The identified frequency is limited to the range from 0.5 to 1.5 times the Grid Frequency property. If the input signal is lost, or the identified frequency reaches the range limits, the component automatically retunes the Kalman gains and restarts the frequency identifier from the nominal grid frequency once a valid input signal is detected again.
The grid model used by the observer contains the fundamental component only. Harmonics and measurement noise in the input signal are attenuated according to the filter bandwidth defined by the Q matrix gain and R matrix gain properties, but harmonics are not explicitly cancelled.
Ports
- Vgrid (in)
- Sinusoidal input of the single-phase system from which the phase, frequency and
amplitude are extracted. Any amplitude scale can be used (V, kV or per-unit).
- Supported types: real.
- Vector support: no.
- Sinusoidal input of the single-phase system from which the phase, frequency and
amplitude are extracted. Any amplitude scale can be used (V, kV or per-unit).
- sin(wt) (out)
- Sine of the estimated phase of the fundamental component, in phase with the input
signal fundamental. If Output normalized is unchecked, the output is scaled by
the estimated amplitude.
- Supported types: real.
- Vector support: no.
- Sine of the estimated phase of the fundamental component, in phase with the input
signal fundamental. If Output normalized is unchecked, the output is scaled by
the estimated amplitude.
- cos(wt) (out)
- Cosine of the estimated phase of the fundamental component: the quadrature signal,
leading the sin(wt) output by 90 degrees. If Output normalized is unchecked,
the output is scaled by the estimated amplitude.
- Supported types: real.
- Vector support: no.
- Cosine of the estimated phase of the fundamental component: the quadrature signal,
leading the sin(wt) output by 90 degrees. If Output normalized is unchecked,
the output is scaled by the estimated amplitude.
- f[Hz] (out)
- Identified frequency (Hz) of the single-phase input system.
- Supported types: real.
- Vector support: no.
- Identified frequency (Hz) of the single-phase input system.
- Amplitude (out)
- Estimated peak amplitude of the fundamental component of the input signal,
.
- Supported types: real.
- Vector support: no.
- Estimated peak amplitude of the fundamental component of the input signal,
.
Properties
- Q matrix gain
-
Kalman Filter process noise covariance. Higher values make the filter track amplitude and phase changes of the input signal faster, at the cost of less noise and harmonic attenuation. Allowed range: 0.0001 to 100.
-
- R matrix gain
- Kalman Filter measurement noise covariance. Higher values give stronger noise and harmonic attenuation, at the cost of a slower response. The ratio between the Q and R gains defines the trade-off between tracking speed and disturbance rejection. Allowed range: greater than 0.01.
- Grid Frequency (Hz)
- Nominal grid frequency, used to initialize the frequency identification algorithm and to automatically adjust its internal gains. It also defines the allowed range of the identified frequency, from 0.5 to 1.5 times this value. The supported nominal frequency range extends from 2 Hz up to 1/(50·Ts), i.e. at least 50 execution steps per nominal period: with an execution rate of 100 µs, for example, the nominal frequency can be set up to 200 Hz. Note that the frequency identification settling time scales with the nominal period (approximately six nominal periods).
- Output normalized
-
If checked, the sin(wt) and cos(wt) outputs are unit signals. Otherwise they are scaled by the estimated amplitude of the input signal fundamental component.
-
- Execution rate
- Type in the desired signal processing execution rate. This value must be compatible with other signal processing components of the same circuit: the value must be a multiple of the fastest execution rate in the circuit. There can be up to four different execution rates. To specify the execution rate, you can use either decimal (e.g. 0.001) or exponential values (e.g. 1e-3) in seconds. Alternatively, you can type in ‘inherit’ in which case the component will be assigned execution rate based on the execution rate of the components it is receiving input from.
The Q matrix gain, R matrix gain and Grid Frequency properties accept values within the ranges given above. If a value outside its allowed range is entered, it is clamped to the nearest limit during the model compilation.
References
[1] Cardoso, R.; de Camargo, R.F.; Pinheiro, H.; Gründling, H.A.: "Kalman filter based synchronisation methods", IET Generation, Transmission & Distribution, 2008, 2, (4), p. 542-555, DOI: 10.1049/iet-gtd:20070281