Performing an Online Change

TwinCAT automatically offers you an online change if you log in with a PLC project that already exists on the controller but has been modified since the last download in the programming system. During this process, only the modified parts are reloaded into the controller. A program that is running on the controller is not stopped during the online change.

WARNING

Damage to property and persons due to unexpected behavior of the machine or system

An online change modifies the running application program and does not cause a restart. Depending on the machine being controlled, the machine or workpieces may be damaged or the health and life of people may be endangered.

  • Make sure that the new program code results in the desired behavior of the controlled system.
Performing an Online Change 1:

Project-specific initializations

When an online change is performed, the project-specific initializations (homing etc.) are not executed because the machine retains its status. For this reason, the new program code may not have the desired effect.

Performing an Online Change 2:

Major changes in the download code

If the online change causes significant changes in the download code (e.g. shifting of variables is required), a dialog provides information about the effects and allows you to cancel the online change.

Performing an Online Change 3:

Fast online change

For small changes (e.g. in the implementation section, with no shifting of variables required), a "fast online change" is performed. In this case, only the modified function block is compiled and reloaded. In particular, no initialization code is generated in this case. This also means that no code for initializing variables with the attribute 'init_on_onlchange' is generated. Usually this will not have any effect, since the attribute tends to be used to initialize variables with addresses, but a variable cannot change its address during a fast online change.

To ensure the init_on_onlchange attribute is applied to the entire application code, deactivate fast online change for the PLC project using the no_fast_online_change compiler definition. To this end, insert the definition in the Compile category of the PLC project properties.

Performing an Online Change 4:

The attribute 'init_on_onlchange' has no effect for individual FB variables

The Attribute 'init_on_onlchange' only applies to global variables, program variables and local static variables of function blocks.

To reinitialize a function block during an online change, the function block instance must be declared with the attribute. The attribute is not evaluated for a single variable in a function block.

Pointer variables

Pointer variables retain their value from the last cycle. If a pointer points to a variable that has been resized by the online change, the value is no longer delivered correctly. Make sure that pointer variables are reassigned in each cycle.

Monitoring functions

After removing implicit monitoring functions such as CheckBound, no online change is possible, only a download. A corresponding message is issued.

See also:

Online change on login

The connection settings of the controller are set correctly. The application programs in the project and on the controller are identical. The program is running on the controller. The PLC project is logged out.
1. Change your PLC project.
2. Select the command Login in the PLC menu or in the TwinCAT PLC Toolbar Options.
A dialog appears indicating that the application was changed since last download.
3. Select the option Login with online change and click OK.
The change is loaded onto the controller. The program running on the controller is not stopped. The PLC project is logged in.

See also:

Online change in logged-in state (online mode)

The connection settings of the controller are set correctly. The application programs in the project and on the controller are identical. The program is running on the controller. The PLC project is logged in.
1. Select an object in the PLC project tree. Ideally a POU or GVL in this case.
2. In the context menu select the command Edit Object (Offline).
The object opens in the editor.
3. Change the object. for example by declaring a new variable or changing a value assignment.
4. Select the command Online Change in the PLC menu.
You will be asked whether you really want to carry out the online change.
5. Confirm the dialog with Yes.
The change is loaded onto the controller.

See also:

What prevents an online change?

After certain TwinCAT actions an online change on a controller is no longer possible. After that, a download of the project is always required. A typical case are the actions Clean and Clean all, which delete the compilation information stored during the last download. But there are also "normal" editing actions that result in an online change not being possible the next time you log in. The following actions can prevent an online change:

Check functions

Activating or removing a check function (CheckBounds, CheckRange, CheckDiv etc.).

Changing the interface of a check function (including inserting or deleting local variables).

Task configuration

Changing the configuration settings.

Project settings

Category Compile: Changing the compiler defines in the Settings section (replace constants)

Category Common: Minimize ID changes in TwinCAT files.

 

Function block properties

Change of option External implementation

Function block

Changing the basic block of a function block (EXTENDS FB_Base), or inserting or deleting such a basic block.

Changing the interface list (IMPLEMENTS I_Sample). Exception: Adding a new interface at the end of the list.

Data type

Changing the data type of a variable from one user-defined data type to another user-defined data type (e.g. from TON to TOF).

Changing the data type from a user-defined data type to a basic data type (e.g. from TON to TIME).

Note: As a workaround, always change the name of the variable at the same time as the data type. As a result, the variable is initialized as a new variable, and the old variable is removed. An online change is then possible.