Tag Archives: POU

PLC Programming Quickstart Guide : First 60 minutes of most PLC Programming Environments – Part 2

The PLC programming quickstart checklist is intended for a user to learn a new PLC programming environment. This applies to users who have programmed PLC’s before and also for someone new to PLC’s. Continuing from part 1 with checklist item 3:

3. Program logic

This is where the code is going to be.

IEC 61131-3 is the reference standard for PLC programming languages. In 2016, all major PLC platforms have some level of compliance to this standard. The standard does allow for partial compliance and requires manufacturers to declare specfics of their compliance with a statement. A quick introduction to the standard is available at the PLCopen site.

Per the standard, logic can be written as one of the following 3 types of program organization units (POU’s):

  • Programs
  • Functions
  • Function Blocks

PLCopen covers an overview of these types in a presentation here.

Adding these POU’s to the program usually occurs on the left side of the screen. There are some differences on how this is done in various environments.

In SoMachine which uses CODESYS V3, a POU is added by right clicking the Application directory and selecting Add Object>> POU. Subsequently, the option to add a Program, Function or Function Block pops up.

Adding a POU in SoMachine
Adding a POU in SoMachine
POU options in SoMachine
POU options in SoMachine

The POU types and options do vary in terminology and operation from platform to platform. In CCW, the Programs are added under the Program directory header. Function blocks are added under a separate header called User Defined Function Blocks.

Adding a Function Block in CCW.
Adding a Function Block in CCW.

When adding a program, the user is usually prompted to define the language chosen for that POU. When playing with a new environment, here is where you will find out the languages supported ( other than in the literature).

It would be advisable to select the different languages and test drive them. At the very least, select the language you will use and play around with the development environment. A later part will cover the specific items to look for in the language chosen.

Some questions to ask, that does vary from platform to platform is:

  • Can a program call another program?
  • When a function block is updated, does it automatically update every instance?
  • Can program execution order be arranged?

The final question takes us to checklist item 4…

4. Task Configuration

The importance of a ‘task’ is that it gives the PLC programmer control over what parts of the code to run and when. Task configuration covers the order , timing and triggers of execution. For example,

  • A cyclic task may be configured to execute every 20ms.
  • An acyclic, freewheeling task may be set to occur per the processor execution cycle for the POU as defined.
  • An event triggered task may run only when an input is triggered.

If a part of the code needs to have  a higher priority over other parts, it may be defined in a task of its own. It could also be set to execute with a shorter cycle time, if required.

SoMachine tasks are configured under the Task Configuration header. Multiple tasks can be defined with the number varying based on the specific PLC used. CCW does not have a specific task configuration section. Programs noted in programs section are executed in order. The order can be changed, as required. CCW does have an interrupt option that can be used to trigger specific logic as required.

Key takeaway here is to note the differences in the number of tasks and sequencing options for programs/POU’s in various environments.

Share