Client - Direct Control with enhanced security
This sample shows the exemplary implementation of direct control with enhanced security (ctlModel := 3, direct control with enhanced security) in a TwinCAT IEC 61850 client project for the following switch control data classes (Common Data Class, CDC):
- SPC (controllable single point) object
- DPC (controllable double point) object
- APC (controllable analogue process value) object
- BAC (binary controlled analogue process value) object
- BSC (binary controlled step position information) object
- ENC (controllable enumerated status) object: Mod
- INC (controllable integer status) object
- ISC (integer controlled step position information) object
Download TwinCAT XAE Project (*.zip): Sample06.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.
An additional, self-implemented function block is required to implement the direct commands. In the sample a new function block: "FB_DIRwControl" has been added for this purpose. The function block: "FB_DIRwControl" handles the actual command execution for the different CDC types. In the modified State 10 several IF statements are listed, which enable the command execution of the client via the instance of the "FB_DIRwControl" function block.
Several Boolean variables are defined in the declaration part of "FB_IEDClient". A rising edge at the corresponding Boolean variable enables command execution in the IF statement. The user can initiate this via the online values in the application.
Methods of the "FB_DIRwControl" function block
Method name | Description |
---|---|
APC BAC BSC DPC ENC_Mod INC ISC SPC | A method is added for each controllable CDC, as most CDCs use different control value 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 state machine of the "FB_IEDClient" function block is set to State 11 as soon as a command has been initiated and successfully executed. The state machine waits here until the command has been successfully executed. For this purpose, the "Execute" method is called in every cycle in State 11 and it is possible, on the basis of the "ipResult" feedback interface pointer, 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 Sample04 with the implementation example for "Direct control with normal security", the user receives the event "OnCommandTerminationInd" at the "FB_IEDClient" function block when the "Direct control with enhanced security" is successfully executed. If an error occurs when executing the command, the user receives the event "OnLastApplErrorInd".
![]() | This is only an exemplary implementation of the direct control with enhanced security in the TwinCAT PLC. |