IEC 61131-3: The Observer Pattern

The Observer Pattern is suitable for applications that require one or more function blocks to be notified when the state of a particular function block changes. The assignment of the communication participants can be changed at runtime of the program.

Continue reading “IEC 61131-3: The Observer Pattern”

IEC 61131-3: Unit-Tests

Unit tests are an essential tool for every programmer to ensure functioning of his software. Software bugs cost time and money, so you need an automated solution to find these bugs and preferably before the software is used. Unit tests should be used wherever software is professionally developed. This article is intended to provide a quick introduction and allow an understanding of the benefits of unit tests.

Continue reading “IEC 61131-3: Unit-Tests”

IEC 61131-3: Extend UNION via inheritance

In the post IEC 61131-3: Additional language extensions, I briefly described the UNION. A reader comment has pointed out to me the possibility, that a UNION can also be expanded by EXTENDS. Since this simplifies the handling of a UNION and the norm does not indicate that, I would like to introduce this possibility in a (very) short post. Continue reading “IEC 61131-3: Extend UNION via inheritance”

IEC 61131-3: Parameter transfer via parameter list

Parameter lists are an interesting alternative for transferring parameters to PLC libraries. Strictly speaking, these are global constants (VAR_GLOBAL CONSTANT) whose initialization values can be edited in the Library Manager.

Continue reading “IEC 61131-3: Parameter transfer via parameter list”

IEC 61131-3: Additional language extensions

The focus of my post has been the object-oriented extensions so far. But there are several general, usually not so far-reaching innovations within TwinCAT 3. Below, they are briefly described.

Continue reading “IEC 61131-3: Additional language extensions”

IEC 61131-3: Methods, Properties and Inheritance

Object-oriented programming (OOP) is a proven way of keeping the complexity of software systems in check. Until recently the preserve of languages such as C++, Java and C#, IEC 61131-3 introduces the concept to PLC programming.

Continue reading “IEC 61131-3: Methods, Properties and Inheritance”

IEC 61131-3: The Command Pattern

A command can be run on a function block by calling a method. Function block A calls a method of function block B. So far, so good, but how can such commands be exchanged flexibly between several function blocks. The command pattern provides an interesting approach.

Continue reading “IEC 61131-3: The Command Pattern”

IEC 61131-3: Namespaces

The third edition of IEC 61131-3 introduces the concept of namespaces. Namespaces group elements such as variables, function blocks, data types and libraries into coherent units. This means that elements are no longer identified solely using their names, but additionally using the associated namespace.

Continue reading “IEC 61131-3: Namespaces”

IEC 61131-3: Arrays with variable length

While declaring arrays, one had always to define a constant value up to now. Since the 3rd edition of the IEC 61131-3, arrays can be declared with a variable length. Thus, you can create functions much more generically than previously.

Continue reading “IEC 61131-3: Arrays with variable length”

IEC 61131-3: Coding Guidelines

The wish to raise the quality of a software is hardly much older than the software development itself. At the beginning, a set of rules should be determined which define software development guidelines, especially in major projects with multiple developers. Fortunately, PLCopen published recently a draft specifically for IEC 61131-3.

Continue reading “IEC 61131-3: Coding Guidelines”