FB_IEC61850Server

FB_IEC61850Server 1:

With this function block you can realise a Server according to the IEC 61850 standard in the TwinCAT PLC. The connection parameters like IP-address and the application-specific parameters will be set over the input variables appPara and srvPara.

The Server block offers two actions:

VAR_INPUT

VAR_INPUT
    appPara : ST_MMS_ApplicationPara;    (* Application parameter *)
    srvPara : ST_MMS_ProtocolPara;  (* Communication parameter *)
    pLD     : DWORD := 0;         (* Pointer to logical device node *)
    cbLD    : UDINT := 0;         (* Byte size of logical device node *)
END_VAR

appPara: Application-specific configuration parameters (MMS and IEC 61850 parameter).

srvPara: Parameters that basically affect the configuration of the communication stack beneath MMS.

pLD: Pointer (address) on the instance of the structure with the model description of the logical device (LD). The address can be determined with the ADR operator.

cbLD: Size of the byte of the structure with the model description of the logical device (LD). The size of the byte can be determined with the SIZEOF operator.

VAR_OUTPUT

VAR_OUTPUT
    system : ST_IED_System;
    eState : E_IED_STATE;
END_VAR

system: System variable.

eState : Device status.

Example:

You can find further examples including every source under: Examples.

PROGRAM MAIN
VAR
    bInit   : BOOL := TRUE;
    bOperate    : BOOL := TRUE;
    bServer     : FB_IEC61850Server := (    srvPara := (    sHost := '127.0.0.1',(* change the IP-Address to meet your needs *)
                            debug := ( bError := TRUE, bLog := TRUE ) ) );(* Server instance *)

    fbChange : FB_ACSI_ChangePresence;(* This function block changes the mandatory/optional presence parameter *)
 Relay   : ST_LD_Relay;(* Our logical device *)
END_VAR
IF bInit THEN
    bInit := FALSE;
    fbServer.appPara.bAccessCtrl := FALSE; (* TRUE = Use access control/authentication, FALSE = Don't use access control/authentication *)
 (* first user *)
    fbServer.appPara.accessCtrl[1].bAuthentication := TRUE;(* TRUE = access control/authentication for this user enabled, FALSE = Disabled *)
 fbServer.appPara.accessCtrl[1].authentMechanism := '2.2.3.1';
    fbServer.appPara.accessCtrl[1].authentPassword := 'PASSWORD';
    (* second user *)
    fbServer.appPara.accessCtrl[2].bAuthentication := TRUE;
    fbServer.appPara.accessCtrl[2].authentMechanism := '2.2.3.1';
    fbServer.appPara.accessCtrl[2].authentPassword := 'OTHER';

  (* at this point you can change the presence of some attributes... *)

    (* change presence of some attributes *)
(*      fbChange( pDO := ADR( Relay.LLN0.Loc.subEna ), cbDO := SIZEOF(  Relay.LLN0.Loc.subEna ), bPresence := TRUE );*)(* change to mandatory *)
(*      fbChange( pDO := ADR( Relay.LLN0.Loc.t ), cbDO := SIZEOF(  Relay.LLN0.Loc.t ), bPresence := FALSE );*)(* change to optional *)

    fbServer.A_INIT( pLD := ADR( Relay ), cbLD := SIZEOF( Relay ) );
END_IF

IF bOperate THEN(* switch to oparating state *)
    IF fbServer.eState = eIED_STATE_PREOP THEN
        bOperate := FALSE;

        (* at this point you can configure your data sets...*)

        fbServer.A_OPERATE( pLD := ADR( Relay ), cbLD := SIZEOF( Relay ) );
    END_IF
END_IF

fbServer( pLD   := ADR( Relay ), cbLD := SIZEOF( Relay ) );

Requirements

Development environment

Target system

PLC libraries to include

TwinCAT v2.10.0 Build >= 1340

PC or CX (X86, ARM)

TcIEC61850Server.Lib