TwinCAT UML class diagram

When working with OOP concepts as discussed in the series “The three pillars of OOP” it might get hard to keep track of your program architecture when your program grows. As this is a common struggle in the world of the programming some smart people came up with the Unified Modeling Language. Or short UML. With UML we can visualize and develop our software graphically. In this post I’ll show how to generate an UML class diagram in TwinCAT.

Read More

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.

Read More

Keep your online view clean: The hiding attributes

In the post ‘How to use monitoring attributes’ I showed how to use the monitoring attributes: attribute ‘monitoring’ := ‘variable’ and attribute ‘monitoring’ := ‘call’. With these pragma attributes we can monitor and modify our function blocks properties. This comes however with a small drawback. As the online view now shows your properties and their backing fields your online view gets less clear. In this post I will show how to solve this with the hiding attributes.

Read More

The three pillars of OOP – Inheritance

Pillars

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’.

Read More

The three pillars of OOP – Encapsulation

Pillars

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’.

Read More

How to use monitoring attributes

Magnifier

Every programmer spends a considerable amount of time debugging their software. In the world of PLC programming it’s common to login to the PLC and monitor and write your variables. However, with the introduction of properties for your function blocks monitoring is not as plain as it used to be. In this post I’ll explain how to use monitoring attributes for your properties in TwinCAT.

Read More

A Code Jam challenge with Structured Text

Laptop with code on desk with Coffee

Every year I participate in a number of online code challenges like Facebook Hacker Cup, Google Code Jam and Advent of Code. Although I never make it really far I quite enjoy the puzzles which I usually make in C#. Definitely not the fastest language out there, but LINQ makes life easy 🙂 . Since I spent every week a considerable amount of time PLC programming, I found myself wondering if I could solve A Code Jam challenge with Structured Text. Spoiler alert, yes you can, but it doesn’t come very easy.. So I decided to write a small post about it, pointing out the challenges I faced.

Read More