TwinCAT User Mode Explained: Understanding Non-Realtime Runtime for Automation

In TwinCAT 3.1.4026, the User Mode (abbreviated as UM) has been introduced, a non-real-time Runtime feature designed to execute TwinCAT programs that do not require real-time performance.

1. Principle

Compared to the standard TwinCAT Realtime Runtime (abbreviated as RM), the most significant distinction of UM lies in its scheduling by the Windows system rather than a real-time kernel.



In each Base Time, it utilizes Windows time instead of TwinCAT RT (Real-Time) time:


2. Operation Modes

UM features three operation modes: Cyclic, External Control, and Fast As Possible.

Cyclic is the default mode upon startup of the UM Runtime, analogous to the time-sharing multitasking mechanism of RM, albeit with task cycles that are not as fixed as the set values and can exhibit significant fluctuations. In the presence of multiple tasks, their execution frequencies generally maintain the set ratios.

The External mode requires an external command to trigger the execution for a specified duration before automatically stopping. On the other hand, Fast As Possible mode executes immediately and continues uninterrupted until the mode is exited, requiring neither external triggers nor waiting for the Base Time of the Realtime kernel to commence.

Regardless of the mode, during operation, tasks are generally executed in a cyclic manner, one cycle after another, similar to the Cyclic mode. Therefore, PLC programming is necessary to switch the UM's operation mode using ADS commands. When switched to the External mode without any external trigger commands, all tasks cease execution entirely.


3. Applications

Due to the lack of real-time capabilities in UM, it cannot directly drive EtherCAT or other real-time Ethernet protocols such as PROFINET (PN) and EtherNet/IP (EIP). However, UM supports non-real-time communication protocols like ADS, TCP/IP, and Modbus TCP. Naturally, all other TF (Technology Function) add-ons requiring real-time performance, such as motion control, temperature control, PID control, Vision, etc., are not available in UM.

The advantages of UM lie in file operations, Ethernet communication, and large-scale computations.

When fast response is required, the Fast As Possible mode can be utilized to trigger program execution at microsecond levels, eliminating the need for continuously monitoring execution conditions at a 50-microsecond cycle, which can consume significant CPU resources.


4. Interfaces

Typically, UM operates as an extended functionality of RM, allowing a single controller to host one Realtime System (RM) and several non-realtime systems (UM) simultaneously. In a TwinCAT Project intended for testing, the target system can be selected as either the RM or a specific UM running on the local machine, with subsequent operations proceeding identically to those with RM.

UM primarily interacts with the external environment through ADS communication. Each UM instance has a unique NetId, which can be viewed and modified by clicking on its icon, similar to RM.

Within the TwinCAT project for UM, just like RM, multiple PLC programs can be accommodated, with ports assigned sequentially starting from 851, 852, and so on. The internal PLC variables can also be accessed via ADS using either variable names or addresses.

A special ADS interface pertains to the UM runtime itself. For example, to query or switch TwinCAT states, communication must be directed through Port 200. The IndexGroup and Offset for various functions are outlined as follows:

Function

Index Group

Offset

Query Runtime Type

0x0700

0x0002

Query Platform Type

0x0700

0x0004

View Runtime Status

0x0001

0x0032

Specify Number of Ticks for UM Operation in External Mode

0x0001

0x0031

ADS commands can be sent through either PLC or high-level programming languages.