| |
Device programming according to IEC 61131: Working with function blocks
According to the IEC 61131, program organization units (POUs) are the language elements of the PLC program. They are small and independent software units that contain program code. The name of a POU must be unique, i.e. it can be used only once within a project. The standard defines three different POU types: Programs, function blocks (FBs) and functions. |
| |
Parts of a POU
Each POU consists of two parts: The variable declaration part and the code body. In the declaration part, all used variables have to be declared. In our programming system MULTIPROG, the declaration part of each POU is realized as a variables grid. The declarations are not entered textually (as described in the standard) but they are entered into a special table (variables grid). This considerably simplifies the handling of declarations and avoids declaration errors. The instructions or code body part of a POU contains the instructions, programmed in the desired programming language (FBD, LD, IL, ST, SFC).
FBs: POUs with memory
Function blocks (FBs) are POUs with several input and output parameters and internal memory. The value returned by a function block depends on the current value of its internal memory. Within a function block, it is possible to call further function blocks and other functions, but not programs. Recursive calls are not allowed. Calling an FB in another POU is designated as instantiation. As function blocks always have an internal memory, the values for each call (instance) of the function block must be stored in a separate memory area. For this purpose, instance names are used. The instance name has to be declared in the variables declaration of the POU in which the function block is used.
FBs of different origins
The IEC 61131-3 defines several standard function blocks, such as bistable elements (e.g. SR and RS), edge detection function blocks (e.g. R_TRIG and F_TRIG), counters (e.g. CTU and CTD) or timer function blocks (e.g. TON and TOF). In addition, control manufacturers can provide further blocks and, of course, each user can program own FBs and reuse them in any other project. FBs are included into the programming system as libraries and they can be inserted into the code body in a comfortable way using the Edit Wizard. Download useful FBs for MULTIPROG - free of charge
On the following pages you find the descriptions of several useful function blocks. These blocks can be downloaded for free and used in the programming system MULTIPROG. |
| |
How to use the downloaded function blocks in MULTIPROG
After having downloaded the archive file containing the zipped FBs to your hard disk, perform the following steps to use the blocks in MULTIPROG:
- Unzip the archive file to the folder
[MULTIPROG_InstallationDir]\MULTIPROG\Libraries. The archive consists of a project file (*.mwt) and a subfolder with the same name.
- In MULTIPROG, open the project in which you want to use the function blocks.
- In the project tree, right click on the folder 'Libraries' and select the context menu item 'Insert. > User Library' (see figure below).
The new library is now displayed in the project tree and the Edit Wizard contains a new group of the same name for selecting and inserting the FBs into a code body. |