Client - SBO Control with enhanced security

This sample shows the exemplary implementation of the command: select-before-operate-control-with-enhanced-security (ctlModel := 4, select before operate control with enhanced security) in a TwinCAT IEC 61850 client project for the following switch control data classes (Common Data Class, CDC):

Download TwinCAT XAE Project (*.zip): Sample07.zip

The example described here uses the state machine that is described in the "General Client project structure" chapter. The States 0, 1, 11 and 100 are identical to the state machine described there. Other states were modified for the example or new states were also added.

For the implementation of the commands: select before operate control with enhanced security, an additional, self-implemented function block is required. In the sample a new function block: "FB_SBOwControl" has been added for this purpose. The function block: "FB_SBOwControl" handles the actual command execution for the different CDC types.

In the modified State 10 of the "FB_IEDClient" several IF statements are listed, which enable the command execution of the client via the instance of the "FB_SBOwControl" function block. An enum is used here for activation in order to consider all states of the SBO command (SBO = select before operate). The command is activated as soon as one of the enums, for example, "eControl_LLN0_Mod" is not "E_AcsiCtlService.None". The user can initiate this via the online values in the application.

Methods of the "FB_DirectControl" function block

Method name

Description

APC

BAC

BSC

DPC

ENC_Mod

INC

ISC

SPC

A method is added for each controllable CDC type, as most CDCs use different types, for example, "APC" -> "REAL" and "SPC" -> "BOOL". As the CDCs use different types, each of these methods also has a different input parameter for the control value (e.g. "ctlVal"). Inside the method the value is written to a union type that contains a member for each CDC. The union variable is passed to the "Request" method. The "Request" method is a private method and it activates the command execution.

Execute

As soon as the "Request" method of the function block has been successfully called, the "Execute" method must be called in every cycle. Within this method there is a separate state machine that works independently of the state machine in the client function block. As a result of this, the code is divided into smaller sections and is easier to extend in future.

Clear

Aborts the command and resets the function block.

The command, depending on the CDC type, modifies the control value of the CDC. For demonstration purposes, a numerical value is incremented or a Boolean value is toggled, for example. 

The execution changes depending on the enum value for initiating a command. The enum can take the following values: None, Select, Operate, Select&Operate, Cancel. Only one command is executed in the case of Select, Operate and Cancel. In the case of Select & Operate, a Select command is executed first and, as soon as this has been successfully completed, the Operate command begins. The user can choose one of these options when switching over the enum in the online values.

As soon as a change takes place with one of the enum values, the respective method to suit the CDC type is called. If this has been successfully completed, the state machine changes to State 11. This is necessary because the processing of the commands takes longer than one cycle in the PLC. The "Execute" method is called cyclically within this state. On the basis of the "ipResult" interface pointer, it is possible to determine whether the command is still being processed or whether it has already been completed. This is queried via the "IsBusy()" method. The state machine switches to State 0 as soon as the command has been successfully executed.

As opposed to Sample05 with the implementation example for "Select before operate control with normal security", the user receives the event "OnCommandTerminationInd" at the "FB_IEDClient" function block when the "Select before operate with enhanced security" is successfully executed. If an error occurs when executing the command, the user receives the event "OnLastApplErrorInd".

Client - SBO Control with enhanced security 1:

This is only an exemplary implementation of the commands: select before operate with enhanced security in the TwinCAT PLC.