Command Online Change

Function: The command is used to initiate an online change to the currently active PLC project. TwinCAT only reloads the modified parts of a PLC project that is already running on the controller into the controller.

Call: PLC menu

Requirement: The PLC project is in online mode.

An online change is not possible after the Clean All and Clean commands. The cleanup process deletes the compile information (compile log) that is automatically saved each time code is generated, and which forms the basis for an 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.
Command 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.

Command 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.

Command 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.

Command 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

Pointers retain their value from the last cycle. If a pointer points to a variable that was resized by the online change and moved in the memory as a result, the pointer variable no longer returns the correct position of the variable. Make sure that pointers are reassigned in each cycle.

During an online change with possibly unintended consequences, TwinCAT lists the changed interfaces, affected variables and all function blocks for which new code has been generated in the Details dialog box. If storage locations change, a dialog is displayed to indicate possible problems with pointers.

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.

See also: