Table of Contents

Using Usermode Runtime in TwinCAT

Note

This guide is targeted towards users of TwinCAT (>= 3.1.4024.xx)

In realtime systems simulating an application can be a tedious task. Most systems require kernel mode access to the operating system or even further special hardware to work on. With Windows 10 Soft-PLCs tend to have problems in keeping track of energy-saving settings and security features that come with updates over time, and after all do not work on standard PC hardware. When simulating a PLC it is not always necessary to have realtime behavior. Sometimes one just wants to test if the program is doing what it is supposed to or wants to test some small parts/algorithms of the application.

In TwinCAT version 3.1.4024.x Beckhoff has integrated a Beta feature which is called UmRt (we suppose it means Usermode Runtime). This runtime does not need kernel mode features and can therefore run under normal application requirements on windows. Of course, no realtime behavior can be guaranteed but as described above it is just for testing and simulating an application.

How to Start Usermode Runtime

Beckhoff has integrated this feature in a folder called C:\Twincat\3.1\Runtimes\UmRT_Default. In this folder there is a Start.bat file which starts the usermode runtime. In earlier versions of TwinCAT this has to be done with administrative priviledges, however with the actual version (3.1.4024.35) it can also be started with normal user rights. The usermode runtime starts and has a separate AMS-Netid which can be chosen by editing the Start.bat file. Just open it with a text editor of your choice (Notepad++, Visual Studio Code, ...) and edit the line where the AMS-Netid is configured.

Depending on which TwinCAT version one has currently running the following steps have to be done by opening the command window with administrative rights. If a valid AMS-Netid has been chosen, open a command window in windows. Press the windows button and type cmd and press enter. (to use administrative rights, right click on the icon and choose Run as Administrator, enter Username and Password of your Admin Account) Now navigate to the folder C:\Twincat\3.1\Runtimes\UmRT_Default. In this folder execute the Start.bat file and keep the window open.

Controlling the Usermode Runtime

After starting, there are some commands which can be entered in this command line window to control this service. These are similar to the normal TwinCAT Runtime running on your device which can be controlled by right clicking on the symbol at the bottom right. The commands are as follows.

  • c ... Switch the runtime into config mode
  • r ... Restart the runtime
  • s ... Show the actual state of the runtime
  • x ... Shut down the runtime and close the window

Selecting Usermode Runtime in Twincat

Start TwinCAT with a solution of your choice and deactivate all Ethercat Master Devices. In the top menubar select the target as remote target and then activate the solution. Finally login and you can test all things you want to test without changing anything in the BIOS or hiding cores or making special settings for energy saving on your device.

Using more Memory in Usermode Runtime

Some tasks like Unit-testing or very large applications require more memory to run the program smoothly either on a realtime capable runtime and also on the Usermode Runtime. To get more RAM for the Usermode Runtime, one has to add some lines to a configuration file which is placed in C:\TwinCAT\3.1\Runtimes\UmRT_Default\3.1\TcRegistry.xml. To raise the actual allocated memory add <Value Name="HeapMemSizeMb" Type="DW">256</Value> which sets the available memory to 256 MBytes.

<?xml version="1.0"?>
<TcRegistry>
	<Key Name="HKLM">
		<Key Name="Software">
			<Key Name="Beckhoff">
				<Key Name="TwinCAT3">
					<Value Name="CurrentVersion" Type="SZ">3.1</Value>
					<Key Name="System">
						<Value Name="RunAsDevice" Type="DW">1</Value>
						<Value Name="AmsNetId" Type="BIN">C0A804010101</Value>
						<Value Name="LockedMemSize" Type="DW">33554432</Value>
						<Value Name="HeapMemSizeMb" Type="DW">256</Value> <!-- add this line here -->
					</Key>
					<Key Name="3.1">
						<Value Name="BootDir" Type="SZ">3.1\Boot\</Value>
						<Value Name="ConfigDir" Type="SZ">3.1\Config\</Value>
						<Value Name="InstallDir" Type="SZ">3.1</Value>
						<Value Name="TargetDir" Type="SZ">3.1\Target\</Value>
						<Value Name="DriverAutoLoadDir" Type="SZ">3.1\Driver\AutoLoad\</Value>
					</Key>
					<Key Name="EventLogger">
						<Value Name="LastUniqueId" Type="DW">0</Value>
					</Key>
				</Key>
			</Key>
		</Key>
		<Key Name="Ident">
			<Value Name="DeviceType" Type="SZ">TC/BSD</Value>
		</Key>
	</Key>
</TcRegistry>