4.75 1 1 1 1 1 1 1 1 1 1 Rating 4.75 (4 Votes)

User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive

The electric power grid transmits power from a generator to the end user using Alternating Current (AC), which oscillates at a specific frequency (typically 50 Hz for Europe). A gap between power generation and loads causes the grid frequency imbalance. If demand is higher than supply, the frequency will fall, leading to brownouts and blackouts. If utilities generate more power than consumers are using, the frequency goes up, potentially damaging the grid or the electric devices plugged into it.

Recently, rapid fluctuations in the grid have increased due to the increasing penetration of highly variable renewable resources such as wind turbines and PV panels.

In this scenario, frequency primary control is a real-time power-adjustment (ramp up or down) made from generators in order to keep the grid at the restoring the network frequency nominal rate (50Hz-60Hz).

In this article I'd like to reproduce the Frequency Primary Regulation (FPR)  algorithm into a Codesys 3.5 (SP10 Patch 2) IDE and run it into a Raspberry Pi.

The concept of FPR is this:


 σ[%] = permanent speed drop (statism) = (Δf/fo) * (Pmax / ΔP)



Δf = fo - f actual  (f0=50Hz in Europe)

Pmax =max Power allocated for the FPR

fo = nominal frequency (50Hz in Europe)

ΔP= FRP power component (output from the FRP regulating function)


This is the base formula:

ΔP=(Δf/fo) * (Pm / σ[%])


but usually it's added by the following features:

DB: frequency dead band  (usually 10mHz --> 49.990 ÷ 50.010 Hz idle range)

Ramp: power increasing / decreasing slope (MW/min)

This is the Codesys code:

FPR Code


 This is the result in Codesys (webvisu):


This is a short demo:


 In stand of manually adjust the "Actual frequency", I've got it from 50hertz.com that share grid frequency data log.

Here an extract from May 2017 log file (sample clock is 1sec)




I've wrote a small code able to read frequency rate from the csv file and manage it with FPR subroutine. This is the result (webvisu interface)

   I wish my notes can be helpful to someone

 Feel free to contact me if you have any questions or comments!