Jakob Sagatowski's Posts

This is a joint article by me and Peter Kurhajec.

Unit testing is the practice of writing a test for a required functionality. In the world of “classical” IT software development, the concept of unit testing has been around for almost two decades. What is a standard procedure in languages such as Java, C++, .NET/C#, Python, etc. — has been completely lacking in the world of PLCs. The world of automation did not have the proper tools, and nor did it develop any comprehensive automated testing frameworks. Here we present two possible approaches for unit testing in Beckhoff’s TwinCAT 3.

Read more

Oh no! The PLC has crashed, and we might even see the classical blue screen of death (BSOD). We’ve all been there, and there are many reasons for why we got there. TwinCAT is generally good at handling exceptions, and most of the time it is possible to analyze exceptions during development of software for a machine. On a few occasions though, I’ve been in the situation where the machine has crashed, and I have not been connected to it at the moment of the crash and without any possibility to see what caused it. In the latest version of TwinCAT (3.1.4024.11), Beckhoff have included a tool to aid with this type of problems.

Read more

I love industrial fairs. When walking around and seeing all the fancy tech, I always feel like a small kid on Christmas Eve. There are so many toys, and I try to find a reason to buy something to use at work, even though deep inside I know I just want to satisfy the child in me. Because of Covid-19, this year all the fairs were (not very surprisingly) cancelled. One of the best fairs is the SPS Messe which runs in the end of November. This year, the fair was named SPS connect, and the different vendors did an online version with various content. Beckhoff was not an exception, and as one of their topics (from the list of many) they had a roundtable discussion about TwinCAT 3 that I was invited into. It was a good opportunity for me and Peter to share some of our TwinCAT experience and thoughts.

Go and watch the video here!

I think this was a great initiative from Beckhoff and I hope that there will be more occasions like this!

Read more

Some time ago I wrote a post about developing code for different runtimes, and since then I’ve come to the realization that there is so much information missing in that blog post that I simply needed to write another one. What’s even worse is that the information regarding development, deployment, and just general handling of several TwinCAT versions on the Beckhoff website is not that good. I’ve talked to numerous automation engineers regarding this topic, and everyone seems to have a different understanding about it. As I was working in a development project that had many PLCs (hundreds!) with different versions of TwinCAT, I finally had a good excuse to dive into the details of this. With this blog post, I’d like to share some of the facts and misconceptions.

Read more

Dear TwinCAT/PLC developers,

I’m very happy to announce the release of the TcUnit-Runner, an open-source tool for integration of TwinCAT unit tests into a CI/CD toolchain automation server such as Jenkins. When TcUnit, the TwinCAT unit testing framework, was released back in December of 2018 I would never have imagined how widespread it would get. Since then, I’ve received e-mails from PLC developers every week with questions, improvement suggestions or just gratitude for this open-source software. The TcUnit framework has found its way into the full range of projects ranging from small machines to multi-billion € projects. With this response, I would say that there definitely is a need for unit testing in the world of automation. The adoption of TcUnit into TwinCAT projects across the globe has motivated the further development of TcUnit. One limitation of the TcUnit framework was that it was only possible to run the unit tests locally on your development machine (or PLC), and thus needed to be run manually every time a change in the software was made. Modern software practices advocate that software development should adhere to the practices of continuous integration/continuous delivery (CI/CD), so that tests would be run automatically when committing changes to version control. Thus, TcUnit-Runner was developed.

Read more

I have been using TwinCAT for quite some time now, and since I started developing software with TwinCAT it has changed almost everything for me as a software engineer, both as a profession and as a hobby. This includes the programming language, development environment, software development processes, hardware, communication protocols and much more. I have recently philosophized about how my life as a software developer has changed compared prior to doing automation software. Overall, I would say that I can do tremendously more things (in a reasonable amount of time) with TwinCAT by myself, than I could do before when I was developing software in the “standard” programming languages. It has given me opportunities to work with insanely fun projects that I would never have worked with if I didn’t start with PLC software development. What I would want to share with you is a list of five things that I think Beckhoff have done right, and five things that they could improve.

Read more

Write filters are an essential part of a PLC. In Beckhoff PLCs write filters redirect writes from a disk/partition to RAM or another disk/partition which is flushed after reboot.

Basic principle of a write filter

The reason why you want to have a write filter on your PLC is simple; it’s to protect the PLC from write operations. We’ve all been in the situation where the OS is in the middle of a write, and for some reason it suddenly dies. After a reboot the system might be corrupted. With write filters, most changes in any applications or the operating system will not be persistent, which is often what you want in a system that runs 24/7 year after year. By protecting volumes from writes, the filter also reduces the wear of flash media. Because the filter puts the changes in volatile storage, it’s enough to do a simple reboot to get the system back in a well-known state. In this post I will go through the different types of write filters and discuss some of the finds I did with the new UWF (unified write filter) that comes with the Windows 10 enterprise operating system.

Read more

Doing version control is a natural part of any software engineers daily work. Doing version control for PLC software has historically mostly been hard, if not impossible. As many automation manufacturers store all software in binary blobs it has not been suitable for version control. Sometimes there have been proprietary solutions available, but it’s not until recently that a shift has started where source code is stored in plain text. For version control, Git has gained more and more popularity for over a decade.

Read more

Logging various form of data is common practice and is done in some form in more or less every industrial application. There are various ways to store the data such as databases and different cloud services. However, sometimes you just want to stick to the basics and store data as a file, for instance as comma separated values (CSV). Depending on the amount of data that needs to be written, it’s usually not the best idea to do a lot of writes to the PLCs local drive because of wear and accessibility, but rather to a network drive.

Read more