twincat

Dear existing & future PLC software developers, I have published the 5th part of my free PLC programming using TwinCAT 3 tutorial.

Arrays allow us to define types of variables that can hold several data items of the same kind. In this part of the tutorial we will look at a data unit type that allows us to hold several data items of different kind. We will also look at one of the basis of modularization and re-use in software development called functions. We will look at how we can get data in and out of functions, and we will also look at the difference between passing parameters by value and by reference. We will finish this part by writing our very first function!

Read more

Dear existing & future PLC software developers, I have published the 4th part of my free PLC programming using TwinCAT 3 tutorial.

In this video we will look into the various data types that are available in the IEC 61131-3 standard, pointers & references and how to work with arrays. We will cover why pointers can be dangerous and why you generally want to prefer to use references instead. Then we will finish the tutorial by looking at how we can convert between different data types. Also, what is the relationship between the amount of stars in the universe and TwinCAT? Watch the video to learn!

Read more

When I started out with TwinCAT programming some time ago, I had basically not heard about PLCs. My background was not even close to automation, mostly doing C/C++ on various Linux-based systems. I had two friends which previously were doing a little automation, and both of them said “Don’t start working with PLCs. It’s boring“. Now that I’ve dabbled in “traditional IT” software development and industrial automation software development, I definitely don’t agree with the latter being boring. Industrial automation using PC-based control is insanely fun! At my first job where they used “this thing called TwinCAT” (which was unknown to me at that time), I did what I usually do: I started googling stuff like “free TwinCAT tutorial, how to program with TwinCAT, free TwinCAT course, TwinCAT open source” and so forth. I didn’t find much on Google or in any other of the places I usually used to learn a new programming language (forums, stack overflow, open source projects, etc). The amount of free resources was very limited. After having my TwinCAT blog for a few years, I even got an (anonymous) message via the contact form on my blog from someone saying that I’m an idiot that shares information and knowledge for free, and that nothing should be done for free and that I should basically stop writing my blog. For these reasons, I decided to do a free TwinCAT 3 tutorial.

Read more

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

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

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