In this tips and tricks post I will demonstrate the usage of the attribute: ‘instance-path’. The instance path attribute allows you to get the instance path of the containing POU in a string variable. Something I find particularly useful for error-logs and debug messages. How to use it 1. We need a string variable which […]
Tag: DRY
You should use AND_THEN. OR_ELSE?
In this post I’ll discuss the operators ‘AND_THEN’ and ‘OR_ELSE’. Operators which I find really useful from time to time.
Instance variables with VAR_INST
Instance variables are available for funtion block methods. Unlike ‘normal’ variable their values are preserved between method calls.
STweep – The formatter for Structured Text
STweep is a formatter for Structured Text integrated in Codesys and TwinCAT. STweep assists in enforcing a consisting code style!
Fluent interface in Structured Text
A popular programming design in high level languages as C# is the so-called ‘fluent code’ or ‘fluent interface’. But what is a fluent interface and how can we implement this in Structured Text? In this post I briefly explain what a fluent interface is and give an example of a fluent interface in Structured Text.
The ABSTRACT keyword
It was already available in CODESYS, but with the release of TwinCAT 4024 it’s now available in TwinCAT as well: the ABSTRACT keyword. Abstraction and the use of the abstract keyword is common practice in OOP and many higher level languages as C# support this. It’s often considered as the fourth pillar of OOP. In this post i’ll explain how to use the ABSTRACT keyword in TwinCAT with some practical examples.
The three pillars of OOP – Inheritance
With the object orientated options we’ve got available with IEC 61131-3 last years the time has come to talk about design patterns and best practices in the world of PLC programming. In this series of three posts ‘The three pillars of OOP’ I will explain the concepts of: Encapsulation, Inheritance and Polymorphism with some examples in TwinCAT. This post is about the second pillar ‘Inheritance’.
The three pillars of OOP – Encapsulation
With the object orientated options we’ve got available with IEC 61131-3 last years the time has come to talk about design patterns and best practices in the world of PLC programming. In this series of three posts ‘The three pillars of OOP’ I will explain the concepts of: Encapsulation, Inheritance and Polymorphism with some examples in TwinCAT. This post is about the first pillar ‘Encapsulation’.