TwinCAT 3 Simulation in VirtualBox

5 min read

Introduction

TwinCAT 3 is a powerful automation software platform developed by Beckhoff Automation. It is widely used in the field of industrial automation and control systems. This software is designed to facilitate the development, programming, and execution of control applications for various industries, including manufacturing, process control, and building automation.

VirtualBox is a versatile virtualization software developed by Oracle, enabling users to run multiple operating systems on a single host machine. It's a ubiquitous tool for testing, development, and running virtualized environments. With its user-friendly interface, extensive guest OS support, and open-source nature, VirtualBox is a popular choice for both beginners and experienced users in the virtualization space.

In this tutorial, you will learn how to configure the TwinCAT 3 environment in VirtualBox software. We will open a project in TcXaeShell (part of TwinCAT 3) and run its Simulation.

Prerequisites

In order for you to follow this tutorial, you will need the following prerequisites:

Software

Note that the TwinCAT 3 - eXtended Automation Engineering (XAE) can be run directly in the system environment without using Virtual Environment.

TwinCAT 3

Nowadays running Virtual machines has a lot of advantages. It creates the possibility of testing various systems on one computer without the need to install several operating systems. As an example, it is possible to have an instance of Windows 10 running TwinCAT 3 and another instance running Windows XP with some legacy software that we have to communicate with.

When you try to Simulate the TwinCAT 3 program in the Virtual environment, if there was no prior configuration made you will encounter the following popup.

As the popup suggests the issue is related to the cores of the operating system. TwinCAT 3 is using system cores to transform PC-based systems into industrial requirements. In order to be able to run the Simulation in the VirtualBox we have to configure at least one isolated core specifically for the TwinCAT 3 so it can use it to simulate the PLC.

To do this we have to go to SYSTEM, Real-Time, and Settings.

In the Setting tab, we can configure the isolated core for the TwinCAT 3. The steps to configure it are as follows:

1) Select “Read from Target” - it will read the current number of cores assigned by VirtualBox

2) Define Shared and Isolated cores - we have to configure at least one Isolated core

3) Select the Isolated Core as the active one

4) Select “Set on Target” - there will be another popup asking to confirm the current configuration, we have to configure it exactly as in step 1.

Next, we have to accept all of the popups.

Note that at the popup asking to reboot the system, it is advised to click “No” save the project, and then reboot the system manually. Otherwise, the system will reboot immediately without saving software changes.

Our VirtualBox has assigned 4 CPU cores for the Windows instance running TwinCAT 3, after the computer reboot and configuration that we have done, one core is used only by the TwinCAT 3 so it is no longer visible to the system which we can verify in the Task Manager.

After this configuration has been updated we can start the simulation of the software in the VirtualBox environment.

It is important to note that the Virtual machine must have a minimum of two or more assigned processor cores. If not, we are unable to assign a single isolated core for TwinCAT3 simulation needs.

We may get one of the following errors when the configuration in TwinCAT 3 is different from the setup in VirtualBox and we intend to start the simulation. In this situation, it is important to make sure the cores assigned to the Virtual machine and those specified in the TwinCAT 3 Settings are consistent.

Conclusion

We saw how to configure the TwinCAT 3 programming environment to be able to run on the Virtual machine using VirtualBox software. It provides a convenient and isolated environment for development and testing, ensuring the stability of your host system. Another advantage is creating backups and snapshots of the whole setup and the possibility of sharing the whole setup with other team members.

Finally, if you have any questions or need assistance with an application and Industry 4.0  automation technologies, Outlier Automation has that know-how. Get in touch with us today to learn more about how we can take your business to the next level of Industrial automation.

Outlier Automation