Creation of versioned drivers

Each object created from Simulink® contains version information. Accordingly, you can build several versions of a Simulink® model and instantiate the created modules version-selectively in TwinCAT.

Define revision control in Simulink®

Before creating a PLC function block or a TcCOM object, you can define the version of the TcCOM and the created PLC library under TC General with the entries "Version source file" and "Version part for increment".

Creation of versioned drivers 1:

Automatic version increments

The basic version on which a version update is to be created is specified via "Version source file". In the standard case $<LatestTMFile> is specified there. This searches for the last available version of the model on the local engineering PC and then uses this as the basis for the version increment.

The version number consists of four digits, e.g. 1.0.3.2 or 2.12.123.14. Each digit can be incremented separately according to the scheme: <Major>.<Minor>.<Build>.<Revision>

For example, if the last version of a model named "MyModelXY" on the engineering PC is found to be 1.2.12.4 and the increment is set to "Revision", a version 1.2.12.5 is created.

If "None" is selected, no version update takes place and the last version on the engineering PC is overwritten.

Default of a fixed version number

If a version is to be specified in Simulink®, this can be done via DrvFileVersion. Simply enter the target version in the input field.

Creation of versioned drivers 2:

In the Engineering Repository, a folder is created under the model name for each version created. Each version folder then contains the corresponding drivers and TwinCAT files. See also TwinCAT objects.

Creation of versioned drivers 3:

Presetting of a version number via an external file

You can also use an external file to specify a version. For example, this is a common method when using build agents at Continuous Integration.

For configuration in Simulink® set TC General Version part for increment to "None" and specify the full path to your version file at Version source file.

Creation of versioned drivers 4:

Structure of the external file:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <appSettings>
    <add key="major" value="1" />
    <add key="minor" value="3" />
    <add key="build" value="1301" />
    <add key="revision" value="267" />
  </appSettings>
</configuration>

Use versioned models in TwinCAT XAE

All models available in the Engineering Repository can also be instantiated in any available version. To do this, navigate through the tree as usual to find the TcCOM of your choice. In the last hierarchical level, you can now also select the version of the TcCOM.

As an example, two versions (0.0.0.4 and 0.0.0.5) of SimpleTempCtrl are available here:

Creation of versioned drivers 5:

Online Change of a TcCOM during TwinCAT Run

To switch between different versions of a TcCOM during operation, the corresponding interface must be implemented.
1. To do this, select the checkbox for Online change support under the tab TC TcCom General in Simulink®.
Creation of versioned drivers 6:

Online Change for PLC function block

If you use the function block (PLC-FB) in a versioned PLC library, you do not have to check the checkbox Online change support. The Online Change process then runs via the PLC-specific mechanism.

Creation of versioned drivers 7:

In addition, created TcCOM data areas must be compatible with each other. If Online change support is activated, the last hierarchical level is more strictly differentiated in the Insert TcCom Object dialog. Only Online Change compatible TcCOM are combined.

The following shows that versions 0.0.0.1 and 0.0.0.3 or 0.0.0.4 and 0.0.0.5 are compatible for Online Change. However, not 0.0.0.3 to 0.0.0.4 or 0.0.0.2.

Creation of versioned drivers 8:

In order to better ensure the compatibility of the Data Areas, it is possible, for example, to keep the parameters, Block I/O, ContState and DWork of a model not in an internal Data Area, but as module parameters. This means that only the inputs and outputs as Data Area are relevant for the compatibility of the TcCOM versions.

Creation of versioned drivers 9:
2. To perform the Online Change in TwinCAT XAE, use the tree item TcCOM Modules and navigate to the Online Changable Objects tab.
Creation of versioned drivers 10:
3. Select a version of your choice from the drop-down menu at Online Version (only compatible versions are displayed).
4. Right-click on the line of the object and select Apply changed online object versions to activate the new version of the TcCOM.
Details can also be found in this TwinCAT C++ documentation.