In this article I'll describe how to run an IEC60870-5-104 server into a raspberry Pi3  (runtime Copalp Straton v9.1)

Straton for Rpi


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)


Recently, surfing on the web, I found for an industrial automation software house located in Italy: Axel Software.

I had the chance to test their IEC61131-3 development environment, Logic Lab: free , powerful and lightweight (installation package about 28MB)

LogoLogic Lab

I tested for the version Using it I get a good surprise: it permits to develop Arduino Mega 2560 and Raspberry Pi (B,B+,2) applications

A couple of years ago I wrote a tutorial about LSW MSW conversion to IEEE754 Float 32bit single precision

Now, I get the reverse need: starting from a given 32Bit Float calculate the LSW and MSW

This is normally made by storing the float into a %MD area (ex: %MD0) and by reading LSW at %MW0 and MSW at %MW1.

But I'm using a PLC development environment not equipped by Addressing area or Pointers: STRATON v.9.1



As knew, this is the structure of an IEEE754 32Bit Floating Point

 IEEE753 32Single Wiki

In this article I'll describe how to implement a Modbus RTU communication over RS485 line between Raspberry PI 2 ( Master) and a PC (Slave) using the IEC61131 Codesys IDE / runtime