TwinCAT and Unity – Intro

Welcome to my new TwinCAT series!

In the cycle of developing software for an industrial automation system, there is usually a moment, when we would like to test our software but the actual hardware that we want to control is not there yet. Sometimes we might be lucky enough that we have access to simulation software and detailed mechanical models. This kind of software however is usually very expensive and not all companies can afford to get one. Luckily, there is an alternative. That is, if you are using Beckhoff TwinCAT 3 PLC and have some C# coding experience…

The last sentence is not exactly true, Siemens PLC would do fine as well, but I’ll focus this time on Beckhoff PLC.

In the next posts I will be describing how to connect TwinCAT PLC and Unity game engine. This unusual marriage will allow us to create simulation environment in which various aspects of controls software can be tested and put through the paces.

To follow through the steps described in the posts, following software will be required:

  1. TwinCAT 3.1 eXtended Automation Engineering (XAE)
  2. Unity 3D
  3. Visual Studio 2019 Community Edition (optional)
  4. Blender – to create models, however some Unity assets can work as well

I am going to run everything on single machine, so no actual PLC is required. TwinCAT 3.1 XAR (Runtime) will run locally. If we consider that for non-commercial (hobbyist / freelancer) application our tool-chain is free of charge, then this whole project becomes even more interesting.

In the next posts I am going to gradually build the capabilities of the simulation environment starting from simple ON/OFF control, up to fully functional closed loop NC control.