Resources to Codesys

Codesys home page



Abbreviations:

  • LD = Ladder Diagram

  • FBD = Function Block Diagram

  • ST = Structured Text

  • CFC = Continuous Function Chart

  • SFC = Sequential Function Chart

  • FUN = Function

  • FB = Function Block


Videos

The videos are in Norwegian.

Introduksjon til PLS

Introduksjon inkl. LD-programmering

FBD med ferdiglaget FUN

FBD med ferdiglaget FB

  • Eksempel: Teller (counter). Video.

  • Eksempel: Sett/resett-vippe (S/R latch). Video.

CFC med egenutviklet FUN

  • Eksempel: Målesignalskalering. Video.

CFC med egenutviklet FB

  • Eksempel: Målesignalfilter: Video.

CFC med simulert reguleringssystem

  • Eksempel: Nivåregulering av vanntank vha. PI-regulator. Video 1. Video 2.

SFC

  • Eksempel: En tenkt statsvis «reaktor» (vanntank).Video 1. Video 2.

SFC koplet mot simulert prosess

  • Eksempel: En simulert satsvis «reaktor» (vanntank).Video.

Regulering av fysisk prosess med PLS

  • Eksempel: Temperaturregulering av fysisk luftvarmer med Wago CC100 PLS. Video 1. Video 2.

Eksport/import av POU fra/til et prosjekt


Function blocks

The following function blocks (*.export files) can be imported into a Codesys project with the meny Project -> Import (in Codesys).

Measurement scaling

meas_scaling.export




  • P is process value (e.g. celsius).

  • M is measurement signal value (e.g. milliampere).

  • (M1, P1) and (M2, P2) are two given measurement points.

P is calculated with the following linear formula:

P = a*M + b

where

a = (P2 – P1) / (M2 – M1)

b = P1 - a*M1



Measurement filter

meas_ewma_filter.export




  • y_mf is filtered measurement value.

  • y_m is nonfiltered (raw; noisy) measurement value.

  • tf [s] is filter time constant.

  • ts [s] is time step, or sampling interval.

y_mf is calculated as:

y_mf = (1 - a) * y_mf_prev + a * y_m

where a is the filter constant:

a = 1/Nf

where Nf is the filter length:

Nf = (tf/ts) + 1

At the first iteration, y_mf_prev is set equal to y_m, which makes the initial value of y_mf become equal to y_m.



Time delay

This function block implements a time delay, which can be used in e.g. a process simulator.

time_delay.export




  • y_delayed is the time delayed signal.

  • y_nondelayed is the signal to be time delayed.

  • delay_array_init is the initial value of y_delayed, i.e. its value before the time delay has elapsed.

  • t_delay [s] is the time delay.

  • ts [s] is time step, or sampling interval.

The time delay is implemented with an array of appropriate length, i.e. The time delay is between the input signal and the output signal from the array.

The time delay can be adjusted continuously (i.e. during the simulation).

By default, the maximum lenght of the array is N_delay_max = 100, i.e. The largest time delay that can be simulated is tf = 100 * ts. However, by setting N_delay_max to a larger value than 100 inside the function block, you can simulate a larger time delay. E.g. with N_delay_max = 500, you can simulate a time delay of up to 500 * ts.


Updated 6 April 2026 by Finn Aakre Haugen