The software model for PLCs, as defined in the IEC 61131-3 standard, Programmable Controllers – Part 3: Programming Languages, consists of, at the top level, a configuration. The configuration defines the hardware structure and logic of the PLC system and contains resources (the PLC or PAC, for example), which are able to execute programs. These resources are controlled by tasks, which invoke the execution of software blocks that make up the PLC project. These software blocks are referred to as Program Organization Units.
IEC 61131-3 defines three types of program organization units (POUs) — programs, function blocks, and functions.
Programs are the highest level program organization units and can be written in any of the IEC 61131-3 programming languages. Each program is a network of functions and function blocks (see below) that controls the machine or process. Therefore, at least one program is required in any project.
Programs can read and write to other input or output variables and can communicate with other programs. And they are the only POUs that can declare global variables, which are made available across the project, and access paths, which allow data to be exchanged between configurations
Programs can be called (initiated) by tasks. Each time a program is called, if the values of the program are changed, the changes are retained the next time the program is called, even if it is called by another task.
The most common type of POU, function blocks are segments of reusable code that have internal memory and can return different outputs even when the same inputs are used. In other words, the results of a function block are conditional on the previous output of the function block or the current state of the process or action. An example of a function block is a PID control loop.
Function blocks can be called by programs or by other function blocks, and in some implementations of IEC 61131-3, they can be called by tasks. The memory that will capture and store the output must be allocated for each unique instance of the function block — a process sometimes referred to as instantiation, since it creates an “instance” of the function block.
A function can be thought of as a subprogram (often an equation) that has no internal memory, so it returns a value rather than an output. This means that any time a function is invoked (performed), if the same inputs are used, the same value will be returned, regardless of the number of times the function is used. Common examples of functions are ADD and SQRT (square root).
The IEC 61131-3 software model — with programs, function blocks, and functions for creating PLC projects — ensures efficient programming by making it possible to copy and reuse software blocks that have already been implemented and tested elsewhere or to identify and deactivate them for troubleshooting.
Leave a Reply
You must be logged in to post a comment.