Notes on the documentation

This description is only intended for the use of trained specialists in control and automation engineering who are familiar with the applicable national standards.
It is essential that the following notes and explanations are followed when installing and commissioning these components.

The responsible staff must ensure that the application or use of the products described satisfy all the requirements for safety, including all the relevant laws, regulations, guidelines and standards.

Disclaimer

The documentation has been prepared with care. The products described are, however, constantly under development.
For that reason the documentation is not in every case checked for consistency with performance data, standards or other characteristics.
In the event that it contains technical or editorial errors, we retain the right to make alterations at any time and without warning.
No claims for the modification of products that have already been supplied may be made on the basis of the data, diagrams and descriptions in this documentation.

Trademarks

Beckhoff®, TwinCAT®, EtherCAT®, Safety over EtherCAT®, TwinSAFE® and XFC® are registered trademarks of and licensed by Beckhoff Automation GmbH.
Other designations used in this publication may be trademarks whose use by third parties for their own purposes could violate the rights of the owners.

Patent Pending

The TwinCAT Technology is covered, including but not limited to the following patent applications and patents:
EP0851348, US6167425 with corresponding applications or registrations in various other countries.

Copyright

© Beckhoff Automation GmbH & Co. KG, Germany.
The reproduction, distribution and utilization of this document as well as the communication of its contents to others without express authorization are prohibited.
Offenders will be held liable for the payment of damages. All rights reserved in the event of the grant of a patent, utility model or design.


Overview

The TwinCAT PLC Library TcIEC870_5_101.Lib implements the connection functions and data structures according to IEC60870-5-101.


FB_IEC870_5_101ErrorFifo

TwinCAT PLC Library: IEC 60870-5-101 Common Data Types

FUNCTION_BLOCK FB_IEC870_5_101ErrorFifo

IEC60870-5-10x error FIFO. The oldest entry is overwritten. The FIFO has a constant size, determined by the constant: IEC870_MAX_ERROR_FIFO_SIZE (default: 10 elements).

The function block features three tasks:

  • AddError (adds a new error message to the FIFO);
  • RemoveError (removes the oldest error message from the FIFO);
  • Reset (clears all error messages and resets the FIFO);

Error messages are normally added to the FIFO via the internal IEC60870-5-10x device functions. The PLC application can read and analyse these error messages by calling the task: RemoveError.

VAR_INPUT

VAR_INPUT
    putError 	: ST_IEC870_5_101ErrorFifoEntry;
END_VAR

putError: Error message to be added to the FIFO.

VAR_OUTPUT

VAR_OUTPUT
    getError 	: ST_IEC870_5_101ErrorFifoEntry;
    nErrors 		: UDINT; (* Error counter *)
    bOk 		: BOOL; (* TRUE = new entry added or removed succesfully, FALSE = fifo empty *)
END_VAR

getError: Error message to be removed from the FIFO.

nErrors: Returns the current number of FIFO entries (error messages in the FIFO).

bOk: This variable becomes TRUE if a new entry was successfully added to or removed from the FIFO.

Example of call in ST:

In the following structured text example the device error FIFO is read, and the registered errors are written into the Windows Application Log.

PROGRAM P_LogErrors
VAR_IN_OUT
    fbErrors : FB_IEC870_5_101ErrorFifo;
END_VAR
REPEAT
    fbErrors.RemoveError();
    IF fbErrors.bOk THEN
        ADSLOGSTR( ADSLOG_MSGTYPE_ERROR OR ADSLOG_MSGTYPE_LOG,
            'IEC60870-5-10x device error: 0x%s',
            DWORD_TO_HEXSTR( fbErrors.getError.nErrId, 8, FALSE) );
    END_IF
UNTIL NOT fbErrors.bOk
END_REPEAT

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


FB_IEC870_5_101TBufferCtrl

FUNCTION_BLOCK FB_IEC870_5_101TBufferCtrl

From product version: TwinCAT PLC Library IEC60870-5-104 substation v2.0.6 / IEC60870-5-101 substation v2.0.2 and higher.

This function block changes the content of the TX/RX data buffer. This data buffer ist used by the communication via the IEC60870-5-104/101 Transport Interface.

The function block has the following actions:

  • RxRemoveObj (removes the oldest Fifo entry from the RX-Fifo);
  • RxReset (deletes all RX-Fifo entries,resets the RX-Fifo);
  • TxAddObj (inserts a new Fifo entry in the TX-Fifo);
  • TxReset (deletes all TX-Fifo entries, resets the TX-Fifo)

The content of the TX/RX data buffer can be changed by the call of one of the listed actions above.

VAR_IN_OUT

VAR_IN_OUT
    buffer 	: ST_IEC870_5_101TBuffer; (* TX/RX data buffer *)
END_VAR

buffer: TX/RX data buffer. The TX/RX buffer parameters (like e.g. asduSize ) have to be configured before using.

VAR_INPUT

VAR_INPUT
    putObj 	: ST_IEC870_5_101AOGen; (* ASDU to send *)
END_VAR

putObj: Data unit (ASDU) to be sent.

VAR_OUTPUT

VAR_OUTPUT
    getObj 	: ST_IEC870_5_101AOGen; (* received ASDU *)
    bOk 	: BOOL; (* TRUE = action succesfully, FALSE=Fifo overflow or fifo empty *)
END_VAR

getObj: Received data unit (ASDU).

bOk: This variable becomes TRUE, if a new entry was inserted or removed successfully from the Fifo. This variable becomes FALSE at a buffer overflow and if no entry could be removed, because the Fifo was already emty.

Example in ST:

The following example code shows the using of theactions. Each ~100ms (tCycle) a new ASDU (M_BO_TB_1) with the transmission cause spontaneous and time stamp will be created and stored in the TX-Fifo.
The received test commands (C_TS_TA_1) and time synchronisation commands (C_CS_NA_1) are removed from the RX-Fifo and answered with mirrored ASDUs

PROGRAM P_SAMPLE_1ms
VAR
    (* TX/RX data buffer *)
    fbBuffer 	: FB_IEC870_5_101TBufferCtrl;
    buffer 		: ST_IEC870_5_101TBuffer := ( asduSize := 253 );

    tCycle 	: TIME := T#100ms;
    timer 	: TON;
    dtStart 	: DT := DT#2006-07-05-12:34:56;

    txAsdu 	: ST_IEC870_5_101AOGen;
    rxAsdu 	: ST_IEC870_5_101AOGen;

    txBSI 	: DWORD := 1;
    txQDS 	: BYTE;
    txTT 	: T_CP56Time2a;
    rxTT 	: T_CP56Time2a;
END_VAR

timer( IN := TRUE, PT := tCycle );
IF timer.Q THEN
    timer( IN := FALSE );

    txAsdu.ident.eType := M_BO_TB_1; (* Bit string with time tag *)
    txAsdu.ident.bSQ := FALSE;
    txAsdu.ident.nObj := 1;
    txAsdu.ident.eCOT := eIEC870_COT_SPONTAN;
    txAsdu.ident.nORG := 1;
    txAsdu.ident.bPN := FALSE;
    txAsdu.ident.bT := FALSE;
    txAsdu.ident.eClass := eIEC870_Class_1;
    txAsdu.ident.asduAddr := 7;
    txAsdu.info.objAddr := 100;

    txBSI := ROL( txBSI, 1); (* Modify bit string value *)
    txQDS.7 := NOT txQDS.7; (* Toggle IV quality flag *)

    (* create dummy time tag *)
    dtStart := dtStart + tCycle;
    txTT := SYSTEMTIME_TO_CP56Time2a( DT_TO_SYSTEMTIME( dtStart ), TRUE );

    F_iecResetStream( 0, txAsdu.info.stream ); (* clear previous data (this sets the stream length = 0 *)
    F_iecCopyBufferToStream( ADR( txBSI ), SIZEOF( txBSI ), txAsdu.info.stream ); (* put BSI to stream *)
    F_iecCopyBufferToStream( ADR( txQDS ), SIZEOF( txQDS ), txAsdu.info.stream ); (* put QDS to stream *)
    F_iecCopyBufferToStream( ADR( txTT ), SIZEOF( txTT ), txAsdu.info.stream ); (* put time tag to stream *)

    fbBuffer.TxAddObj( putObj := txAsdu, buffer := buffer ); (* put asdu to the TX fifo *)
    IF NOT fbBuffer.bOk THEN
        ;(* Report send buffer overflow error *)
    END_IF
END_IF

REPEAT
fbBuffer.RxRemoveObj( getObj=>rxAsdu, buffer := buffer ); (* Try to remove asdu from RX fifo *)
IF fbBuffer.bOk THEN (* success *)

    CASE rxAsdu.ident.eType OF
    C_TS_TA_1: (* Test command *)

        txAsdu := rxAsdu;
        txAsdu.ident.eCOT := eIEC870_COT_ACT_CON; (* send activation confirmation *)

        fbBuffer.TxAddObj( putObj := txAsdu, buffer := buffer ); (* put asdu to the TX fifo *)
        IF NOT fbBuffer.bOk THEN
            ;(* Report send buffer overflow error *)
        END_IF

    C_CS_NA_1: (* clock synchronisation *)

        F_iecCopyStreamToBuffer( ADR( rxTT ), SIZEOF( rxTT ), rxAsdu.info.stream );

        (*... *)

        txAsdu := rxAsdu; (* dummy old time value *)
        txAsdu.ident.eCOT := eIEC870_COT_ACT_CON; (* send activation confirmation *)

        fbBuffer.TxAddObj( putObj := txAsdu, buffer := buffer ); (* put asdu to the TX fifo *)
        IF NOT fbBuffer.bOk THEN
            ;(* Report send buffer overflow error *)
        END_IF

    END_CASE

END_IF
UNTIL NOT fbBuffer.bOk (* RX fifo is empty *)
END_REPEAT

Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


FB_IEC870_5_101FBufferCtrl

FUNCTION_BLOCK FB_IEC870_5_101FBufferCtrl

From product version: TwinCAT PLC Library IEC60870-5-101/104 substation v3.0.2 / IEC60870-5-104 controlling station v1.0.2 and higher.

This function block allows the contents of the TX/RX data buffer that is used for communication through the IEC60870-5-104/101 (low level) transport interface to be manipulated. In addition, the ASDUs that are to be transmitted (only in the TX direction) are buffered in the file if the connection to the central station is interrupted (in offline mode). The functionality is similar to that of the FB_IEC870_5_101TBufferCtrl function block.

The function block features the following tasks:

  • RxRemoveObj (removes the oldest FIFO entry from the RX FIFO);
  • RxReset (clears all the RX FIFO entries, resets the RX FIFO);
  • TxAddObj (inserts a new FIFO entry into the TX FIFO);
  • TxReset (clears all the TX FIFO entries, resets the TX FIFO);

The content of the TX/RX data buffer can be changed by calling the actions listed above.

VAR_IN_OUT

VAR_IN_OUT
    bOnline 	: BOOL; (* TRUE => route frames to the link layer, FALSE => route frames to the file buffer *)
    buffer 	: ST_IEC870_5_101TBuffer; (* TX/RX data buffer *)
END_VAR

bOnline: This input tells the function block whether the connection is in offline or online mode. TRUE = online, FALSE = offline. In offline mode, the ASDUs that are to be transmitted are buffered in a file. In online mode, the ASDUs that are buffered in the file are taken out of the file and sent to the central station.

buffer: TX/RX data buffer. The TX/RX buffer parameters (such as asduSize) must be configured before use.

VAR_INPUT

VAR_INPUT
    config 	: ST_IEC870_5_101FBufferCfg; (* File buffer configuration settings *)
    putObj 	: ST_IEC870_5_101AOGen; (* ASDU to send *)
END_VAR

config: offline file buffer configuration settings.

putObj: data unit (ASDU) that is to be transmitted.

VAR_OUTPUT

VAR_OUTPUT
    status 	: ST_IEC870_5_101FBufferStatus; (* File buffer status *)
    getObj 	: ST_IEC870_5_101AOGen; (* received ASDU *)
    bOk 	: BOOL; (* TRUE = action succesfully, FALSE=Fifo overflow or fifo empty *)
END_VAR

status: Offline data buffer status information.

getObj:: Received data unit (ASDU).

bOk: This variable becomes TRUE if a new entry was successfully added to or removed from the FIFO. This variable becomes FALSE if the buffer overflows and if it is not possible to remove an entry because the FIFO is already empty.

Example in ST:

The following fragment of example code demonstrates the use of the function block actions. Approximately every 1s (tCycle) a new ASDU (M_BO_TB_1) is generated with "spontaneous" as the transmission cause and with a timestamp, and is placed in the TX FIFO.
The test command (C_TS_TA_1) and clock synchronisation command (C_CS_NA_1) received are removed from the RX FIFO, and replied to with reflected ASDUs.

The VAR_IN_OUT variable bOnline is used to control the storage or loading of the ASDUs in the file. If bOnline = FALSE the file is opened, and all the TX ASDUs that arise are written into the file in the background. If bOnline = TRUE the ASDUs are taken out of the file in the background and transmitted. In order for saving and loading of the buffer file in the background to be possible, the FB_IEC870_5_101FBufferCtrl function block must be called cyclically. The insertion of new TX ASDUs or the editing of old RX ASDUs is not affected by saving or loading data into or out of the file.

PROGRAM P_ProcessSlaveBufferData
VAR_IN_OUT
    bOnline : BOOL;
    buffer : ST_IEC870_5_101TBuffer;
END_VAR
VAR
    asduAddr : DWORD := 7; (* Common asdu address *)

    fbBuffer : FB_IEC870_5_101FBufferCtrl :=( config := ( sPathName := 'c:\tmp\OfflineAsdu.dat',
                            bOverwrite := TRUE,
                        cbBuffer := 16#100000 )); (* RX/TX buffer control function block *)

    txAsdu : ST_IEC870_5_101AOGen; (* asdu to send *)
    txTT : T_CP56Time2a; (* time tag to send *)

    rxAsdu : ST_IEC870_5_101AOGen; (* received asdu *)
    rxTT : T_CP56Time2a; (* received time tag *)

    rxQOI : BYTE; (* qualifier of interrogation command *)
    txBSI : DWORD := 1; (* bit string value *)
    txQDS : BYTE; (* bit string quality descriptor *)
    tCycle : TIME := T#1s;
    bSpont : BOOL := TRUE;
    timer : TON;
    fbRTC : RTC_EX2 := ( EN := TRUE, PDT := ( wYear := 2006, wMonth := 8, wDay := 17, wHour := 12, wMinute := 23 ) );
END_VAR
timer( IN := bSpont, PT := tCycle );
IF timer.Q THEN
    timer( IN := FALSE ); timer( IN := bSpont );

    txBSI := ROL( txBSI, 1); (* Modify bit string value *)
    txQDS.7 := NOT txQDS.7; (* Toggle IV quality flag *)

    (* create dummy time tag *)
    fbRTC();
    txTT := SYSTEMTIME_TO_CP56Time2a( fbRTC.CDT, TRUE );

    (* create asdu *)
    txAsdu.ident.eType := M_BO_TB_1; (* Bit string with time tag *)
    txAsdu.ident.bSQ := FALSE;
    txAsdu.ident.nObj := 1;
    txAsdu.ident.eCOT := eIEC870_COT_SPONTAN;
    txAsdu.ident.nORG := 1;
    txAsdu.ident.bPN := FALSE;
    txAsdu.ident.bT := FALSE;
    txAsdu.ident.eClass := eIEC870_Class_1;
    txAsdu.ident.asduAddr := asduAddr;
    txAsdu.info.objAddr := 100;
    F_iecResetStream( 0, txAsdu.info.stream ); (* clear previous data (this sets the stream length = 0 *)
    F_iecCopyBufferToStream( ADR( txBSI ), SIZEOF( txBSI ), txAsdu.info.stream ); (* put BSI to stream *)
    F_iecCopyBufferToStream( ADR( txQDS ), SIZEOF( txQDS ), txAsdu.info.stream ); (* put QDS to stream *)
    F_iecCopyBufferToStream( ADR( txTT ), SIZEOF( txTT ), txAsdu.info.stream ); (* put time tag to stream *)

    fbBuffer.TxAddObj( bOnline := bOnline, putObj := txAsdu, buffer := buffer ); (* put asdu to the TX fifo *)
    IF NOT fbBuffer.bOk THEN
        RETURN;
        (* TODO: Report send buffer overflow error *)
    END_IF
END_IF

REPEAT
    fbBuffer.RxRemoveObj( bOnline := bOnline, getObj=>rxAsdu, buffer := buffer ); (* Try to remove asdu from RX fifo *)
    IF fbBuffer.RxRemoveObj.bOk THEN (* success *)
        CASE rxAsdu.ident.eType OF

        C_TS_NA_1: (* Simple test command implementation *)

        txAsdu := rxAsdu;
        txAsdu.ident.eCOT := eIEC870_COT_ACT_CON; (* send activation confirmation *)
        fbBuffer.TxAddObj( bOnline := bOnline, putObj := txAsdu, buffer := buffer ); (* put asdu to the TX fifo *)
        IF NOT fbBuffer.bOk THEN
            EXIT;
            (* TODO: Report send buffer overflow error *)
        END_IF

        C_CS_NA_1: (* Simple clock synchronisation command implementation *)

        F_iecCopyStreamToBuffer( ADR( rxTT ), SIZEOF( rxTT ), rxAsdu.info.stream );

        (*... *)

        txAsdu := rxAsdu; (* dummy old time value *)
        txAsdu.ident.eCOT := eIEC870_COT_ACT_CON; (* send activation confirmation *)
        fbBuffer.TxAddObj( bOnline := bOnline, putObj := txAsdu, buffer := buffer ); (* put asdu to the TX fifo *)
        IF NOT fbBuffer.bOk THEN
            EXIT;
            (* TODO: Report send buffer overflow error *)
        END_IF

        C_IC_NA_1: (* Simple interrogation command implementation *)

        txAsdu := rxAsdu;
        txAsdu.ident.eCOT := eIEC870_COT_ACT_CON; (* send activation confirmation *)
        fbBuffer.TxAddObj( bOnline := bOnline, putObj := txAsdu, buffer := buffer ); (* put asdu to the TX fifo *)
        IF NOT fbBuffer.bOk THEN
            EXIT;
            (* TODO: Report send buffer overflow error *)
        END_IF

        F_iecCopyStreamToBuffer( ADR( rxQOI ), SIZEOF(rxQOI), rxAsdu.info.stream );

        (* create asdu *)
        txAsdu.ident.eType := M_BO_NA_1; (* Bit string without time tag! *)
        txAsdu.ident.bSQ := FALSE;
        txAsdu.ident.nObj := 1;
        txAsdu.ident.eCOT := BYTE_TO_INT( rxQOI );
        txAsdu.ident.nORG := 1;
        txAsdu.ident.bPN := FALSE;
        txAsdu.ident.bT := FALSE;
        txAsdu.ident.eClass := eIEC870_Class_1;
        txAsdu.ident.asduAddr := asduAddr;
        txAsdu.info.objAddr := 100;
        F_iecResetStream( 0, txAsdu.info.stream ); (* clear previous data (this sets the stream length = 0 *)
        F_iecCopyBufferToStream( ADR( txBSI ), SIZEOF( txBSI ), txAsdu.info.stream ); (* put BSI to stream *)
        F_iecCopyBufferToStream( ADR( txQDS ), SIZEOF( txQDS ), txAsdu.info.stream ); (* put QDS to stream *)
        fbBuffer.TxAddObj( bOnline := bOnline, putObj := txAsdu, buffer := buffer ); (* put asdu to the TX fifo *)
        IF NOT fbBuffer.bOk THEN
            EXIT;
            (* TODO: Report send buffer overflow error *)
        END_IF

        txAsdu := rxAsdu;
        txAsdu.ident.eCOT := eIEC870_COT_ACT_TERM; (* send activation termination *)
        fbBuffer.TxAddObj( bOnline := bOnline, putObj := txAsdu, buffer := buffer ); (* put asdu to the TX fifo *)
        IF NOT fbBuffer.bOk THEN
            EXIT;
            (* TODO: Report send buffer overflow error *)
        END_IF

        ELSE
            (* TODO: Report invalid asdu type...*)
            EXIT;
        END_CASE

    END_IF
UNTIL NOT fbBuffer.bOk (* RX fifo is empty *)
END_REPEAT

(* Offline frames are written to the file. Execute this function block in every cycle! *)
fbBuffer(bOnline := bOnline, buffer:= buffer );
IF fbBuffer.status.eState = eIEC870_FBUFFER_ERROR THEN
    (*TODO: Report file access error *)
    ;
END_IF

Development environment | Target system type | PLC libraries to be linked
TwinCAT v2.10.0 Build >= 1313 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib are included automatically )


FB_IEC870_5_101TableEventHandler

FUNCTION_BLOCK FB_IEC870_5_101TableEventHandler

From product version: TwinCAT PLC Library IEC60870-5-104 controlling station v1.0.0 and higher.

Note!

Reading of the events is optional, i.e. the PLC application does not necessarily have to instance this block. This functionality is currently only supported by the IEC 60870-5-104 master!

This function block enables the PLC application to detect certain changes in the IEC application object database and respond accordingly, if required. The changes are referred to as events. Each event type is managed in a separate internal list. The PLC application can read the pending events from one of the lists by calling the block actions. The events are counted internally since several events may occur during a PLC cycle. The counter is incremented whenever an event occurs. At the block output only the last value and the counter reading is issued.

The following events are registered by the function block:

  • OnCreate events are reported whenever a new application object (single point, double point, measured value...) was added to the application database.
  • OnChange events are reported when an application object is received by the lower transport layer (Rx frames) or sent (Tx frames), irrespective of whether the value of the information object has actually changed or not. For a direct command, e.g. C_SC_NA_1, in control direction (master->slave), events are usually reported for the following causes of transmission: eIEC870_COT_ACT (activation), eIEC870_COT_ACT_CON (confirmation of activation) and eIEC870_COT_TERM (completion of activation). For a data point in monitoring direction (slave->master), e.g. M_SP_NA_1, events may be reported for the following causes of transmission: eIEC870_COT_SPONTAN, eIEC870_COT_INROGEN, eIEC870_COT_BACKGROUND etc.

The function block features two tasks:

  • RemoveOnCreateEvent (reads an entry from the OnCreate event list);
  • RemoveOnChangeEvent (reads an entry from the OnChange event list);

VAR_IN_OUT

VAR_IN_OUT
    hTable : T_HAODBTable;
END_VAR

hTable: Application object database handle (hash table handle). The table handle must be initialised once with the function F_iecCreateTableHnd before it can be used.

VAR_OUTPUT

VAR_OUTPUT
    bOk 	: BOOL := FALSE;
    getObj 	: ST_IEC870_5_101AOGen;
    getCfg 	: ST_IEC870_5_101AOCfg;
    nEvents 	: DWORD := 0;
END_VAR

bOk: This variable becomes TRUE if a new event was read successfully. If FALSE, the event list read last is empty.

getObj: The current value of the data unit (ASDU).

getCfg: The current configuration parameters of the data unit (ASDU).

nEvents: Event counter (multiplier). Value range: (0 to 16#FFFFFFFF). Incrementation stops when the maximum value is reached.

Example in ST:

In the following program section the pending events are read via REPEAT loops and written to the Windows Application log. The associated data points have already been configured as hash table entries. See function description: F_iecAddTableEntry.

PROGRAM P_LogEvents
VAR_IN_OUT
    hTable : T_HAODBTable;
END_VAR
VAR
    fbHandler : FB_IEC870_5_101TableEventHandler;
END_VAR
REPEAT
    fbHandler.RemoveOnChangeEvent( hTable := hTable );
    IF fbHandler.bOk THEN
        ADSLOGSTR( ADSLOG_MSGTYPE_HINT OR ADSLOG_MSGTYPE_LOG,
            'RemoveOnChangeEvent(), IOA: %s',
            DWORD_TO_STRING( fbHandler.getObj.info.objAddr ) );
    END_IF
UNTIL NOT fbHandler.bOk
END_REPEAT

REPEAT
    fbHandler.RemoveOnCreateEvent( hTable := hTable );
    IF fbHandler.bOk THEN
        ADSLOGSTR( ADSLOG_MSGTYPE_HINT OR ADSLOG_MSGTYPE_LOG,
            'RemoveOnCreateEvent(), IOA: %s',
            DWORD_TO_STRING( fbHandler.getObj.info.objAddr ) );
    END_IF
UNTIL NOT fbHandler.bOk
END_REPEAT

Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


F_iecInitAOEntry

FUNCTION F_iecInitAOEntry

The function F_iecInitAOEntry configures application objects (Single Points, Double Points, Measured Values...) as linear table entries. The table element (array element ) to be configured has to be given to the function as VAR_IN_OUT function parameter.

FUNCTION F_iecInitAOEntry: UDINT

VAR_INPUT
    eType 		: E_IEC870_5_101TcTypeID := ASDU_TYPEUNDEF;
    objAddr 		: DWORD := 0;
    group 		: DWORD := 0;
    multiplier 	: BYTE := 0;
    ioMapType 	: E_IEC870_5_101IOMappingType := MAP_AREA_NONE;
    byteOffs 	: UDINT := 0;
    bitOffs 		: UDINT := 0;
END_VAR
VAR_IN_OUT
    dbEntry 		: ST_IEC870_5_101AODBEntry;
END_VAR

eType: Type of application object, ASDU identifier (e.g..: M_SP_NA_1 for Single Point or M_DP_NA_1 for Double Point ).

objAddr : Object address, any address can be given.

group: Object group configuration flags. See: Description of all Group Flags. The flags can be combined with OR-Linking. Not all combinations are sensefull!

multiplier: Base cycle time multiplicator for cyclic/periodic data transfer. 0 = disabled. The base cycle time can be configured by the tPerCyclicBase- parameter in the system parameters.

ioMapType: TwinCAT PLC process data range. This parameter defines how the TwinCAT PLC and IEC applicatation object process data are to be mapped.

byteOffs: TwinCAT PLC process data byte offset.

bitOffs: TwinCAT PLC process data bit offset.

dbEntry: Application object to be configured (array element).

Return value | Description
0 | No error.
<> 0 | Error: IEC60870-5-10x error code

Example in ST:

Configuration of three datapoints as linear table entries.

eType | objAddr | group | multiplier | ioMapType | byteOffs | bitOffs
M_SP_NA_1 | 100 | IEC870_GRP_INRO1 | 0 | MAP_AREA_MEMORY | 100 | 0
M_DP_NA_1 | 200 | IEC870_GRP_INROGEN | 0 | MAP_AREA_DATA | 200 | 0
M_IT_NA_1 | 800 | IEC870_GRP_REQCOGEN | 0 | MAP_AREA_MEMORY | 800 | 0
VAR_GLOBAL CONSTANT
    MIN_TABLE_IDX : INT := 0;
    MAX_TABLE_IDX : INT := 49;
END_VAR
PROGRAM P_LinearTableConfig
VAR_IN_OUT
    AODB : ARRAY[MIN_TABLE_IDX..MAX_TABLE_IDX] OF ST_IEC870_5_101AODBEntry;
END_VAR
VAR
    init 		: BOOL := TRUE;
    initError 	: UDINT;
END_VAR
IF init THEN
    init := FALSE;
    initError := F_iecInitAOEntry( 	eType 		:= M_SP_NA_1,
                    objAddr 		:= 100,
                    group 		:= IEC870_GRP_INRO1,
                    multiplier 	:= 0,
                    ioMapType 	:= MAP_AREA_MEMORY,
                    byteOffs 	:= 100,
                    bitOffs 		:= 0,
                    dbEntry 		:= AODB[0] );
    IF initError <> 0 THEN
        ADSLOGSTR( ADSLOG_MSGTYPE_ERROR OR ADSLOG_MSGTYPE_LOG,
            'F_iecInitAOEntry() error: %s',
            DWORD_TO_HEXSTR( initError, 8, FALSE ) );
        RETURN;
    END_IF

    initError := F_iecInitAOEntry( 	eType 		:= M_DP_NA_1,
                    objAddr 		:= 200,
                    group 		:= IEC870_GRP_INROGEN,
                    multiplier 	:= 0,
                    ioMapType 	:= MAP_AREA_DATA,
                    byteOffs 	:= 200,
                    bitOffs 		:= 0,
                    dbEntry 		:= AODB[1] );
    IF initError <> 0 THEN
        ADSLOGSTR( ADSLOG_MSGTYPE_ERROR OR ADSLOG_MSGTYPE_LOG,
            'F_iecInitAOEntry() error: %s',
            DWORD_TO_HEXSTR( initError, 8, FALSE ) );
        RETURN;
    END_IF

    initError := F_iecInitAOEntry( 	eType 		:= M_IT_NA_1,
                    objAddr 		:= 800,
                    group 		:= IEC870_GRP_REQCOGEN,
                    multiplier 	:= 0,
                    ioMapType 	:= MAP_AREA_MEMORY,
                    byteOffs 	:= 800,
                    bitOffs 		:= 0,
                    dbEntry 		:= AODB[2] );
    IF initError <> 0 THEN
        ADSLOGSTR( ADSLOG_MSGTYPE_ERROR OR ADSLOG_MSGTYPE_LOG,
            'F_iecInitAOEntry() error: %s',
            DWORD_TO_HEXSTR( initError, 8, FALSE ) );
        RETURN;
    END_IF

END_IF
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


F_iecSetAOQuality

FUNCTION F_iecSetAOQuality

This function sets / resets the quality flags of an application object to a defined value.

FUNCTION F_iecSetAOQuality: UDINT

VAR_INPUT
    QMsk : DWORD;
END_VAR
VAR_IN_OUT
    dbEntry 	: ST_IEC870_5_101AODBEntry;
    device 	: ST_IEC870_5_101DeviceInterface;
END_VAR

QMsk : Quality-Flags. The Quality-Flags can be combined with OR Linking. If QMsk = zero, no flags are set/reset. See: List of available quality-flags.

dbEntry: Application object whose status of the Quality-Flags are to be set.

device: Communication interface of IEC device.

Return parameter | Description
0 | No error
<> 0 | error: IEC60870-5-10x error code

Example for a call in ST:

PROGRAM MAIN
VAR
    slave1AODB : ARRAY[1..199] OF ST_IEC870_5_101AODBEntry;

    server1 : FB_IEC870_5_104Slave;
...

    bBlock : BOOL;
    bUnblock : BOOL;
    bIsBlocked : BOOL;
END_VAR

Program code:

IF bBlock THEN
    bBlock := FALSE;
    F_iecSetAOQuality( IECQ_BL_ON, slave1AODB[1], server1.system.device );
END_IF

IF bUnblock THEN
    bUnblock := FALSE;
    F_iecSetAOQuality( IECQ_BL_OFF, slave1AODB[1], server1.system.device );
END_IF

bIsBlocked := SEL( ( F_iecGetAOQuality( slave1AODB[1], server1.system.device ) AND IECQ_BL_ON ) = IECQ_BL_ON, FALSE, TRUE );

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


F_iecGetAOQuality

FUNCTION F_iecGetAOQuality

This function reads the status of the qualitiy flag of an application object.

FUNCTION F_iecGetAOQuality: DWORD

VAR_IN_OUT
    dbEntry 	: ST_IEC870_5_101AODBEntry;
    device	: ST_IEC870_5_101DeviceInterface;
END_VAR

dbEntry : Application object whose qualitiy flags are to be read.

device: Communication interface to IEC device.

Return parameter | Description
0 | error , no qualtiy flag for this application object available.
<> 0 | No error. The return parameter delivers the status of the Quality-Flags. See: available Quality-Flags.

Example for a call in ST:

PROGRAM MAIN
VAR
    slave1AODB : ARRAY[1..199] OF ST_IEC870_5_101AODBEntry;

    server1 : FB_IEC870_5_104Slave;
...

    bBlock : BOOL;
    bUnblock : BOOL;
    bIsBlocked : BOOL;
END_VAR

Program code:

IF bBlock THEN
    bBlock := FALSE;
    F_iecSetAOQuality( IECQ_BL_ON, slave1AODB[1], server1.system.device );
END_IF

IF bUnblock THEN
    bUnblock := FALSE;
    F_iecSetAOQuality( IECQ_BL_OFF, slave1AODB[1], server1.system.device );
END_IF

bIsBlocked := SEL( ( F_iecGetAOQuality( slave1AODB[1], server1.system.device ) AND IECQ_BL_ON ) = IECQ_BL_ON, FALSE, TRUE );
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


F_iecGetAOTimeTag

FUNCTION F_iecGetAOTimeTag

This function reads the current timestamp in a byte buffer of an application object.

FUNCTION F_iecGetAOTimeTag: UDINT

VAR_INPUT
    pDest 	: DWORD; (* Pointer to time tag destination buffer *)
    cbDest 	: UDINT; (* Byte size of time tag destination buffer *)
END_VAR
VAR_IN_OUT
    dbEntry 	: ST_IEC870_5_101AODBEntry;
END_VAR

pDest : Buffer address.

cbDest: Byte size of the buffer.

dbEntry: Application object whose timestamp is to be read.

Return parameter | Description
0 | Error, no timestamp for this application object available.
<> 0 | Number of successfull copied time stamp data bytes. These are 3 bytes for the CP24Time2a time stamp format and 7 bytes for the CP56Time2a time stamp format.

Example for a call in ST:

PROGRAM MAIN
VAR
(*...*)
    TT1		: T_CP56Time2a;
    TTSize     	: UDINT;
    bGetTT     	: BOOL;
END_VAR
IF bGetTT THEN
    bGetTT 	:= FALSE;
    TTSize 	:= F_iecGetAOTimeTag( ADR( TT1 ), SIZEOF( TT1 ), slave1AODB[1] );
END_IF

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


F_iecIncVTI

FUNCTION F_iecIncVTI

This function increments the INT7 regulating step value. Transient bit is not changed!

FUNCTION F_iecIncVTI: BOOL

VAR_IN_OUT
    VTI : BYTE;
END_VAR

VTI: Byte to be incremented.

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


F_iecDecVTI

FUNCTION F_iecDecVTI

This function decrements the INT7 regulating step value. The transient flag is not changed!

FUNCTION F_iecDecVTI: BOOL

VAR_IN_OUT
    VTI	: BYTE;
END_VAR

VTI: Byte to be decremented.

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


SYSTEMTIME_TO_CP56Time2a

FUNCTION SYSTEMTIME_TO_CP56Time2a

The function converts the Windows Systemtime format to the CP56Time2a-Format. All reserved bits are zero.

FUNCTION SYSTEMTIME_TO_CP56Time2a: T_CP56Time2a

VAR_INPUT
    TIMESTR	 	: TIMESTRUCT;
    SU 		: BOOL;
END_VAR

TIMESTR : System time to be converted.

SU: Summer and winter time format. This information is not included in the TIMESTR format. It has to be inserted additionally! TRUE = Summer time, FALSE = Winter time.

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


CP56Time2a_TO_SYSTEMTIME

FUNCTION CP56Time2a_TO_SYSTEMTIME

This function converts the CP56Time2a- time format to the Windows system time format. The SU flag is not used.

FUNCTION CP56Time2a_TO_SYSTEMTIME: TIMESTRUCT

VAR_INPUT
    CP56Time2a 	: T_CP56Time2a;
    century 		: WORD;
END_VAR

CP56Time2a : CP56Time2a format to be converted.

century: The century (e.g. 20 for the year 2005). This information is not included in the CP56Time2a format, it has to be inserted additionally!

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


CP24IOA_TO_DWORD

FUNCTION CP24IOA_TO_DWORD

From product version: TwinCAT PLC Library IEC60870-5-104 substation v3.0.0 / IEC60870-5-104 controlling station v1.0.0 and higher.

The funktion creates a structured TwinCAT object address (3 octets). See: DWORD_TO_CP24IOA.

FUNCTION CP24IOA_TO_DWORD: DWORD

VAR_INPUT
    objAddr : T_CP24IOA;
END_VAR

objAddr : Parameter of structured TwinCAT object addresse.

Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)


DWORD_TO_CP24IOA

FUNCTION DWORD_TO_CP24IOA

From product version: TwinCAT PLC Library IEC60870-5-104 substation v3.0.0 / IEC60870-5-104 controlling station v1.0.0 and higher.

The function converts a structured TwinCAT object address into individual address parameters. See also: CP24IOA_TO_DWORD.

FUNCTION DWORD_TO_CP24IOA: T_CP24IOA

VAR_INPUT
    objAddr : DWORD(0..16777215);
END_VAR

objAddr : structured TwinCAT object address (3 octets).

Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


F_iecCopyBufferToStream

FUNCTION F_iecCopyBufferToStream

From product version: TwinCAT PLC Library IEC60870-5-104 substation v2.0.6 and higher.

This function copies data bytes from an external buffer variable to the stream variable.The memory content of the stream variable increases. The return parameter of the function delivers the number of successfull copied data bytes.

FUNCTION F_iecCopyBufferToStream: UDINT

VAR_INPUT
    pBuffer 		: DWORD;
    cbBuffer 	: UDINT;
END_VAR
VAR_IN_OUT
    stream 		: ST_IEC870_5_101Stream;
END_VAR

pBuffer: Pointer (address) of external buffer variable.

cbBuffer: Number of data bytes to be copied from the external buffer variable to the stream variable.

stream: Data buffer.

Exmple in ST:

The 4 data bytes of the txBuffer variable are copied to the stream variable by a rising edge at bTx.

PROGRAM P_CopyBufferToStream
VAR
    stream 	: ST_IEC870_5_101Stream;
    txBuffer : ARRAY[0..3] OF BYTE := 1, 2, 3, 4;
    cbTx 	: UDINT;
    bTx 	: BOOL;
END_VAR

IF bTx THEN
    bTx 	:= FALSE;
    cbTx 	:= cbTx + F_iecCopyBufferToStream( ADR( txBuffer ), SIZEOF( txBuffer ), stream );
    txBuffer[0] := txBuffer[0] + 1;
    txBuffer[1] := txBuffer[1] + 1;
    txBuffer[2] := txBuffer[2] + 1;
    txBuffer[3] := txBuffer[3] + 1;
END_IF

Memory description of stream variable before the first function call:

length | data
0 | 16#00 | 16#00 | 16#00 | 16#00 | 16#00 | ... | ... | ... | ... | ... | ... | IEC870_MAX_ASDU_DATA_BYTE

Memory description of stream variable after the first function call:

length | data
4 | 16#01 | 16#02 | 16#03 | 16#04 | ... | ... | ... | ... | ... | ... | ... | IEC870_MAX_ASDU_DATA_BYTE

Memory description of stream variable after the second function call:

length | data
8 | 16#01 | 16#02 | 16#03 | 16#04 | 16#02 | 16#03 | 16#04 | 16#05 | ... | ... | ... | IEC870_MAX_ASDU_DATA_BYTE

Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86) CX (ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


F_iecCopyStreamToBuffer

FUNCTION F_iecCopyStreamToBuffer

From product version: TwinCAT PLC Library IEC60870-5-104 substation v2.0.6 and higher.

This function copies data bytes from the stream variable to an external buffer variable. The memory content of the stream variable remains unchanged. The return parameter of the function delivers the number of successfull copied data bytes.

FUNCTION F_iecCopyStreamToBuffer: UDINT

VAR_INPUT
    pBuffer 	: DWORD;
    cbBuffer	: UDINT;
END_VAR
VAR_IN_OUT
    stream 	: ST_IEC870_5_101Stream;
END_VAR

pBuffer: Pointer (address) of external buffer variable.

cbBuffer: Maximum number of data bytes to be copied from the stream variable to the external buffer.

stream: Data buffer.

Example in ST:

After run 4 data bytes are copied to the stream variable. The first 4 data bytes of the stream variable are copied to the rxBuffer variable by a rising edge at bRx .

PROGRAM P_CopyStreamToBuffer
VAR
    stream 	: ST_IEC870_5_101Stream;
    txBuffer	: ARRAY[0..3] OF BYTE := 1, 2, 3, 4;
    cbTx 	: UDINT;
    bTx 	: BOOL := TRUE;

    rxBuffer	: ARRAY[0..3] OF BYTE;
    cbRx 	: UDINT;
    bRx 	: BOOL;
END_VAR
IF bTx THEN
    bTx 	:= FALSE;
    cbTx 	:= cbTx + F_iecCopyBufferToStream( ADR( txBuffer ), SIZEOF( txBuffer ), stream );
    txBuffer[0] := txBuffer[0] + 1;
    txBuffer[1] := txBuffer[1] + 1;
    txBuffer[2] := txBuffer[2] + 1;
    txBuffer[3] := txBuffer[3] + 1;
END_IF

IF bRx THEN
    bRx 	:= FALSE;
    cbRx 	:= F_iecCopyStreamToBuffer( ADR( rxBuffer ), SIZEOF( rxBuffer ), stream );
END_IF

Memory description of stream variable after run:

length | data
4 | 16#01 | 16#02 | 16#03 | 16#04 | ... | ... | ... | ... | ... | ... | ... | IEC870_MAX_ASDU_DATA_BYTE

Memory description of stream variable after first and each further F_CopyStreamToBuffer function call:

length | data
4 | 16#01 | 16#02 | 16#03 | 16#04 | ... | ... | ... | ... | ... | ... | ... | IEC870_MAX_ASDU_DATA_BYTE

Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86) CX (ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


F_iecCopyStreamToStream

FUNCTION F_iecCopyStreamToStream

From product version: TwinCAT PLC Library IEC60870-5-104 substation v2.0.6 and higher.

This function copies databytes from the source variable to the target variable. The memory content of source variable remains unchanged. The memory content of the target variable increases. The return parameter of the function delivers the number of successfull copied data bytes.

FUNCTION F_iecCopyStreamToStream: UDINT

VAR_INPUT
    cbCopy	 	: UDINT;
END_VAR
VAR_IN_OUT
    target 		: ST_IEC870_5_101Stream;
    source 		: ST_IEC870_5_101Stream;
END_VAR

cbCopy: Number of bytes to be copied from the source variable to the target variable.

target: Target data buffer

source: Source data buffer

Example in ST:

At a rising edge at bCopy first the srcValue is incremented and copied to srcStream . After that the first 4 data bytes are copied from srcStream to dstStream. At the end the first 4 data bytes are copied from dstStream into the dstValue variable.

PROGRAM P_iecCopyStreamToStream
VAR
    srcStream 	: ST_IEC870_5_101Stream;
    srcValue 	: DWORD;

    dstStream 	: ST_IEC870_5_101Stream;
    dstValue 	: DWORD;

    bCopy 		: BOOL;
END_VAR
IF bCopy THEN
    bCopy := FALSE;
    srcValue := srcValue + 1;

    F_iecCopyBufferToStream( ADR( srcValue ), SIZEOF( srcValue ), srcStream );

    F_iecCopyStreamToStream( SIZEOF( srcValue ), dstStream, srcStream );

    F_iecCopyStreamToBuffer( ADR( dstValue ), SIZEOF( dstValue ), dstStream );

END_IF

Memory description of srcStream and dstStream variable after the first F_iecCopyStreamToStream function call:

srcStream:

length | data
4 | 16#01 | 16#00 | 16#00 | 16#00 | ... | ... | ... | ... | ... | ... | ... | IEC870_MAX_ASDU_DATA_BYTE

dstStream:

length | data
4 | 16#01 | 16#00 | 16#00 | 16#00 | ... | ... | ... | ... | ... | ... | ... | IEC870_MAX_ASDU_DATA_BYTE

Memory description of srcStream and dstStream variable after thesecond F_iecCopyStreamToStream function call:

srcStream:

length | data
8 | 16#01 | 16#00 | 16#00 | 16#00 | 16#02 | 16#00 | 16#00 | 16#00 | ... | ... | ... | IEC870_MAX_ASDU_DATA_BYTE

dstStream:

length | data
8 | 16#01 | 16#00 | 16#00 | 16#00 | 16#01 | 16#00 | 16#00 | 16#00 | ... | ... | ... | IEC870_MAX_ASDU_DATA_BYTE

Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86) CX (ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


F_iecMoveStreamToBuffer

FUNCTION F_iecMoveStreamToBuffer

From product version: TwinCAT PLC Library IEC60870-5-104 substation v2.0.6 and higher.

This function copies data bytes from the stream variable to an external buffer variable and deletes afterwards the copied data bytes from the stream variable .The memory content of the stream variable decreases . The return parameter of the function delivers the number of successfull copied data bytes.

FUNCTION F_iecMoveStreamToBuffer : UDINT

VAR_INPUT
    pBuffer 	: DWORD;
    cbBuffer	: UDINT;
END_VAR
VAR_IN_OUT
    stream 	: ST_IEC870_5_101Stream;
END_VAR

pBuffer: Pointer (address) of external buffer variable.

cbBuffer: Maximum number of data bytes to be copied from the stream variable to the external buffer.

stream: Data buffer.

Example in ST:

After run two DWORD values are copied to the stream variable. Each time 4 data bytes of the stream variable are copied to the rxBuffer variable by a rising edge at bRx .

PROGRAM P_MoveStreamToBuffer
VAR
    stream 	: ST_IEC870_5_101Stream;
    txBuffer	: ARRAY[0..1] OF DWORD := 16#12345678, 16#ABCDEF01;
    cbTx 	: UDINT;
    bTx 	: BOOL := TRUE;

    rxBuffer	: DWORD;
    cbRx 	: UDINT;
    bRx 	: BOOL;
END_VAR
IF bTx THEN
    bTx 	:= FALSE;
    cbTx 	:= F_iecCopyBufferToStream( ADR( txBuffer ), SIZEOF( txBuffer ), stream );
END_IF

IF bRx THEN
    bRx 	:= FALSE;
    cbRx 	:= F_iecMoveStreamToBuffer( ADR( rxBuffer ), SIZEOF( rxBuffer ), stream );
END_IF

Memory description of stream variable after run:

length | data
8 | 16#78 | 16#56 | 16#34 | 16#12 | 16#01 | 16#EF | 16#CD | 16#AB | ... | ... | ... | IEC870_MAX_ASDU_DATA_BYTE

Memory description of stream variable after the first F_iecMoveStreamToBuffer function call:

length | data
4 | 16#01 | 16#EF | 16#CD | 16#AB | 16#01 | 16#EF | 16#CD | 16#AB | ... | ... | ... | IEC870_MAX_ASDU_DATA_BYTE

Memory description of stream variable after the second F_iecMoveStreamToBuffer function call:

length | data
0 | 16#01 | 16#EF | 16#CD | 16#AB | 16#01 | 16#EF | 16#CD | 16#AB | ... | ... | ... | IEC870_MAX_ASDU_DATA_BYTE

Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86) CX (ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)


F_iecMoveStreamToStream

FUNCTION F_iecMoveStreamToStream

From product version TwinCAT PLC Library IEC60870-5-104 substation v2.0.6 and higher.

This function copies data bytes from the source variable to the target variable and deletes afterwards the copied data bytes from the source variable. The memory content of the source variable decreases .The memory content of the target variable increases

FUNCTION F_iecMoveStreamToStream : UDINT

VAR_INPUT
    cbCopy	: UDINT;
END_VAR
VAR_IN_OUT
    target 	: ST_IEC870_5_101Stream;
    source 	: ST_IEC870_5_101Stream;
END_VAR

cbCopy: Number of data bytes to be copied from the source variable to the target variable.

target: Target data buffer

source: Source data buffer.

Example in ST:

under construction

Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86) CX (ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


F_iecResetStream

FUNCTION F_iecResetStream

From product version: TwinCAT PLC Library IEC60870-5-104 substation v2.0.6 and higher.

The function initialises ans resets the stream variable. As an option the internal data buffer of the stream variable can be initialised with a defined number of zero bytes. The return value of the function delivers the number of successfull initialised zero bytes.

FUNCTION F_iecResetStream: UDINT

VAR_INPUT
    cbLength : UDINT; (* number of init data bytes *)
END_VAR
VAR_IN_OUT
    stream 	: ST_IEC870_5_101Stream;
END_VAR

cbLength: Number of data bytes to be initialised.

stream: Variable to be initialised.

Example in ST:

After run the internal buffer odf the stream variable is reset and initialised with 5 zero bytes.

PROGRAM P_ResetStream
VAR
    stream : ST_IEC870_5_101Stream;
    bReset : BOOL := TRUE;
END_VAR
IF bReset THEN
    bReset := FALSE;
    F_iecResetStream( 5, stream );
END_IF

Memory description of stream variable after run:

length | data
5 | 16#00 | 16#00 | 16#00 | 16#00 | 16#00 | ... | ... | ... | ... | ... | ... | IEC870_MAX_ASDU_DATA_BYTE

Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86) CX (ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically


F_iecCreateTableHnd

FUNCTION F_iecCreateTableHnd

From product version: TwinCAT PLC Library IEC60870-5-104 controlling station v1.0.0 and higher.

The function F_iecCreateTableHnd initializes the application object data base handle (hash tabele handle). The table handle has to be initialized once before using.

FUNCTION F_iecCreateTableHnd: UDINT

VAR_INPUT
    pAOEntries 	: POINTER TO ST_IEC870_5_101AODBEntry := 0;
    cbAOEntries 	: UDINT := 0;
END_VAR
VAR_IN_OUT
    hTable 		: T_HAODBTable;
ENd_VAR

pAOEntries: Address of application object data base variable.

cbAOEntries: Byte size of application object data base variable.

hTable: Application object data base handle (hash table handle) to be initialized.

Return parameter | Description
0 | No error
<> 0 | Error: IEC60870-5-10x error code

Example in ST:

See description of F_iecAddTableEntry

Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


F_iecAddTableEntry

FUNCTION F_iecAddTableEntry

From product version: TwinCAT PLC Library IEC60870-5-104 controlling station v1.0.0 and higher.

The function F_iecAddTableEntry configures the application objects (Single Points, Double Points, Measured Values...) in the application data base as hash table entries. The function searches automatically a free, not used table element (array element) und sets whose configuration parameter.

FUNCTION F_iecAddTableEntry: UDINT

VAR_INPUT
    eType 		: E_IEC870_5_101TcTypeID := ASDU_TYPEUNDEF;
    asduAddr 	: DWORD := 0;
    objAddr 		: DWORD := 0;
    group 		: DWORD := 0;
    multiplier 	: BYTE := 0;
    ioMapType 	: E_IEC870_5_101IOMappingType := MAP_AREA_NONE;
    byteOffs 	: UDINT := 0;
    bitOffs 		: UDINT := 0;
    hUser 		: DWORD := 0;
END_VAR
VAR_IN_OUT
    hTable 		: T_HAODBTable;
ENd_VAR

eType: Application object type, ASDU identifier (e.g.: M_SP_NA_1 for Single-Point or M_DP_NA_1 for Double-Point ).

asduAddr: Shared ASDU address.

objAddr: Object address, arbitrary.

group: Object group configuration flag (description). The flags can be combined with OR connection. Note: Not all combinations make sense!

multiplier: Base cycle time multiplicator for cyclic/periodic data transfer. 0 = Disabled. The base cycle time can be configured by the tPerCyclicBase parameter in the system parameter.

ioMapType: TwinCAT PLC process data range. This parameter defines the mapping of TwinCAT PLC and IEC application object process data.

byteOffs: TwinCAT PLC process data byte offset.

bitOffs: TwinCAT PLC process data bit offset.

hUser: Free definable 32 bit value. This value is stored in the configuration data of the application object.

hTable: Application object data base handle (hash table handle). The table handle has to be initialized once before using with the function F_iecCreateTableHnd.

Return parameter | Description
0 | No error
<> 0 | Error: IEC60870-5-10x error code

Example in ST:

Three data points are inserted to the application data base as hash table entries:

eType | asduAddr | objAddr | group | multiplier | ioMapType | byteOffs | bitOffs | hUser
M_SP_NA_1 | 11 | 100 | IEC870_GRP_INRO1 | 0 | MAP_AREA_MEMORY | 100 | 0 | 16#00BECF01
M_DP_NA_1 | 11 | 200 | IEC870_GRP_INROGEN | 0 | MAP_AREA_DATA | 200 | 0 | 16#00BECF02
M_IT_NA_1 | 11 | 800 | IEC870_GRP_REQCOGEN | 0 | MAP_AREA_MEMORY | 800 | 0 | 16#00BECF03
VAR_GLOBAL CONSTANT
    MIN_TABLE_IDX : INT := 0;
    MAX_TABLE_IDX : INT := 49;
END_VAR
PROGRAM P_HashTableConfig
VAR_IN_OUT
    hTable 	: T_HAODBTable;
    AODB 	: ARRAY[MIN_TABLE_IDX..MAX_TABLE_IDX] OF ST_IEC870_5_101AODBEntry;
END_VAR
VAR
    init 	: BOOL := TRUE;
    initError : UDINT;
END_VAR
IF init THEN
    init := FALSE;
    initError := F_iecCreateTableHnd( ADR( AODB ), SIZEOF( AODB ), hTable );
    IF initError <> 0 THEN
        ADSLOGSTR( ADSLOG_MSGTYPE_HINT OR ADSLOG_MSGTYPE_LOG,
            'F_iecCreateTableHnd() error: %s',
            DWORD_TO_HEXSTR( initError, 8, FALSE ) );
        RETURN;
    END_IF
    initError := F_iecAddTableEntry( 	eType 		:= M_SP_NA_1,
                    asduAddr 	:= 11,
                    objAddr		:= 100,
                    group		:= IEC870_GRP_INRO1,
                    multiplier 	:= 0,
                    ioMapType 	:= MAP_AREA_MEMORY,
                    byteOffs 	:= 100,
                    bitOffs 		:= 0,
                    hUser 		:= 16#00BECF01,
                    hTable 		:= hTable );
    IF initError <> 0 THEN
        ADSLOGSTR( ADSLOG_MSGTYPE_ERROR OR ADSLOG_MSGTYPE_LOG,
            'F_iecAddTableEntry() error: %s',
            DWORD_TO_HEXSTR( initError, 8, FALSE ) );
        RETURN;
    END_IF

    initError := F_iecAddTableEntry( 	eType 		:= M_DP_NA_1,
                    asduAddr 	:= 11,
                    objAddr 		:= 200,
                    group 		:= IEC870_GRP_INROGEN,
                    multiplier 	:= 0,
                    ioMapType 	:= MAP_AREA_DATA,
                    byteOffs 	:= 200,
                    bitOffs 		:= 0,
                    hUser 		:= 16#00BECF02,
                    hTable 		:= hTable );
    IF initError <> 0 THEN
        ADSLOGSTR( ADSLOG_MSGTYPE_ERROR OR ADSLOG_MSGTYPE_LOG,
            'F_iecAddTableEntry() error: %s',
            DWORD_TO_HEXSTR( initError, 8, FALSE ) );
        RETURN;
    END_IF

    initError := F_iecAddTableEntry( 	eType 		:= M_IT_NA_1,
                    asduAddr 	:= 11,
                    objAddr 		:= 800,
                    group 		:= IEC870_GRP_REQCOGEN,
                    multiplier 	:= 0,
                    ioMapType 	:= MAP_AREA_MEMORY,
                    byteOffs 	:= 800,
                    bitOffs 		:= 0,
                    hUser 		:= 16#00BECF03,
                    hTable 		:= hTable );
    IF initError <> 0 THEN
        ADSLOGSTR( ADSLOG_MSGTYPE_ERROR OR ADSLOG_MSGTYPE_LOG,
            'F_iecAddTableEntry() error: %s',
            DWORD_TO_HEXSTR( initError, 8, FALSE ) );
        RETURN;
    END_IF
END_IF
Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


F_iecGetPosOfTableEntry

FUNCTION F_iecGetPosOfTableEntry

From product version: TwinCAT PLC Library IEC60870-5-104 controlling station v1.0.0 and higher.

The function F_iecGetPosOfTableEntry supplies the table index (array index) for a hash table entry that matches the lookup key. The first array element has position number one (non-zero based array position).

FUNCTION F_iecGetPosOfTableEntry: UDINT

VAR_INPUT
    key : ST_IEC870_5_101HashTableKey;
END_VAR
VAR_IN_OUT
    hTable 	: T_HAODBTable;
ENd_VAR

key: Lookup key.

hTable: Application object database handle (hash table handle). The table handle must be initialised once with the function F_iecCreateTableHnd before it can be used.

Return parameter | Description
0 | No table entry matching the key was found.
<> 0 | No error. The return parameter supplies the required table index (non-zero-based array position).

Example in ST:
The system searches for the linear table index for three data points. The associated data points have already been configured as hash table entries. See function description: F_iecAddTableEntry.

eType | objAddr | asduAddr | group
M_SP_NA_1 | 100 | 11 | IEC870_GRP_INRO1
M_DP_NA_1 | 200 | 11 | IEC870_GRP_INROGEN
M_IT_NA_1 | 800 | 11 | IEC870_GRP_REQCOGEN
VAR_GLOBAL CONSTANT
    MIN_TABLE_IDX : INT := 0;
    MAX_TABLE_IDX : INT := 49;
END_VAR
PROGRAM P_GetPosOfTableEntry
VAR_IN_OUT
    hTable 	: T_HAODBTable;
    AODB 	: ARRAY[MIN_TABLE_IDX..MAX_TABLE_IDX] OF ST_IEC870_5_101AODBEntry;
END_VAR
VAR
    bGetPos 	: BOOL;
    position	: UDINT;
    key 	: ST_IEC870_5_101HashTableKey;
    hUser 	: UDINT;
END_VAR
IF bGetPos 	THEN
    bGetPos 		:= FALSE;

    key.eType 	:= M_SP_NA_1;
    key.asduAddr 	:= 11;
    key.objAddr 	:= 100;
    key.group 	:= IEC870_GRP_INRO1;
    key.lookup 	:= IEC870_LOOKUP_KEY_ALL_ON;
    position 	:= F_iecGetPosOfTableEntry( key := key, hTable := hTable );
    IF position <> 0 THEN
        hUser := AODB[MIN_TABLE_IDX+position-1].aObj.cfg.hUser;
    ELSE
        ADSLOGSTR( ADSLOG_MSGTYPE_HINT OR ADSLOG_MSGTYPE_LOG,
        'F_iecGetPosOfTableEntry() error: %s', '' );
    END_IF

    key.eType 	:= M_DP_NA_1;
    key.objAddr 	:= 200;
    key.group 	:= IEC870_GRP_INROGEN;
    key.lookup 	:= IEC870_LOOKUP_KEY_ALL_ON;
    position 	:= F_iecGetPosOfTableEntry( key := key, hTable := hTable );
    IF position <> 0 THEN
        hUser := AODB[MIN_TABLE_IDX+position-1].aObj.cfg.hUser;
    ELSE
        ADSLOGSTR( ADSLOG_MSGTYPE_HINT OR ADSLOG_MSGTYPE_LOG,
        'F_iecGetPosOfTableEntry() error: %s', '' );
    END_IF

    key.eType 	:= M_IT_NA_1;
    key.objAddr 	:= 800;
    key.group 	:= IEC870_GRP_REQCOGEN;
    key.lookup 	:= IEC870_LOOKUP_KEY_ALL_ON;
    position 	:= F_iecGetPosOfTableEntry( key := key, hTable := hTable );
    IF position <> 0 THEN
        hUser := AODB[MIN_TABLE_IDX+position-1].aObj.cfg.hUser;
    ELSE
        ADSLOGSTR( ADSLOG_MSGTYPE_HINT OR ADSLOG_MSGTYPE_LOG,
            'F_iecGetPosOfTableEntry() error: %s', '' );
    END_IF
END_IF
Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


F_iecLookupTableEntry

FUNCTION F_iecLookupTableEntry

From product version: TwinCAT PLC Library IEC60870-5-104 controlling station v1.0.0 and higher.

The function F_iecLookupTableEntry checks if an table entry already exists that matches to the key.

FUNCTION F_iecLookupTableEntry: UDINT

VAR_INPUT
    key : ST_IEC870_5_101HashTableKey;
END_VAR
VAR_IN_OUT
    hTable 	: T_HAODBTable;
ENd_VAR

key: Lookup key.

hTable: Application object data base handle (hash table handle). The table handle has to be initialized once before using with the function F_iecCreateTableHnd.

Return parameter | Description
0 | No error. A table entry that matches to the key exists.
<> 0 | No table entry found. Error: IEC60870-5-10x error code

Example in ST:

It will be checked if three data points in the application data base exist. The searched data points have already been configured as hash table entries.
See description of: F_iecAddTableEntry.

eType | objAddr | asduAddr | group
M_SP_NA_1 | 100 | 11 | IEC870_GRP_INRO1
M_DP_NA_1 | 200 | 11 | IEC870_GRP_INROGEN
M_IT_NA_1 | 800 | 11 | IEC870_GRP_REQCOGEN
PROGRAM P_LookupEntry
VAR_IN_OUT
    hTable : T_HAODBTable;
END_VAR
VAR
    key : ST_IEC870_5_101HashTableKey;
    bLookup : BOOL;
    nFound : BYTE;
    nError : UDINT;
END_VAR
IF bLookup THEN
    bLookup := FALSE;

    key.eType 	:= M_SP_NA_1;
    key.asduAddr 	:= 11;
    key.objAddr 	:= 100;
    key.group 	:= IEC870_GRP_INRO1;
    key.lookup 	:= IEC870_LOOKUP_KEY_ALL_ON;
    nError 		:= F_iecLookupTableEntry( key := key, hTable := hTable );
    IF nError <> 0 THEN
        RETURN;
    ELSE
        nFound := nFound + 1;
    END_IF

    key.eType 	:= M_DP_NA_1;
    key.asduAddr 	:= 11;
    key.objAddr 	:= 200;
    key.group 	:= IEC870_GRP_INROGEN;
    key.lookup 	:= IEC870_LOOKUP_KEY_ALL_ON;
    nError 		:= F_iecLookupTableEntry( key := key, hTable := hTable );
    IF nError <> 0 THEN
        RETURN;
    ELSE
        nFound := nFound + 1;
    END_IF

    key.eType 	:= M_IT_NA_1;
    key.asduAddr 	:= 11;
    key.objAddr 	:= 800;
    key.group 	:= IEC870_GRP_REQCOGEN;
    key.lookup 	:= IEC870_LOOKUP_KEY_ALL_ON;
    nError 		:= F_iecLookupTableEntry( key := key, hTable := hTable );
    IF nError <> 0 THEN
        RETURN;
    ELSE
        nFound := nFound + 1;
    END_IF
END_IF

Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included atomatically )


F_iecRemoveTableEntry

FUNCTION F_iecRemoveTableEntry

From product version: TwinCAT PLC Library IEC60870-5-104 controlling station v1.0.0 and higher.

The function F_iecRemoveTableEntry removes an hash table entry that matches to the key.

FUNCTION F_iecRemoveTableEntry: UDINT

VAR_INPUT
    key : ST_IEC870_5_101HashTableKey;
END_VAR
VAR_IN_OUT
    hTable 	: T_HAODBTable;
ENd_VAR

key: Lookup key.

hTable: Application object data base handle (hash table handle). The table handle has to be initialized once before using with the function F_iecCreateTableHnd.

Return parameter | Description
0 | No error. The table entry has been removed successfully.
<> 0 | Error: IEC60870-5-10x error code

Example in ST:

Three hash table entries will be romoved from the application data base. The searched data points have already been configured as hash table entries.
See description of: F_iecAddTableEntry.

eType | objAddr | asduAddr | group
M_SP_NA_1 | 100 | 11 | IEC870_GRP_INRO1
M_DP_NA_1 | 200 | 11 | IEC870_GRP_INROGEN
M_IT_NA_1 | 800 | 11 | IEC870_GRP_REQCOGEN
PROGRAM P_RemoveEntry
VAR_IN_OUT
    hTable : T_HAODBTable;
END_VAR
VAR
    key : ST_IEC870_5_101HashTableKey;
    bRemove : BOOL;
    nError : UDINT;
END_VAR
IF bRemove THEN
    bRemove 		:= FALSE;

    key.eType 	:= M_SP_NA_1;
    key.asduAddr 	:= 11;
    key.objAddr 	:= 100;
    key.group 	:= IEC870_GRP_INRO1;
    key.lookup 	:= IEC870_LOOKUP_KEY_ALL_ON;
    nError 		:= F_iecRemoveTableEntry( key := key, hTable := hTable );
    IF nError <> 0 THEN
        RETURN;
    END_IF

    key.eType 	:= M_DP_NA_1;
    key.asduAddr 	:= 11;
    key.objAddr 	:= 200;
    key.group 	:= IEC870_GRP_INROGEN;
    key.lookup 	:= IEC870_LOOKUP_KEY_ALL_ON;
    nError 		:= F_iecRemoveTableEntry( key := key, hTable := hTable );
    IF nError <> 0 THEN
        RETURN;
    END_IF

    key.eType 	:= M_IT_NA_1;
    key.asduAddr 	:= 11;
    key.objAddr 	:= 800;
    key.group 	:= IEC870_GRP_REQCOGEN;
    key.lookup 	:= IEC870_LOOKUP_KEY_ALL_ON;
    nError 		:= F_iecRemoveTableEntry( key := key, hTable := hTable );
    IF nError <> 0 THEN
        RETURN;
    END_IF
END_IF

Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


F_iecCmpAddrOctets

FUNCTION F_iecCmpAddrOctets

From product version: TwinCAT PLC Library IEC60870-5-101/104 substation v3.0.2 / IEC60870-5-104 controll station v1.0.2 and higher.

This function compares two address values ( e.g. link addresses, object addresses or common ASDU addresses).

FUNCTION F_iecCmpAddrOctets: BOOL

VAR_INPUT
    a : DWORD; (* first address *)
    b : DWORD; (* second address *)
    size : INT(0..4); (* address octet size (0..3, 4 = reserved) *)
END_VAR

a: First address.

b: Second address

size: Address octet size.

Return value | Description
TRUE | (a and b are equal) or (b is broadcast address) or (size is 0).
FALSE | All other cases.
Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1307 | PC oder CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


F_iecGetSPI

FUNCTION F_iecGetSPI

This function decodes the single point information from byte variable. One byte variable yields up to 8 single points information. Every single point information occupies 1 bit.

FUNCTION F_iecGetSPI: E_IEC870_5_101SPI

VAR_INPUT
    in : BYTE; (* Byte variable from where the single point information have to be decoded *)
    offset : UDINT(0..7); (* Single point information offset *)
END_VAR

Example:

Decoding the information of 4 single points from byte variable.

PROGRAM MAIN
VAR
    memarea AT%MB0 : ARRAY[0..10] OF BYTE;
    eSPI : E_IEC870_5_101SPI;
ENd_VAR
eSPI := F_iecGetSPI( memarea[0], 0 );
eSPI := F_iecGetSPI( memarea[0], 1 );
eSPI := F_iecGetSPI( memarea[0], 2 );
eSPI := F_iecGetSPI( memarea[0], 3 );
Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1324 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib are included automatically )


F_iecGetDPI

FUNCTION F_iecGetDPI

This function decodes the double point information from byte variable. One byte variable yields up to 4 double points information. Every double point information occupies 2 bits.

FUNCTION F_iecGetDPI: E_IEC870_5_101DPI

VAR_INPUT
    in : BYTE; (* Byte variable from where the double point information have to be decoded *)
    offset : UDINT(0..3); (* Double point information offset *)
END_VAR

Example:

Decoding the information of 4 double points from one byte variable.

PROGRAM MAIN
VAR
    memarea AT%MB0 : ARRAY[0..10] OF BYTE;
    eDPI : E_IEC870_5_101DPI;
ENd_VAR
eDPI := F_iecGetDPI( memarea[0], 0 );
eDPI := F_iecGetDPI( memarea[0], 1 );
eDPI := F_iecGetDPI( memarea[0], 2 );
eDPI := F_iecGetDPI( memarea[0], 3 );
Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1324 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib are included automatically )


F_iecGetSCS

FUNCTION F_iecGetSCS

This function decodes the single command state from byte variable. One byte variable yields up to 8 single command states. Every single command state occupies 1 bit.

FUNCTION F_iecGetSCS: E_IEC870_5_101SCS

VAR_INPUT
    in : BYTE;(* Byte variable from where the single command state have to be decoded *)
    offset : UDINT(0..7); (* Single command state offset *)
END_VAR

Example:

Decoding the state of 4 single commands from one byte variable.

PROGRAM MAIN
VAR
    memarea AT%MB0 : ARRAY[0..10] OF BYTE;
    eSCS : E_IEC870_5_101SCS;
ENd_VAR
eSCS := F_iecGetSCS( memarea[0], 0 );
eSCS := F_iecGetSCS( memarea[0], 1 );
eSCS := F_iecGetSCS( memarea[0], 2 );
eSCS := F_iecGetSCS( memarea[0], 3 );
Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1324 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib are included automatically )


F_iecGetDCS

FUNCTION F_iecGetDCS

This function decodes the double command state from byte variable. One byte variable yields up to 4 double commands states. Every double command state occupies 2 bits.

FUNCTION F_iecGetDCS: E_IEC870_5_101DCS

VAR_INPUT
    in : BYTE; (* Byte variable from where the double command state have to be decoded *)
    offset : UDINT(0..3); (* Double command state offset *)
END_VAR

Example:

Decoding the state of 4 double commands from byte variable.

PROGRAM MAIN
VAR
    memarea AT%MB0 : ARRAY[0..10] OF BYTE;
    eDCS : E_IEC870_5_101DCS;
ENd_VAR
eDCS := F_iecGetDCS( memarea[0], 0 );
eDCS := F_iecGetDCS( memarea[0], 1 );
eDCS := F_iecGetDCS( memarea[0], 2 );
eDCS := F_iecGetDCS( memarea[0], 3 );
Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1324 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib are included automatically )


F_iecSetSPI

FUNCTION F_iecSetSPI

This function encodes the single point information in the byte variable. One byte variable yields up to 8 single point information. Every single point information occupies 1 bit.

FUNCTION F_iecSetSPI: BYTE

VAR_INPUT
    in : BYTE; (* Byte variable where the new single point information have to be encoded. *)
    offset : UDINT(0..7);(* Single point information offset. *)
    eSPI : E_IEC870_5_101SPI; (* The new value of single point information. *)
END_VAR

Example:

Setting the information of 4 single points to ON.

PROGRAM MAIN
VAR
    memarea AT%MB0 : ARRAY[0..10] OF BYTE;
END_VAR
memarea[0] := F_iecSetSPI( memarea[0], 0, eIEC870_SPI_ON );
memarea[0] := F_iecSetSPI( memarea[0], 1, eIEC870_SPI_ON );
memarea[0] := F_iecSetSPI( memarea[0], 2, eIEC870_SPI_ON );
memarea[0] := F_iecSetSPI( memarea[0], 3, eIEC870_SPI_ON );
Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1324 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib are included automatically )


F_iecSetDPI

FUNCTION F_iecSetDPI

This function encodes the double point information in the byte variable. One byte variable yields up to 4 double point information. Every double point information occupies 2 bits.

FUNCTION F_iecSetDPI: BYTE

VAR_INPUT
    in : BYTE; (* Byte variable where the new double point information have to be encoded. *)
    offset : UDINT(0..3);(* Double point information offset. *)
    eDPI : E_IEC870_5_101DPI; (* The new value of double point information. *)
END_VAR

Example:

Setting the information of 4 double points to ON.

PROGRAM MAIN
VAR
    memarea AT%MB0 : ARRAY[0..10] OF BYTE;
END_VAR
memarea[0] := F_iecSetDPI( memarea[0], 0, eIEC870_DPI_ON );
memarea[0] := F_iecSetDPI( memarea[0], 1, eIEC870_DPI_ON );
memarea[0] := F_iecSetDPI( memarea[0], 2, eIEC870_DPI_ON );
memarea[0] := F_iecSetDPI( memarea[0], 3, eIEC870_DPI_ON );
Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1324 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib are included automatically )


F_iecSetSCS

FUNCTION F_iecSetSCS

This function encodes the single command state in the byte variable. One byte variable yields up to 8 single command states. Every single command state occupies 1 bit.

FUNCTION F_iecSetSCS: BYTE

VAR_INPUT
    in : BYTE; (* Byte variable where the new single command state have to be encoded. *)
    offset : UDINT(0..7);(* Single command state offset. *)
    eSCS : E_IEC870_5_101SCS; (* The new value of single command state. *)
END_VAR

Example:

Setting the state of 4 single command to ON.

PROGRAM MAIN
VAR
    memarea AT%MB0 : ARRAY[0..10] OF BYTE;
END_VAR
memarea[0] := F_iecSetSCS( memarea[0], 0, eIEC870_SCS_ON );
memarea[0] := F_iecSetSCS( memarea[0], 1, eIEC870_SCS_ON );
memarea[0] := F_iecSetSCS( memarea[0], 2, eIEC870_SCS_ON );
memarea[0] := F_iecSetSCS( memarea[0], 3, eIEC870_SCS_ON );
Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1324 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib are included automatically )


F_iecSetDCS

FUNCTION F_iecSetDCS

This function encodes the double command state in the byte variable. One byte variable yields up to 4 double command states. Every double command state occupies 2 bits.

FUNCTION F_iecSetDCS: BYTE

VAR_INPUT
    in : BYTE; (* Byte variable where the new double command state have to be encoded. *)
    offset : UDINT(0..3);(* Double command state offset. *)
    eDCS : E_IEC870_5_101DCS; (* The new value of double command state *)
END_VAR

Example:

Setting the state of 4 doble commands to ON.

PROGRAM MAIN
VAR
    memarea AT%MB0 : ARRAY[0..10] OF BYTE;
END_VAR
memarea[0] := F_iecSetDCS( memarea[0], 0, eIEC870_DCS_ON );
memarea[0] := F_iecSetDCS( memarea[0], 1, eIEC870_DCS_ON );
memarea[0] := F_iecSetDCS( memarea[0], 2, eIEC870_DCS_ON );
memarea[0] := F_iecSetDCS( memarea[0], 3, eIEC870_DCS_ON );
Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1324 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib are included automatically )


F_iecChangeLinkLayerMode

TwinCAT PLC Library: IEC60870-5-101 Common Data Types

FUNCTION F_iecChangeLinkLayerMode

Starting from the product version:

  • TwinCAT PLC Library IEC60870-5-101 Central Station v2.0.3;
  • TwinCAT PLC Library IEC60870-5-101 Substation v4.0.3;
  • TwinCAT PLC Library IEC60870-5-102 Central Station v2.0.3;
  • TwinCAT PLC Library IEC60870-5-103 Central Station v2.0.3;

With this function the default behaviour of each individual ASDU frame at the Link-Layer level in the primary station can be set or changed. The ASDU frame to be sent can be marked as a SEND/NO REPLY frame (function 4) or as a broadcast frame. The frames are marked before depositing the frame in the TX buffer I.e. before calling the FB_IEC870_5_101TBufferCtrl.TxAddObj action.

If you do not use the function, then all frames in the primary station are sent as SEND/CONFIRM frames (function 3). In this case the configured station address is used as the link address.

Important notes:

  • In unbalanced mode the use of this function has no meaning in the substation. The substation never acts as a primary station in this mode.
  • The function has no meaning when using the IEC 6087-5-104 protocol.
  • This functionality is supported only when using the ‘low level’ interface.

FUNCTION F_iecChangeLinkLayerMode: BOOL

VAR_INPUT
    sendNoReplay : BOOL;(* TRUE => Use SEND / NO REPLAY link layer function, FALSE => Use SEND/CONFIRM function (default) *)
    globalLinkAddr : BOOL;(* TRUE => Use global (broadcast link address, 0xFF... ), FALSE => Use configured (station) link address *)
END_VAR
VAR_IN_OUT
    asdu : ST_IEC870_5_101AOGen;
END_VAR

sendNoReplay : this parameter specifies whether the Link-Layer function SEND/NO REPLY (TRUE = function 4) or SEND/CONFIRM (FALSE = function 3) is to be used when sending the frame;

globalLinkAddr : this parameter specifies whether a global (broadcast) address is to be used instead of the configured station link address when sending the frame. If the value is TRUE, 16#FF or 16#FFFF (size one octet, link address size two octets) is used as the link address in the sent frame;

asdu : The ASDU frame to be sent as a VAR_IN_OUT variable;

Return parameter | Description
FALSE | Function failed.
TRUE | No error.

Example 1 (excerpt):

The spontaneous data of a bitstring are to be sent to the central station with the aid of the SEND/NO REPLY function (balanced mode).

...

(* Send spontanous bitstring data *)
IF ( txQDS <> BITSTRING_QUALITY_100 ) OR ( txBSI <> BITSTRING_100 ) THEN

    txBSI	:= BITSTRING_100;
    txQDS 	:= BITSTRING_QUALITY_100;(* Get quality *)
    txTT	:= SYSTEMTIME_TO_CP56Time2a( fbRTC.CDT, TRUE );(* Get current time stamp *)

    (* create asdu *)
    txAsdu.ident.eType 	:= M_BO_TB_1;  (* Bit string with time tag *)
    txAsdu.ident.bSQ 		:= FALSE;
    txAsdu.ident.nObj 	:= 1;
    txAsdu.ident.eCOT 	:= eIEC870_COT_SPONTAN;
    txAsdu.ident.nORG 	:= sysPara.nOrg;(* Set originator address *)
    txAsdu.ident.bPN 		:= FALSE;
    txAsdu.ident.bT 		:= FALSE;
    txAsdu.ident.eClass 	:= eIEC870_Class_1;(* Put to the high priority tx buffer *)
    txAsdu.ident.asduAddr 	:= sysPara.asduAddr;(* Set common asdu address *)
    txAsdu.info.objAddr	:= 100;(* Set information object address *)
    F_iecResetStream( 0, txAsdu.info.stream ); (* clear previous data (this sets the stream length = 0 *)
    F_iecCopyBufferToStream( ADR( txBSI ), SIZEOF( txBSI ), txAsdu.info.stream ); (* put BSI to stream *)
    F_iecCopyBufferToStream( ADR( txQDS ), SIZEOF( txQDS ), txAsdu.info.stream ); (* put QDS to stream *)
    F_iecCopyBufferToStream( ADR( txTT ), SIZEOF( txTT ), txAsdu.info.stream ); (* put time tag to stream *)

    F_iecChangeLinkLayerMode( TRUE, FALSE, txAsdu );

    fbBuffer.TxAddObj( putObj := txAsdu, buffer := buffer ); (* put asdu to the TX fifo *)

    F_iecChangeLinkLayerMode( FALSE, FALSE, txAsdu );

    IF fbBuffer.bOk THEN
        fbLog( put := CONCAT( '<=', IEC101ASDU_TO_STRING(txAsdu) ) );
    ELSE(* Report send buffer overflow error *)
        fbLog( put := 'TX buffer overflow (spontanous bitstring data)!' );
    END_IF
END_IF

...

The txAsdu variable is used to send further data points. The default configuration of the txAsdu frame is produced by a further F_iecChangeLinkLayerMode (FALSE, FALSE,…) function call. Other ASDUs are not to be sent as SEND/NO REPLY telegrams.

Example 2 (excerpt):

A single command is to be sent to the substation with the aid of the SEND/NO REPLY function (unbalanced mode).

...

(* Send one single command *)
IF SND_SCS_2100 THEN
    SND_SCS_2100 := FALSE; (* Reset flag *)

    txAsdu.ident.eType 	:= C_SC_NA_1; (* Single command *)
    txAsdu.ident.bSQ 		:= FALSE;
    txAsdu.ident.nObj 	:= 1;
    txAsdu.ident.eCOT 	:= eIEC870_COT_ACT; (* Command activation *)
    txAsdu.ident.nORG 	:= sysPara.nOrg;(* Set originator address *)
    txAsdu.ident.bPN 		:= FALSE;
    txAsdu.ident.bT 		:= FALSE;
    txAsdu.ident.eClass 	:= eIEC870_Class_1;(* Put to the high priority tx buffer *)
    txAsdu.ident.asduAddr 	:= sysPara.asduAddr;(* Set common asdu address *)
    txAsdu.info.objAddr	:= 2100;(* Set information object address *)
    tmpByte 			:= INT_TO_BYTE(SCS_2100);(* Set single command state *)
    tmpByte.7 		:= 0;(* Set select/execute bit *)

    F_iecResetStream( 0, txAsdu.info.stream ); (* Clear previous data (this sets the stream length = 0 *)
    F_iecCopyBufferToStream( ADR( tmpByte ), SIZEOF( tmpByte ), txAsdu.info.stream ); (* put QCC to stream *)

    F_iecChangeLinkLayerMode( TRUE, FALSE, txAsdu );

    fbBuffer.TxAddObj( putObj := txAsdu, buffer := buffer ); (* put asdu to the TX fifo *)

    F_iecChangeLinkLayerMode( FALSE, FALSE, txAsdu );

    IF fbBuffer.bOk THEN
        timerCON( IN := FALSE );(* Reset timer *)
        timerTERM( IN := FALSE );(* Reset timer *)
        fbLog( put := CONCAT( '<=', IEC101ASDU_TO_STRING(txAsdu) ) );
        state := 80;(* Wait for command confirmation *)
    ELSE(* Report send buffer overflow error *)
        fbLog( put := 'TX buffer overflow (single command)!' );
        state := 1;
    END_IF

END_IF

...

Development environment | Target platform | PLC libraries to be linked
TwinCAT v2.11.0 Build >= 1554 | PC or CX (x86, ARM) | (Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; TcIEC870_5_101.Lib are included automatically)


F_GetVersionTcIEC870_5_101

FUNCTION F_GetVersionTcIEC870_5_101

This function reads version information from the plc library.

FUNCTION F_GetVersionTcIEC870_5_101: UINT

VAR_INPUT
    nVersionElement : INT;
END_VAR

nVersionElement : Version element, that is to be read. Possible parameters:

  • 1 : major number;
  • 2 : minor number;
  • 3 : revision number;
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


ST_IEC870_5_101TBuffer

TYPE ST_IEC870_5_101TBuffer

From product version: TwinCAT PLC Library IEC60870-5-104 substation v2.0.6 / IEC60870-5-101 substation v2.0.2 and higher.

This data structure is used for data exchange (TX/RX data buffer) via the IEC60870-5-104/101 Transport Interface.

TYPE ST_IEC870_5_101TBuffer :
STRUCT
    eDbg 		: E_IEC870_5_101FifoDbgFlags :=eIEC870_FIFO_DBG_OFF; (* enable/disable log view hex output *)
    asduFmt 		: ST_IEC870_5_101AsduFmtParams; (* ASDU frame format parameters *)
    asduSize 		: BYTE := 0; (* max. length of ASDU data *)
    mode		: DWORD := 0;
    dataLink 		: ST_IEC870_5_101DataLink; (* internal tx/rx buffer *)
    bOverwrite 	: BOOL := FALSE;(* TRUE = Overwrite oldest entry, FALSE = don't overwrite *)
END_STRUCT
END_TYPE

eDbg: Debug output parameter.

asduFmt: ASDU format parameter.

asduSize: Maximum length of ASDU data.

mode: Reserved, not used. This value has to be zero.

dataLink: The access to the elements of this data structure should only occur with an instance of the function block FB_IEC870_5_101TBufferCtrl, not directly.

The TX/RX data buffer uses internal two send Fifos and one receive Fifo:

  1. Class 1 send Fifo with (high prior) data;
  2. Class 2 send Fifo with (low prior) data;
  3. Receive Fifo (for Class 1 and Class 2 data);

The lower transport functions of the library emtpy first the class 1 Fifo and afterwards the class 2 Fifo. The class 2 data are only sent, if the class 1 Fifo contains no data to be sent.

Each internal Fifo hast a fixed size of 10000 bytes. This is enough for the most applications, because the number of frames which can once be sent is limited by the iK and iW protocol parameters.
According to experience it is possible to store 200 ADSUs with an information element (object), or approx. 20 ADSUs with with a sequence of 100 information elements (objects) in each Fifo.

If a higher number of frames (to be sent or to be received) should be buffered ( e.g. ~20000), they can be kept in external buffers/Fifos which are defined by the PLC programmer. The PLC application can refill the TwinCAT send Fifos with own Fifo entries, or empty the TwinCAT receive Fifo.

As an alternative it is possible to use two buffers and to fill/read them alternately and give them to the communication block .

bOverwrite: Implemented from IEC870-5-104 slave library v3.0.14 and higher. Activates/deactivates the overwriting of the oldest messages in the send buffer if the max. permissible buffer size is exceeded. This parameter is active only in the offline mode, (i.e. if the connection has been interrupted) and if offline data storage has additionally been activated via the bRetainBuffer parameter in the protocol parameters (ST_IEC870_5_104ProtPara). In online mode, i.e. if data transfer has been started, no older messages are overwritten (otherwise some intermediate values would possibly be missing).

Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


ST_IEC870_5_101AODBEntry

TYPE ST_IEC870_5_101AODBEntry

TYPE ST_IEC870_5_101AODBEntry :
STRUCT
    aObj : ST_IEC870_5_101AOEntry; 	(* application object *)
    ctrl : FB_IEC870_5_101AOCtrl; 	(* application object control function *)
END_STRUCT
END_TYPE

An IEC application object database entry. The IEC application object database is declared as an array variable of type ST_IEC870_5_101AODBEntry. The member variables of this structured type are not manipulated (modified) directly, but only via the available functions or function blocks. F_iecIniAOEntry is part of such a function, for example.

Example for a declaration of an application database with 2001 objects:

VAR_GLOBAL
    slave1AODB : ARRAY[0..2000] OF ST_IEC870_5_101AODBEntry;
ENd_VAR
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


ST_IEC870_5_101AOGen

TYPE ST_IEC870_5_101AOGen

From product version: TwinCAT PLC Library IEC60870-5-104 substation v2.0.5 and higher.

Variables of this type represent an ASDU object.

TYPE ST_IEC870_5_101AOGen:
STRUCT
    head : ST_IEC870_5_101FifoHead :=(	source := ( link := 0, addr := 0 ),
                    target := ( link := 0, addr := 0 ),
                    ctrl := 0 ); (* Header *)

    ident 	: ST_IEC870_5_101DataUnit_Ident := ( eType 	:= ASDU_TYPEUNDEF,
                        nObj 	:= 0,
                        bSQ 	:= FALSE,
                        bT 		:= FALSE,
                        bPN 	:= FALSE,
                        nORG 	:= 0,
                        asduAddr	:= 0,
                        eCOT 	:= eIEC870_COT_UNUSED,
                        eClass 	:= eIEC870_Class_None ); (* Data unit identifier *)

    info 	: ST_IEC870_5_101AOInfoObj	:= ( objAddr := 0, stream := ( length := 0 ) ); (* information object *)
END_STRUCT
END_TYPE

head: Header (reserved).

ident: Identification field in the data unit (ASDU).

info: Information object /Information element data field.

Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


ST_IEC870_5_101AOCfg

TYPE ST_IEC870_5_101AOCfg

From product version: TwinCAT PLC Library IEC60870-5-104 controlling station v1.0.0 and higher.

ASDU object configuration parameters. These parameters are set during configuration of the data points ( F_iecInitAOEntry or F_iecAddTableEntry ) and should not be written directly from the PLC application.

TYPE ST_IEC870_5_101AOCfg:
STRUCT
    group 		: DWORD := IEC870_GRP_INROGEN;
    multiplier 	: BYTE := 0;
    opt 		: BYTE := 0;
    ioMapType 	: E_IEC870_5_101IOMappingType := MAP_AREA_NONE;
    byteOffs 	: DWORD := 0;
    bitOffs 		: DWORD := 0;
    hUser 		: DWORD := 0;
    ext 		: DWORD := 0;
END_STRUCT
END_TYPE

group: Object group configuration flags. A description of all group flags can be found here. The flags can be combined with an OR operation. Not all combinations are meaningful!

multiplier: Basic cycle time multiplier for cyclic/periodic data transfer. 0 = deactivated. The basic cycle time can be configured via the tPerCyclicBase parameter in the system parameters.

opt: Reserved.

ioMapType: TwinCAT PLC process data area. This parameter defines the mapping for the TwinCAT PLC and IEC application object process data.

byteOffs: TwinCAT PLC process data byte offset.

bitOffs: TwinCAT PLC process data bit offset.

hUser: User handle. Freely definable 32-bit value.

ext: Reserved.

Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


ST_IEC870_5_101DataUnit_Ident

TYPE ST_IEC870_5_101DataUnit_Ident

Identification field of data unit (ASDU).

TYPE ST_IEC870_5_101DataUnit_Ident:
STRUCT
    eType 	: E_IEC870_5_101TcTypeID; (* TwinCAT ASDU type identifier *)
    bSQ 	: BOOL; (* Single/Sequence *)
    nObj 	: BYTE; (* Number of information objects or elements *)
    bT 	: BOOL; (* Test bit *)
    bPN 	: BOOL; (* Positive/Negative confirmation *)
    eCOT 	: E_IEC870_5_101COTType; (* Cause of transmission *)
    nORG 	: BYTE; (* Originator address (optional) *)
    asduAddr	: DWORD; (* Common address of ASDU *)
    eClass 	: E_IEC870_5_101ClassType; (* Object class *)
END_STRUCT
END_TYPE

eType: Type.

bSQ: Sequence flag.

nObj: Number of information objects or information elements.

bT: Test flag

bPN: Positive/negative confirmation.

eCOT: Cause of transmission.

nORG: Source address.

asduAddr: Common ASDU address

eClass: Priority class.

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


ST_IEC870_5_101AOInfoObj

TYPE ST_IEC870_5_101AOInfoObj

Information object description.

TYPE ST_IEC870_5_101AOInfoObj :
STRUCT
    objAddr 	: DWORD; (* Information object address *)
    stream 	: ST_IEC870_5_101Stream; (* Information element of max. length *)
END_STRUCT
END_TYPE

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


ST_IEC870_5_101Stream

TYPE ST_IEC870_5_101Stream

Variables of this type are used for data buffer (Stream). In the stream "raw" databytes are buffered in that order they have to be sent /received later. During sending or receiving the data byte zero is sent/received first.

TYPE ST_IEC870_5_101Stream :
STRUCT
    length 	: DWORD := 0; (* current stream length *)
    data 	: ARRAY[0..IEC870_MAX_ASDU_DATA_BYTE] OF BYTE; (* stream data *)
END_STRUCT
END_TYPE

length: Current number of data bytes in the stream;

data: Stream data buffer;

Memory description of a stream variable with an intermediate stored DWORD variable with the value: 16#BECF1234. Please regard the interchanged data bytes in the Intel format!

length | data
4 | 16#34 | 16#12 | 16#CF | 16#BE | ... | ... | ... | ... | ... | ... | ... | IEC870_MAX_ASDU_DATA_BYTE

Please use the following functions to change the memory content of a stream variable:

Function | Description
F_iecResetStream | Stream Initialisation /Reset.
F_iecCopyBufferToStream | Copies data bytes from an external buffer variable to the stream. The memory content of the stream variable increases.
F_iecCopyStreamToBuffer | Copies data bytes from the stream to an external buffer variable. The memory content of the stream variable remains unchanged.
F_iecCopyStreamToStream | Copies data bytes from one stream to another stream. The memory content of the source variable remains unchanged. The memory content of the target variable increases.
F_iecMoveStreamToBuffer | Copies data bytes from the stream to an external buffer variable and deletes afterwards the copied data bytes in the stream. The memory content of the stream variable decreases.
F_iecMoveStreamToStream | Copies data bytes from the source stream to the target stream an deletes afterwards the copied data bytes in the source stream. The memory content of the source variable decreases and the memory content of the target variable increases.

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


ST_IEC870_5_101SystemParams

TYPE ST_IEC870_5_101SystemParams

TYPE ST_IEC870_5_101SystemParams :
STRUCT
    asduAddr 	: DWORD := 11;
    asduAddrRev 	: DWORD := 22;
    asduFmt 		: ST_IEC870_5_101AsduFmtParams := (	eCOTSize 	:= eIEC870_COT_TwoOctets,
                            eAsduAddrSize 	:= eIEC870_AsduAddr_TwoOctets,
                            eObjAddrSize 	:= eIEC870_ObjAddr_ThreeOctets );
    bEndOfInit 	: BOOL := TRUE;

    bSyncTime 	: BOOL := TRUE;
    bSyncPCTime 	: BOOL := FALSE;

    bUsePCTime 	: BOOL := TRUE;
    tSyncToPCTime 	: TIME := T#0s;
    sPCTimeNetID 	: T_AmsNetID := '';

    bTimeCOT3 	: BOOL := FALSE;
    tSyncTimeut 	: TIME := T#0m;

    bACTCONRes 	: BOOL := TRUE;
    bACTTERMRes 	: BOOL := TRUE;

    bPerCyclic 	: BOOL := FALSE;
    tPerCyclicBase 	: TIME := T#60s;

    bBackScan 	: BOOL := FALSE;
    tBackScanCycle 	: TIME := T#60s;

    bPerFRZ 		: BOOL := FALSE;
    tPerFRZCycle 	: TIME := T#60s;

    tSelExecTimeout 	: TIME := T#10s;
    tActConTimeout 	: TIME := T#5s;
    tActTermTimeout 	: TIME := T#30s;
    tDeactConTimeout 	: TIME := T#5s;
    tReadResTimeout 	: TIME := T#5s;

    dbgMode 		: DWORD := 0; (* 0 => disabled,
                Bit 0 set => IEC870_DEBUGMODE_ASDU => debug asdu's,
                Bit 1 set => IEC870_DEBUGMODE_DEVSTATE => debug device state changes
                Bit 2 set => IEC870_DEBUGMODE_LINKLAYER => link layer frame data *)
    orgAddr 		: BYTE := 1; (* Oiginator address, reserved, not used *)

    bOverwrite 	: BOOL := FALSE;(* TRUE = Overwrite oldest entries, FALSE = don't overwrite *)
END_STRUCT
END_TYPEEND_TYPE

asduAddr: Common ASDU address in standard direction. Default: 11.

asduAddrRev: Common ASDU address in reverse direction. Default: 22.

asduFmt: ASDU format parameter (e.g. Octet length of the transfer cause, ASDU address and the Object address );

bEndOfInit: If TRUE, send M_EI_NA_1 (End of init) after station initialisation is completed. Station initialisation is carried out during system start-up or after a process reset. Default: TRUE.

bSyncTime: If TRUE, enable IEC system time synchronization after reception of C_CS_NA_1 command. Default: TRUE.

bSyncPCTime: If TRUE, synchronise the IEC system time and the system time of the TwinCAT PC (the Windows system time in the taskbar). Default: FALSE.

bUsePCTime: If TRUE, synchronise the IEC system time with the system time of the PC. After the initialisation of the substation, the IEC system time is first synchronised with the system time of the TwinCAT PC. Default: TRUE.

tSyncToPCTime: Controls the cyclic synchronisation of the IEC system itme with the system time of the TwinCAT PC. Implemented in IEC870-5-104 slave v3.0.3 and higher. The cyclic synchronisation is deactivated if tSyncToPCTime = T#0s . Default: T#0s.

sPCTimeNetID: TwinCAT network address of the PC whose system time is to be used for the synchronisation. For the local PC an empty string may be specified. Default: empty stirng = local PC.

bTimeCOT3: If TRUE, send the system time to the central station with the cause of transmission <3> spontaneous on the hour. Default: FALSE.

tSyncTimeout: Clock time synchronsation intervall timeout monitoring. Implemented in IEC870-5-101/104 slave libraries v2.0.0 and higher. Earlier versions don´t use this parameter. The time stamps have a IV-Quality-Flag (invalid). For value <> T#0m (eg. T#60m) the IV-Quality-Flag is set invalid for all following time stamps if during one hour the Clock time synchronsation has not been executed. The IV-Quality-Flag of the time stamp can be used by the master as indicator for the quality of the time stamp. If tSyncTimeout = T#0m the monitoring is not active . Default: T#0s.

bACTCONRes: If TRUE, send ACTCON response.

bACTTERMRes: If TRUE, send ACTTERM response.

bPerCyclic: If TRUE, enable cyclic/ periodic data transfer

tPerCyclicBase: Base time of cyclic/ periodic data transfer

bBackScan: If TRUE, enable back scan.

tBackScanCycle: Cycle time for back scan.

bPerFRZ: If TRUE, activate local re-storing/resetting of the counter values.

tPerFRZCycle: Cycle time for local re-storing/resetting.

tSelExecTimeout: Max. select/execute time (control station only).

tActConTimeout: Max. activation confirmation time (control station only).

tActTermTimeout: Max. activation termination time (control station only).

tDeactConTimeout: Max. deactivation confirmation time (control station only).

tReadResTimeout: Max. Read response time (control station only).

dbgMode:Debug flags.

Value | Description
IEC870_DEBUGMODE_DISABLED | Log disabled
IEC870_DEBUGMODE_ASDU | The ASDUs are logged as hexadecimal output in the application log.
IEC870_DEBUGMODE_DEVSTATE | Changes in station status are logged in the application log.
IEC870_DEBUGMODE_LINKLAYER | Link layer frames are logged in the application log IEC870-5-101 slave library: all versions IEC870-5-104 slave library: v2.0.0 and higher
IEC870_DEBUGMODE_LINKERROR | Link layer errors are logged in the application log

The flags can be ORed in the desired combination.

orgAddr: Source address (not used).

bOverwrite: Implemented from IEC870-5-104 slave library v3.0.14 and higher. Activates/deactivates the overwriting of the oldest messages in the send buffer if the max. permissible buffer size is exceeded. This parameter is active only in the offline mode, (i.e. if the connection has been interrupted) and if offline data storage has additionally been activated via the bRetainBuffer parameter in the protocol parameters (ST_IEC870_5_104ProtPara). In online mode, i.e. if data transfer has been started, no older messages are overwritten (otherwise some intermediate values would possibly be missing).

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


ST_IEC870_5_101DeviceInterface

TYPE ST_IEC870_5_101DeviceInterface

TYPE ST_IEC870_5_101DeviceInterface :
STRUCT
    asduAddr 	: DWORD;
    asduAddrRev 	: DWORD;
    dataLink 	: ST_IEC870_5_101DataLink;
    clock 		: ST_IEC870_5_101SystemRTC;
    comp 		: ST_IEC870_5_101DeviceCompatibility;
    errors 		: FB_IEC870_5_101ErrorFifo;
    status 		: DWORD;
END_STRUCT
END_TYPEEND_TYPE

asduAddr: Common ASDU address in standard direction;

asduAddrRev: Common ASDU address in reverse direction;

dataLink: Internal ASDU Send/Receive Fifos;

clock: IEC system time object;

comp: Compatibility list with mapping between ASDU types and transfer causes;

errors: Device error fifo;

status: Global device status. 1=OK, 0=Not Ok;

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


ST_IEC870_5_101AsduFmtParams

TYPE ST_IEC870_5_101AsduFmtParams

TYPE ST_IEC870_5_101AsduFmtParams :
STRUCT
    eCOTSize 	: E_IEC870_5_101COTSize 		:= eIEC870_COT_TwoOctets;
    eAsduAddrSize 	: E_IEC870_5_101AsduAddrSize 	:= eIEC870_AsduAddr_TwoOctets;
    eObjAddrSize 	: E_IEC870_5_101ObjAddrSize 	:= eIEC870_ObjAddr_ThreeOctets;
END_STRUCT
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


ST_IEC870_5_101ErrorFifoEntry

TYPE ST_IEC870_5_101ErrorFifoEntry

IEC60870-5-10x device error

TYPE ST_IEC870_5_101ErrorFifoEntry :
STRUCT
    nErrId : UDINT;
    eSrcId : E_IEC870_5_101ErrorSourceID;
END_STRUCT
END_TYPEEND_TYPE

nErrID: error code.

eSrcID: error source.The error source gives detailed information about error cause, component or service which reports the error.

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


ST_IEC870_5_101AcquisitionParams

TYPE ST_IEC870_5_101AcquisitionParams

From product version:

  • TwinCAT PLC Library IEC60870-5-104 controlling station v1.0.0 and higher;
  • TwinCAT PLC Library IEC60870-5-101 controlling station v1.0.1 and higher.

Configuration parameters for cyclic data acquisition. The initialisation sequence commands configured in the arrInitSeq array are executed once after receipt of M_EI_NA_1 (end of initialisation) or after the connection is established. The cyclic commands configured via the structure parameters testCmd, clockSync, arrGenro, arrCoro or genCmd are then executed.

TYPE ST_IEC870_5_101AcquisitionParams :
STRUCT
    (* Initialization sequence steps *)
    arrInitSeq : ARRAY[IEC870_MIN_ISTEP..IEC870_MAX_ISTEP] OF E_IEC870_5_101InitSeqStep :=
    eIEC870_ISTEP_TEST, (* Send test command *)
    eIEC870_ISTEP_CLOCK, (* Send clock synchronization command *)
    eIEC870_ISTEP_GENRO, (* Send general interrogation command *)
    eIEC870_ISTEP_CORO, (* Send counter interrogation command *)
    eIEC870_ISTEP_UNUSED; (* Reserved *)

    (* Test command polling settings *)
    testCmd : ST_IEC870_5_101TestPollParams := (
    asduAddr := IEC870_ASDUADDR_SYSPARA,
    tPollCycle := T#60s,
    bEnable := TRUE );

    (* Clock synchronisation polling settings *)
    clockSync : ST_IEC870_5_101ClockPollParams := (
    asduAddr := IEC870_ASDUADDR_SYSPARA,
    tPollCycle := T#60s,
    bEnable := TRUE );

    (* Station interrogation polling settings *)
    arrGenro : ARRAY[0..16] OF ST_IEC870_5_101GenroPollParams := (
    asduAddr := IEC870_ASDUADDR_SYSPARA,
    tPollCycle := T#60s,
    eQOI := eIEC870_QOI_INROGEN,
    bEnable := TRUE );

    (* Counter interrogation polling settings *)
    arrCoro : ARRAY[0..4] OF ST_IEC870_5_101CoroPollParams := (
    asduAddr := IEC870_ASDUADDR_SYSPARA,
    tPollCycle := T#60s,
    eRQT := eIEC870_RQT_REQCOGEN,
    eFRZ := eIEC870_FRZ_READ,
    bEnable := TRUE );

    (* General command acquisition settings *)
    genCmd : ST_IEC870_5_101GenCmdPollParams := (
    tPollCycle := T#1h,
    bEnable := FALSE );

    (* Delay command acquisition settings *)
    delayCmd : ST_IEC870_5_101DelayPollParams := (
    tDelay := T#5s );

    eAODBType : E_IEC870_5_101AODBType := eIEC870_AODB_STATIC;
END_STRUCT
END_TYPE

arrInitSeq: Initialisation sequence. The initialisation sequence is always executed once after receipt of M_EI_NA_1 (end of initialisation) or after the connection is established.

testCmd: Parameter for cyclic test commands. Default: One test command every 60 seconds.

clockSync: Parameter for cyclic time synchronisation commands. Default: Time synchronisation every 60 s.

arrGenro: Parameter for cyclic station query commands. Station queries for up to 17 datapoint groups may be configured. Default: One station query from the 'General' group every 60 s.

arrCoro: Parameter for cyclic counter query commands. Counter queries for up to 5 counter groups may be configured. Default: One counter query from the 'General' group every 60 s.

genCmd: Parameter for cyclic transmission of data points in controlling direction (single-commands, double-commands, setpoint-commands and so forth). Default: Execute all commands every 60 minutes.

delayCmd: Parameter for delay commands. Execution delay time of the next initialisation step command. Default: Delay time = 5 s.

eAODBType: Application database type. This parameter defines how the data points are stored in the application database.

Example in ST:

In the following program section cyclic data acquisition is configured as follows: All initialisation steps are deactivated. The cyclic test command and time synchronisation command are also deactivated. In addition to the standard station query a further station query from group 1 is configured (every 100 s). In addition to the standard counter query, a counter query (freezing) from counter group 1 is configured (every 200 s).

PROGRAM P_AcquisitionConfig
VAR_IN_OUT
    acqPara : ST_IEC870_5_101AcquisitionParams;
END_VAR
acqPara.arrInitSeq[0] 		:= eIEC870_ISTEP_UNUSED;
acqPara.arrInitSeq[1] 		:= eIEC870_ISTEP_UNUSED;
acqPara.arrInitSeq[2] 		:= eIEC870_ISTEP_UNUSED;
acqPara.arrInitSeq[3] 		:= eIEC870_ISTEP_UNUSED;
acqPara.arrInitSeq[4] 		:= eIEC870_ISTEP_UNUSED;

acqPara.testCmd.bEnable 		:= FALSE;

acqPara.clockSync.bEnable 		:= FALSE;

acqPara.arrGenro[1].asduAddr 	:= IEC870_ASDUADDR_SYSPARA;
acqPara.arrGenro[1].eQOI 		:= eIEC870_QOI_INRO1;
acqPara.arrGenro[1].tPollCycle 	:= T#100s;
acqPara.arrGenro[1].bEnable 	:= TRUE;

acqPara.arrCoro[1].asduAddr 	:= IEC870_ASDUADDR_SYSPARA;
acqPara.arrCoro[1].eFRZ 		:= eIEC870_FRZ_FREEZE;
acqPara.arrCoro[1].eRQT 		:= eIEC870_RQT_REQCO1;
acqpara.arrCoro[1].tPollCycle 	:= T#200s;
acqPara.arrCoro[1].bEnable 	:= TRUE;

Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


ST_IEC870_5_101TestPollParams

TYPE ST_IEC870_5_101TestPollParams

From product version: TwinCAT PLC Library IEC60870-5-104 controlling station v1.0.0 and higher.

Configuration parameter for the cyclic test command.

TYPE ST_IEC870_5_101TestPollParams:
STRUCT
    asduAddr 	: DWORD := IEC870_ASDUADDR_SYSPARA;
    tPollCycle 	: TIME := T#60s;
    bEnable 		: BOOL := FALSE;
END_STRUCT
END_TYPE

asduAddr: Target address;

tPollCycle: Cycle time of the test command.

bEnable: Enables (TRUE) or disables (FALSE) the cyclic test commands.

Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


ST_IEC870_5_101ClockPollParams

TYPE ST_IEC870_5_101ClockPollParams

From product version: TwinCAT PLC Library IEC60870-5-104 controlling station v1.0.0 and higher.

Configuration parameter for the cyclic clock time synchronzation command.The station that sends clock time synchronization commands.has an own internal software clock. This clock is synchronized with the local windows system time ( the clock time in the windows task bar) during the station initialization. During operation the target stations are synchronized via the clock time synchronization commands with the tie of the internal software clock.

TYPE ST_IEC870_5_101ClockPollParams:
STRUCT
    asduAddr 	: DWORD := IEC870_ASDUADDR_SYSPARA;
    tPollCycle 	: TIME := T#60s;
    bEnable 		: BOOL := FALSE;
END_STRUCT
END_TYPE

asduAddr: Target address

tPollCycle: Cycle time of clock time synchronization command.

bEnable: Enables/disables the cyclic clock time synchronization commands.

Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


ST_IEC870_5_101GenroPollParams

TYPE ST_IEC870_5_101GenroPollParams

From product version: TwinCAT PLC Library: IEC60870-5-104 controlling station v1.0.0 and higher.

Configuration parameter for the cyclic station poll command.

TYPE ST_IEC870_5_101GenroPollParams:
STRUCT
    asduAddr 	: DWORD := IEC870_ASDUADDR_SYSPARA;
    tPollCycle 	: TIME := T#60s;
    eQOI 		: E_IEC870_5_101QOI := eIEC870_QOI_INROGEN;
    bEnable 		: BOOL := FALSE;
END_STRUCT
END_TYPE

asduAddr: Target address

tPollCycle: station poll cycle time.

eQOI: Polling parameter/characteristic value

bEnable: Enables(TRUE) or disables (FALSE) the station poll commands.

Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


ST_IEC870_5_101CoroPollParams

TYPE ST_IEC870_5_101CoroPollParams

From product version: TwinCAT PLC Library IEC60870-5-104 controlling station v1.0.0 and higher.

Configuration parameters for the cyclic counter query command.

TYPE ST_IEC870_5_101CoroPollParams:
STRUCT
    asduAddr 	: DWORD := IEC870_ASDUADDR_SYSPARA;
    tPollCycle 	: TIME := T#60s;
    eRQT 		: E_IEC870_5_101RQT := eIEC870_RQT_REQCOGEN;
    eFRZ 		: E_IEC870_5_101FRZ := eIEC870_FRZ_READ;
    bEnable 		: BOOL := FALSE;
END_STRUCT
END_TYPE

asduAddr: Target address;

tPollCycle:Cycle time of the counter query command.

eRQT: Counter query ID.

eFRZ: FREEZE/RESET ID.

bEnable : Activates/deactivates the cyclic counter query commands.

Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


ST_IEC870_5_101GenCmdPollParams

TYPE ST_IEC870_5_101GenCmdPollParams

General command acquisition settings.

TYPE ST_IEC870_5_101GenCmdPollParams:
STRUCT
    tPollCycle : TIME := T#1h; (* General command cycle time *)
    bEnable : BOOL := FALSE; (* TRUE = Enable cyclic general command, FALSE = Disable *)
    options : DWORD := 0; (* Additional general command options *)
END_STRUCT
END_TYPE

tPollCycle: General command cycle time. Default: 60min.

bEnable: TRUE = Enable cyclic general command, FALSE = Disable.

options: Additional general command options.

Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


ST_IEC870_5_101DelayPollParams

TYPE ST_IEC870_5_101DelayPollParams

Configuration parameters for the delay of the next initialization step.

TYPE ST_IEC870_5_101DelayPollParams:
STRUCT
    tDelay : TIME := T#5s; (* Delay time *)
END_STRUCT
END_TYPE

tDelay: Delay time.

Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


ST_IEC870_5_101HashTableKey

TYPE ST_IEC870_5_101HashTableKey

From product version: TwinCAT PLC Library IEC60870-5-104 controlling station v1.0.0 and higher.

Application object database lookup key. The key can be used for locating and modifying the hash table entries.

TYPE ST_IEC870_5_101HashTableKey :
STRUCT
    eType 		: E_IEC870_5_101TcTypeID := ASDU_TYPEUNDEF;
    asduAddr 	: DWORD := 0;
    objAddr 		: DWORD := 0;
    group 		: DWORD := 0;
    lookup 		: DWORD := IEC870_LOOKUP_KEY_ALL_ON;
END_STRUCT
END_TYPE

eType: Application object type, ASDU identifier (e.g.: M_SP_NA_1 for single-point or M_DP_NA_1 for double-point etc.).

asduAddr: Common ASDU address.

objAddr : Object address, freely selectable.

group: Object group configuration flags. A description of all group flags can be found here. The flags can be combined with an OR operation. If this parameter is zero the group parameters are ignored.

lookup: Additional lookup key parameters. The available parameters are declared as constants (see table below). They can be combined with an OR operation.

Constant | Value | Description
IEC870_LOOKUP_KEY_ALL_ON | 0 | All parameters are considered in the search (eType, asduAddr, objAddr, group).
IEC870_LOOKUP_KEY_TYPE_OFF | 1 | The eType parameter is ignored in the search.
IEC870_LOOKUP_KEY_ASDUADDR_OFF | 2 | The asduAddr parameter is ignored in the search.
IEC870_LOOKUP_KEY_GROUP_OFF | 4 | The group parameter is ignored in the search.
IEC870_LOOKUP_KEY_OBJADDR_OFF | 8 | The objAddr parameter is ignored in the search. This parameter is not recommended because all data points must be identifiable via a unique object address.

Example in ST:

See function description: F_iecLookupTableEntry, F_iecRemoveTableEntry, F_iecGetPosOfTableEntry.

Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)


ST_IEC870_5_101FBufferCfg

TYPE ST_IEC870_5_101FBufferCfg

From product version: TwinCAT PLC Library IEC60870-5-101/104 substation v3.0.2 / IEC60870-5-104 controlling station v1.0.2 and higher.

Configuration settings for offline ASDU data buffer. This structure is used by the functionblock FB_IEC870_5_101FBufferCtrl .

TYPE ST_IEC870_5_101FBufferCfg :
STRUCT
    sNetID 		: T_AmsNetID := ''; (* TwinCAT System network address *)
    sPathName 	: T_MaxString := 'c:\Temp\data.dat'; (* File buffer path name (max. length = 255 characters) *)
    ePath 		: E_OpenPath := PATH_GENERIC; (* Default: Open generic file *)
    cbBuffer 	: UDINT := 16#100000; (* Max. size of file: 16#100000 = 1MB *)
    bOverwrite 	: BOOL := TRUE; (* TRUE = overwrite oldest entry, FALSE = don't overwrite *)
    bFilter 		: BOOL := FALSE; (* Enable/disable frame filter (reserved)*)
    cotFilter 	: T_IEC870_5_101COTBits := 8(0); (* COT (cause of transfer) filter, reserved for future use *)
    tTimeout 	: TIME := DEFAULT_ADS_TIMEOUT; (* ADS (file access) timeout *)
ND_STRUCT
END_TYPE

sNetID: It is possible here to provide thenetwork address of the TwinCAT computer on which the buffer file is to be created The string can also be empty for the local computer.

sPathName: Contains the path and filename for the file to be opened. Note: The path can only point to the local computer’s file system! This means that network paths can not be used here!

ePath: This input can be used to select a TwinCAT system path on the target device for opening the file.

cbBuffer: Maximum byte size of buffer file. If bOverwrite = FALSE is set and the maximum size was exceeded an error is returned.

bOverwrite: If variable is set TRUE: the oldest entries are overwritten by reaching the maximum size.

bFilter: Not yet implemented. Enables/disables a COT filter (Cause of transfer). Only ASDUs with specific cause of transfer are buffered in the file.

cotFilter: Not yet implemented.. Via this variable COTS (cause of transfer) can be configured, that have tio be buffered in the file.

tTimeout: States the length of the timeout that may not be exceeded by file access.

Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1313 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


ST_IEC870_5_101FBufferStatus

TYPE ST_IEC870_5_101FBufferStatus

From product version: TwinCAT PLC Library IEC60870-5-101/104 substation v3.0.2 / IEC60870-5-104 controllingstation v1.0.2 and higher.

Status information to offline ASDU data buffer. This structure is used by the functionblock FB_IEC870_5_101FBufferCtrl .

TYPE ST_IEC870_5_101FBufferStatus:
STRUCT
    eState 		: E_IEC870_5_101FBufferState := eIEC870_FBUFFER_IDLE; (* File buffer data direction status (storing, loading, idle, error) *)
    nErrID 		: UDINT; (* File access error code *)
    bCorrupted 	: BOOL; (* TRUE => Existing file was corrupted and with new (empty) file replaced.
    FALSE => Existing file was not corrupted or new (empty) file created. *)
    nCount 		: UDINT; (* Number of buffered entries in file *)
END_STRUCT
END_TYPE

eState: Supplies the file buffer data direction status. (File is written, loaded, closed or an error occurs while writing/reading).

nErrID: Supplies the file access ADS error code..

bCorrupted: TRUE: the exisiting file was corrupted and is replaced with a new empty one. A corrupted file occurs if the maximum data buffer size was changed or the file was not closed accurately.

nCount: Number of current buffered entries in the data buffer. The data buffer has to be opened to detect the number of entries in the existing data buffer . That is the connection has to be in the offline mode for a short moment.

Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1313 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


E_IEC870_5_101TcTypeID

TYPE E_IEC870_5_101TcTypeID

Data point type identifier.

TYPE E_IEC870_5_101TcTypeID :
(
    ASDU_TYPEUNDEF := 0, (* (000, 0x00) not allowed *)
    (* reserved standard asdu types *)
    M_SP_NA_1, (* (001, 0x01) Single-point information *)
    M_SP_TA_1, (* (002, 0x02) Single-point information with time tag *)
    M_DP_NA_1, (* (003, 0x03) Double-point information *)
    M_DP_TA_1, (* (004, 0x04) Double-point information with time tag *)
    M_ST_NA_1, (* (005, 0x05) Step position information *)
    M_ST_TA_1, (* (006, 0x06) Step position information with time tag *)
    M_BO_NA_1, (* (007, 0x07) Bitstring of 32 bit *)
    M_BO_TA_1, (* (008, 0x08) Bitstring of 32 bit with time tag *)
    M_ME_NA_1, (* (009, 0x09) Measured value, normalised value *)
    M_ME_TA_1, (* (010, 0x0A) Measured value, normalized value with time tag *)
    M_ME_NB_1, (* (011, 0x0B) Measured value, scaled value *)
    M_ME_TB_1, (* (012, 0x0C) Measured value, scaled value wit time tag *)
    M_ME_NC_1, (* (013, 0x0D) Measured value, short floating point number *)
    M_ME_TC_1, (* (014, 0x0E) Measured value, short floating point number with time tag *)
    M_IT_NA_1, (* (015, 0x0F) Integrated totals *)
    M_IT_TA_1, (* (016, 0x10) Integrated totals with time tag *)
    M_EP_TA_1, (* (017, 0x11) Event of protection equipment with time tag *)
    M_EP_TB_1, (* (018, 0x12) Packed start events of protection equipment with time tag *)
    M_EP_TC_1, (* (019, 0x13) Packed output circuit information of protection equipment with time tag *)
    M_PS_NA_1, (* (020, 0x14) Packed single point information with status change detection *)
    M_ME_ND_1, (* (021, 0x15) Measured value, normalized value without quality descriptor *)
    ASDU_TYPE_22,
    ASDU_TYPE_23,
    ASDU_TYPE_24,
    ASDU_TYPE_25,
    ASDU_TYPE_26,
    ASDU_TYPE_27,
    ASDU_TYPE_28,
    ASDU_TYPE_29,
    M_SP_TB_1, (* (030, 0x1E) Single-point information with time tag CP56Time2a *)
    M_DP_TB_1, (* (031, 0x1F) Double-point information with time tag CP56Time2a *)
    M_ST_TB_1, (* (032, 0x20) Step position information with time tag CP56Time2a *)
    M_BO_TB_1, (* (033, 0x21) Bitstring of 32 bit with time tag CP56Time2a *)
    M_ME_TD_1, (* (034, 0x22) Measured value, normalised value with time tag CP56Time2a *)
    M_ME_TE_1, (* (035, 0x23) Measured value, scaled value with time tag CP56Time2a *)
    M_ME_TF_1, (* (036, 0x24) Measured value, short floating point number with time tag CP56Time2a *)
    M_IT_TB_1, (* (037, 0x25) Integrated totals with time tag CP56Time2a *)
    M_EP_TD_1, (* (038, 0x26) Event of protection equipment with time tag CP56Time2a *)
    M_EP_TE_1, (* (039, 0x27) Packed start events of protection equipment with time tag CP56Time2a *)
    M_EP_TF_1, (* (040, 0x28) Packed output circuit information of protection equipment with time tag CP56Time2a *)
    ASDU_TYPE_41,
    ASDU_TYPE_42,
    ASDU_TYPE_43,
    ASDU_TYPE_44,
    C_SC_NA_1, (* (045, 0x2D) Single command *)
    C_DC_NA_1, (* (046, 0x2E) Double command *)
    C_RC_NA_1, (* (047, 0x2F) Regulating step command *)
    C_SE_NA_1, (* (048, 0x30) Set-point Command, normalised value *)
    C_SE_NB_1, (* (049, 0x31) Set-point Command, scaled value *)
    C_SE_NC_1, (* (050, 0x32) Set-point Command, short floating point number *)
    C_BO_NA_1, (* (051, 0x33) Bitstring 32 bit command *)
    ASDU_TYPE_52,
    ASDU_TYPE_53,
    ASDU_TYPE_54,
    ASDU_TYPE_55,
    ASDU_TYPE_56,
    ASDU_TYPE_57,
    C_SC_TA_1, (* (058, 0x3A) Single command with time tag CP56Time2a *)
    C_DC_TA_1, (* (059, 0x3B) Double command with time tag CP56Time2a *)
    C_RC_TA_1, (* (060, 0x3C) Regulating step command with time tag CP56Time2a *)
    C_SE_TA_1, (* (061, 0x3D) Measured value, normalised value command with time tag CP56Time2a *)
    C_SE_TB_1, (* (062, 0x3E) Measured value, scaled value command with time tag CP56Time2a *)
    C_SE_TC_1, (* (063, 0x3F) Measured value, short floating point number command with time tag CP56Time2a *)
    C_BO_TA_1, (* (064, 0x40) Bitstring of 32 bit command with time tag CP56Time2a *)
    ASDU_TYPE_65,
    ASDU_TYPE_66,
    ASDU_TYPE_67,
    ASDU_TYPE_68,
    ASDU_TYPE_69,
    M_EI_NA_1, (* (070, 0x46) End of Initialisation *)
    ASDU_TYPE_71,
    ASDU_TYPE_72,
    ASDU_TYPE_73,
    ASDU_TYPE_74,
    ASDU_TYPE_75,
    ASDU_TYPE_76,
    ASDU_TYPE_77,
    ASDU_TYPE_78,
    ASDU_TYPE_79,
    ASDU_TYPE_80,
    ASDU_TYPE_81,
    ASDU_TYPE_82,
    ASDU_TYPE_83,
    ASDU_TYPE_84,
    ASDU_TYPE_85,
    ASDU_TYPE_86,
    ASDU_TYPE_87,
    ASDU_TYPE_88,
    ASDU_TYPE_89,
    ASDU_TYPE_90,
    ASDU_TYPE_91,
    ASDU_TYPE_92,
    ASDU_TYPE_93,
    ASDU_TYPE_94,
    ASDU_TYPE_95,
    ASDU_TYPE_96,
    ASDU_TYPE_97,
    ASDU_TYPE_98,
    ASDU_TYPE_99,
    C_IC_NA_1, (* (100, 0x64) Interrogation command *)
    C_CI_NA_1, (* (101, 0x65) Counter interrogation command *)
    C_RD_NA_1, (* (102, 0x66) Read Command*)
    C_CS_NA_1, (* (103, 0x67) Clock synchronisation command *)
    C_TS_NA_1, (* (104, 0x68) Test command *)
    C_RP_NA_1, (* (105, 0x69) Reset process command *)
    C_CD_NA_1, (* (106, 0x6A) C_CD_NA_1 Delay acquisition command *)
    C_TS_TA_1, (* (107, 0x6B) Test command with time tag CP56Time2a *)
    ASDU_TYPE_108,
    ASDU_TYPE_109,
    P_ME_NA_1, (* (110, 0x6E) Parameter of measured values, normalized value *)
    P_ME_NB_1, (* (111, 0x6F) Parameter of measured values, scaled value *)
    P_ME_NC_1, (* (112, 0x70) Parameter of measured values, short floating point number *)
    P_AC_NA_1, (* (113, 0x71) Parameter activation *)
    ASDU_TYPE_114,
    ASDU_TYPE_115,
    ASDU_TYPE_116,
    ASDU_TYPE_117,
    ASDU_TYPE_118,
    ASDU_TYPE_119,
    F_FR_NA_1, (* (120, 0x78) File ready *)
    F_SR_NA_1, (* (121, 0x79) Section ready *)
    F_SC_NA_1, (* (122, 0x7A) Call directory, select file, call file, call section *)
    F_LS_NA_1, (* (123, 0x7B) Last section, last segment *)
    F_FA_NA_1, (* (124, 0x7C) ACK file, ACK section *)
    F_SG_NA_1, (* (125, 0x7D) Segment *)
    F_DR_TA_1, (* (126, 0x7E) Directory *)
    ASDU_TYPE_127,
    (* reserved user asdu types *)
    ASDU_TYPE_128,
    ASDU_TYPE_129,
    ASDU_TYPE_130,
    ASDU_TYPE_131,
    ASDU_TYPE_132,
    ASDU_TYPE_133,
    ASDU_TYPE_134,
    ASDU_TYPE_135,
    ASDU_TYPE_136,
    ASDU_TYPE_137,
    ASDU_TYPE_138,
    ASDU_TYPE_139,
    ASDU_TYPE_140,
    ASDU_TYPE_141,
    ASDU_TYPE_142,
    ASDU_TYPE_143,
    ASDU_TYPE_144,
    ASDU_TYPE_145,
    ASDU_TYPE_146,
    ASDU_TYPE_147,
    ASDU_TYPE_148,
    ASDU_TYPE_149,
    ASDU_TYPE_150,
    ASDU_TYPE_151,
    ASDU_TYPE_152,
    ASDU_TYPE_153,
    ASDU_TYPE_154,
    ASDU_TYPE_155,
    ASDU_TYPE_156,
    ASDU_TYPE_157,
    ASDU_TYPE_158,
    ASDU_TYPE_159,
    ASDU_TYPE_160,
    ASDU_TYPE_161,
    ASDU_TYPE_162,
    ASDU_TYPE_163,
    ASDU_TYPE_164,
    ASDU_TYPE_165,
    ASDU_TYPE_166,
    ASDU_TYPE_167,
    ASDU_TYPE_168,
    ASDU_TYPE_169,
    ASDU_TYPE_170,
    ASDU_TYPE_171,
    ASDU_TYPE_172,
    ASDU_TYPE_173,
    ASDU_TYPE_174,
    ASDU_TYPE_175,
    ASDU_TYPE_176,
    ASDU_TYPE_177,
    ASDU_TYPE_178,
    ASDU_TYPE_179,
    ASDU_TYPE_180,
    ASDU_TYPE_181,
    ASDU_TYPE_182,
    ASDU_TYPE_183,
    ASDU_TYPE_184,
    ASDU_TYPE_185,
    ASDU_TYPE_186,
    ASDU_TYPE_187,
    ASDU_TYPE_188,
    ASDU_TYPE_189,
    ASDU_TYPE_190,
    ASDU_TYPE_191,
    ASDU_TYPE_192,
    ASDU_TYPE_193,
    ASDU_TYPE_194,
    ASDU_TYPE_195,
    ASDU_TYPE_196,
    ASDU_TYPE_197,
    ASDU_TYPE_198,
    ASDU_TYPE_199,
    ASDU_TYPE_200,
    ASDU_TYPE_201,
    ASDU_TYPE_202,
    ASDU_TYPE_203,
    ASDU_TYPE_204,
    ASDU_TYPE_205,
    ASDU_TYPE_206,
    ASDU_TYPE_207,
    ASDU_TYPE_208,
    ASDU_TYPE_209,
    ASDU_TYPE_210,
    ASDU_TYPE_211,
    ASDU_TYPE_212,
    ASDU_TYPE_213,
    ASDU_TYPE_214,
    ASDU_TYPE_215,
    ASDU_TYPE_216,
    ASDU_TYPE_217,
    ASDU_TYPE_218,
    ASDU_TYPE_219,
    ASDU_TYPE_220,
    ASDU_TYPE_221,
    ASDU_TYPE_222,
    ASDU_TYPE_223,
    ASDU_TYPE_224,
    ASDU_TYPE_225,
    ASDU_TYPE_226,
    ASDU_TYPE_227,
    ASDU_TYPE_228,
    ASDU_TYPE_229,
    ASDU_TYPE_230,
    ASDU_TYPE_231,
    ASDU_TYPE_232,
    ASDU_TYPE_233,
    ASDU_TYPE_234,
    ASDU_TYPE_235,
    ASDU_TYPE_236,
    ASDU_TYPE_237,
    ASDU_TYPE_238,
    ASDU_TYPE_239,
    ASDU_TYPE_240,
    ASDU_TYPE_241,
    ASDU_TYPE_242,
    ASDU_TYPE_243,
    ASDU_TYPE_244,
    ASDU_TYPE_245,
    ASDU_TYPE_246,
    ASDU_TYPE_247,
    ASDU_TYPE_248,
    ASDU_TYPE_249,
    ASDU_TYPE_250,
    ASDU_TYPE_251,
    ASDU_TYPE_252,
    ASDU_TYPE_253,
    ASDU_TYPE_254,
    ASDU_TYPE_255,
    ASDU_TYPEMAX (* not used *)
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101IOMappingType

TYPE E_IEC870_5_101IOMappingType

TYPE E_IEC870_5_101IOMappingType :
(
    MAP_AREA_NONE 	:= 0,
    MAP_AREA_MEMORY 	:= 1,
    MAP_AREA_INPUT 	:= 2,
    MAP_AREA_OUTPUT 	:= 4,
    MAP_AREA_DATA 	:= 8
);
END_TYPE

TwinCAT PLC process data range (inputs, outputs, memory, data) into resp. from the IEC process data are to be mapped (copied).

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101AsduAddrSize

TYPE E_IEC870_5_101AsduAddrSize

TYPE E_IEC870_5_101AsduAddrSize :
(
    eIEC870_AsduAddr_OneOctet 		:= 1, (* One octet *)
    eIEC870_AsduAddr_TwoOctets 	:= 2 (* Two octets *)
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101COTSize

TYPE E_IEC870_5_101COTSize

TYPE E_IEC870_5_101COTSize :
(
    eIEC870_COT_OneOctet 	:= 1, (* One octet *)
    eIEC870_COT_TwoOctets 	:= 2 (* Two octets *)
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101LinkAddrSize

TYPE E_IEC870_5_101LinkAddrSize

TYPE E_IEC870_5_101LinkAddrSize :
(
    eIEC870_LinkAddr_None 		:= 0, (* None *)
    eIEC870_LinkAddr_OneOctet 		:= 1, (* One octet *)
    eIEC870_LinkAddr_TwoOctets 	:= 2 (* Two octets *)
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101ObjAddrSize

TYPE E_IEC870_5_101ObjAddrSize

TYPE E_IEC870_5_101ObjAddrSize :
(
    eIEC870_ObjAddr_OneOctet 		:= 1, (* One octet *)
    eIEC870_ObjAddr_TwoOctets 		:= 2, (* Two octets *)
    eIEC870_ObjAddr_ThreeOctets 	:= 3 (* Three octets *)
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101ErrorSourceID

TYPE E_IEC870_5_101ErrorSourceID

Error source.

TYPE E_IEC870_5_101ErrorSourceID :
(
    eIEC870_ESRC_NONE,			(* Error source is unknown *)
    eIEC870_ESRC_COUNTER_INTERROGATION,	(* Error during counter interrogation command execution *)
    eIEC870_ESRC_SYNC_CLOCK_CTRL,	(* Error during execution of clock synchronisation command *)
    eIEC870_ESRC_CLOCK_EVENT,		(* Error during spontanous transmission of clock time *)
    eIEC870_ESRC_GETPCTIME,		(* Error during synchronisation of device time to PC time *)
    eIEC870_ESRC_SETPCTIME,		(* Error during synchronisation of PC time to device time *)
    eIEC870_ESRC_STATION_INTERROGATION,	(* Error during execution of general interrogation *)
    eIEC870_ESRC_READ_DATA_CMD,		(* Error during execution of read command *)
    eIEC870_ESRC_RESET_PROCESS,		(* Error during execution of process reset command *)
    eIEC870_ESRC_TEST_CMD,		(* Error during execution of test command *)
    eIEC870_ESRC_ENDOFINIT,		(* Error during transmission of M_EI_NA_1 (end of initialisation) *)
    eIEC870_ESRC_BACKGROUND_SCAN,	(* Error during execution of background scan *)
    eIEC870_ESRC_COMMAND_CTRL,		(* Error during initialisation of command (single-command, double-command, setpoint-command and so forth ) *)
    eIEC870_ESRC_COMMAND_EXEC,		(* Error during command execution *)
    eIEC870_ESRC_LOCAL_FREEZE_RESET,	(* Error during counter freeze/reset *)
    eIEC870_ESRC_PERIODIC_CYCLIC,	(* Error during cyclic/periodic data transmission *)
    eIEC870_ESRC_USERAPP_OBJECT,	(* Error in application object (invalid configuration/value) *)
    eIEC870_ESRC_USERAPP_SETQUALITY,	(* Error in quality flag execution *)
    eIEC870_ESRC_IEC60870_5_104LINK,	(* Error in IEC60870-5-104 link layer *)
    eIEC870_ESRC_IEC60870_5_101LINK,	(* Error in IEC60870-5-101 link layer *)
    eIEC870_ESRC_COMLIB,		(* Error in the basic serial communication interface *)
    eIEC870_ESRC_POLLING_SEVICE 	(* Error in the acquisition state machine (execution of cyclic poll commands) *)
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101ClassType

TYPE E_IEC870_5_101ClassType

TYPE E_IEC870_5_101ClassType :
(
    eIEC870_Class_None,
    eIEC870_Class_1,
    eIEC870_Class_2
);
END_TYPE

Priority class of ASDU. High prior data are assigned to class 1, low prior data are assigned to class 2.

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101COTType

TYPE E_IEC870_5_101COTType

Cause of transfer

TYPE E_IEC870_5_101COTType:
(
    eIEC870_COT_UNUSED := 0,
    eIEC870_COT_CYCLIC := 1,
    eIEC870_COT_BACKGROUND := 2,
    eIEC870_COT_SPONTAN := 3,
    eIEC870_COT_INIT := 4,
    eIEC870_COT_REQ := 5,
    eIEC870_COT_ACT := 6,
    eIEC870_COT_ACT_CON := 7,
    eIEC870_COT_DEACT := 8,
    eIEC870_COT_DEACT_CON := 9,
    eIEC870_COT_ACT_TERM := 10,
    eIEC870_COT_RETREM := 11,
    eIEC870_COT_RETLOC := 12,
    eIEC870_COT_FILE := 13,
    eIEC870_COT_14 := 14,
    eIEC870_COT_15 := 15,
    eIEC870_COT_16 := 16,
    eIEC870_COT_17 := 17,
    eIEC870_COT_18 := 18,
    eIEC870_COT_19 := 19,
    eIEC870_COT_INROGEN := 20,
    eIEC870_COT_INRO1 := 21,
    eIEC870_COT_INRO2 := 22,
    eIEC870_COT_INRO3 := 23,
    eIEC870_COT_INRO4 := 24,
    eIEC870_COT_INRO5 := 25,
    eIEC870_COT_INRO6 := 26,
    eIEC870_COT_INRO7 := 27,
    eIEC870_COT_INRO8 := 28,
    eIEC870_COT_INRO9 := 29,
    eIEC870_COT_INRO10 := 30,
    eIEC870_COT_INRO11 := 31,
    eIEC870_COT_INRO12 := 32,
    eIEC870_COT_INRO13 := 33,
    eIEC870_COT_INRO14 := 34,
    eIEC870_COT_INRO15 := 35,
    eIEC870_COT_INRO16 := 36,
    eIEC870_COT_REQCOGEN := 37,
    eIEC870_COT_REQCO1 := 38,
    eIEC870_COT_REQCO2 := 39,
    eIEC870_COT_REQCO3 := 40,
    eIEC870_COT_REQCO4 := 41,
    eIEC870_COT_42 := 42,
    eIEC870_COT_43 := 43,
    eIEC870_COT_UNKNOWN_TYPE := 44,
    eIEC870_COT_UNKNOWN_CAUSE := 45,
    eIEC870_COT_UNKNOWN_ASDU_ADDRESS := 46,
    eIEC870_COT_UNKNOWN_OBJECT_ADDRESS := 47,
    eIEC870_COT_48 := 48,
    eIEC870_COT_49 := 49,
    eIEC870_COT_50 := 50,
    eIEC870_COT_51 := 51,
    eIEC870_COT_52 := 52,
    eIEC870_COT_53 := 53,
    eIEC870_COT_54 := 54,
    eIEC870_COT_55 := 55,
    eIEC870_COT_56 := 56,
    eIEC870_COT_57 := 57,
    eIEC870_COT_58 := 58,
    eIEC870_COT_59 := 59,
    eIEC870_COT_60 := 60,
    eIEC870_COT_61 := 61,
    eIEC870_COT_62 := 62,
    eIEC870_COT_63 := 63
);
END_TYPE
Value | Description
eIEC870_COT_UNUSED | Not used
eIEC870_COT_CYCLIC | Cyclic data
eIEC870_COT_BACKGROUND | Background request
eIEC870_COT_SPONTAN | Spontaneous data
eIEC870_COT_INIT | End of initialisation
eIEC870_COT_REQ | Read-Request
eIEC870_COT_ACT | Command activation
eIEC870_COT_ACT_CON | Acknowledgement of command activation
eIEC870_COT_DEACT | Command abort
eIEC870_COT_DEACT_CON | Acknowledgement of command abort
eIEC870_COT_ACT_TERM | Termination of command activation
eIEC870_COT_RETREM | Return because of remote command
eIEC870_COT_RETLOC | Return because local command
eIEC870_COT_FILE | File access
eIEC870_COT_INROGEN | Station interrogation (general)
eIEC870_COT_INRO1 | Station interrogation of group 1
eIEC870_COT_INRO2 | Station interrogation of group 2
eIEC870_COT_INRO3 | Station interrogation of group 3
eIEC870_COT_INRO4 | Station interrogation of group 4
eIEC870_COT_INRO5 | Station interrogation of group 5
eIEC870_COT_INRO6 | Station interrogation of group 6
eIEC870_COT_INRO7 | Station interrogation of group 7
eIEC870_COT_INRO8 | Station interrogation of group 8
eIEC870_COT_INRO9 | Station interrogation of group 9
eIEC870_COT_INRO10 | Station interrogation of group 10
eIEC870_COT_INRO11 | Station interrogation of group 11
eIEC870_COT_INRO12 | Station interrogation of group 12
eIEC870_COT_INRO13 | Station interrogation of group 13
eIEC870_COT_INRO14 | Station interrogation of group 14
eIEC870_COT_INRO15 | Station interrogation of group 15
eIEC870_COT_INRO16 | Station interrogation of group 16
eIEC870_COT_REQCOGEN | Counter request (general)
eIEC870_COT_REQCO1 | Counter request of group 1
eIEC870_COT_REQCO2 | Counter request of group 2
eIEC870_COT_REQCO3 | Counter request of group 3
eIEC870_COT_REQCO4 | Counter request of group 4
eIEC870_COT_UNKNOWN_TYPE | Unknown type
eIEC870_COT_UNKNOWN_CAUSE | Unknown transmission cause
eIEC870_COT_UNKNOWN_ASDU_ADDRESS | Unknown collective ASDU address
eIEC870_COT_UNKNOWN_OBJECT_ADDRESS | Unknown object address
eIEC870_COT_14..eIEC870_COT_19 eIEC870_COT_42..eIEC870_COT_43 eIEC870_COT_48..eIEC870_COT_63 | Reserved/not used area

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101FifoDbgFlags

TYPE E_IEC870_5_101FifoDbgFlags

Debug output flags. If the debug output is activated, the ASDU hexbytes are logged in the TwinCAT System Manager logger window.

TYPE E_IEC870_5_101FifoDbgFlags:
(
    eIEC870_FIFO_DBG_OFF := 0,
    eIEC870_FIFO_DBG_PUT := 1,
    eIEC870_FIFO_DBG_GET := 2,
    eIEC870_FIFO_DBG_ALL := 3
);
END_TYPE

Important Note:

Please regard that the debug output creates a higher system load.

Value | Description
eIEC870_FIFO_DBG_OFF | No debug output
eIEC870_FIFO_DBG_PUT | Debug output when adding the Fifo elements
eIEC870_FIFO_DBG_GET | Debug otuput when removing the Fifo elements
eIEC870_FIFO_DBG_ALL | Debug output when adding und removing the Fifo elements

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101AODBType

TYPE E_IEC870_5_101AODBType

From product version: TwinCAT PLC Library IEC60870-5-104 controlling station v1.0.0 and higher.

Type of application data base. At the moment only the type eIEC870_AODB_STATIC is supported. That means all application objects (data points) have to be configured by the PLC application.

TYPE E_IEC870_5_101AODBType :
(
    eIEC870_AODB_STATIC := 0,
    eIEC870_AODB_DYNAMIC := 1
);
END_TYPE

Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)


E_IEC870_5_101InitSeqStep

TYPE E_IEC870_5_101InitSeqStep

Commands to be executed once ( initialisation sequence ) after receipt of M_EI_NA_1 ( end of initialisation ) or after the communication establishment with the slave device.

TYPE E_IEC870_5_101InitSeqStep :
(
    eIEC870_ISTEP_UNUSED := 0, 	(* Do nothing *)
    eIEC870_ISTEP_CLOCK, 	(* Send clock synchronization command *)
    eIEC870_ISTEP_TEST, 	(* Send test command *)
    eIEC870_ISTEP_GENRO, 	(* Send general interrogation command *)
    eIEC870_ISTEP_CORO, 	(* Send counter interrogation command *)
    eIEC870_ISTEP_COMMAND, 	(* Send general command *)
    eIEC870_ISTEP_DELAY 	(* Delay timer *)
);
END_TYPE
Initialisation step | Description
eIEC870_ISTEP_UNUSED | The initialisation step is not used.
eIEC870_ISTEP_CLOCK | The server is to send a clock synchronization command.
eIEC870_ISTEP_TEST | The server is to send a test command.
eIEC870_ISTEP_GENRO | The server is to send a general interrogation command.
eIEC870_ISTEP_CORO | The server ist to send a general conunter interrogation command.
eIEC870_ISTEP_COMMAND | The server is to send commands once (all data points in controlling direction: single-points, double-points, set-point commands and so forth).
eIEC870_ISTEP_DELAY | The server is to wait the specified number of time prior execution of the next initialisation step command
Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


E_IEC870_5_101FBufferState

TYPE E_IEC870_5_101FBufferState

From product version: TwinCAT PLC Library IEC60870-5-101/104 substation v3.0.2 / IEC60870-5-104 controlling station v1.0.2 and higher.

Current offline ASDU file buffer state.

TYPE E_IEC870_5_101QU :
(
    eIEC870_FBUFFER_IDLE := 0,
    eIEC870_FBUFFER_SAVING := 1,
    eIEC870_FBUFFER_LOADING := 2,
    eIEC870_FBUFFER_ERROR := 3
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1313 | PC oder CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


E_IEC870_5_101SCS

TYPE E_IEC870_5_101SCS

Single command state.

TYPE E_IEC870_5_101SCS :
(
    eIEC870_SCS_OFF 	:= 0,
    eIEC870_SCS_ON 	:= 1
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101DCS

TYPE E_IEC870_5_101DCS

Double command state.

TYPE E_IEC870_5_101DCS :
(
    eIEC870_DCS_INDETERMINATE0 	:= 0,
    eIEC870_DCS_OFF 			:= 1,
    eIEC870_DCS_ON 			:= 2,
    eIEC870_DCS_INDETERMINATE3 	:= 3
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101COI

TYPE E_IEC870_5_101COI

Cause of initialization.

TYPE E_IEC870_5_101COI :
(
    eIEC870_COI_LOCAL_POWER_ON 	:= 0, (* Local power ON *)
    eIEC870_COI_LOCAL_MANUAL_RESET 	:= 1, (* Local manual reset *)
    eIEC870_COI_REMOTE_RESET 		:= 2 (* Remote reset *)
    (* <3..31> := reserved for future norm definitions
    <32..127> := reserved for user definitions (private range) *)
);
END_TYPE
Development Environment | Target System | PLC Libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101QOI

TYPE E_IEC870_5_101QOI

Qualifier of interrogation command.

TYPE E_IEC870_5_101QOI :
(
    eIEC870_QOI_UNUSED 	:= 0, (* not used*)
    (* <1..19> := reserved for standard definitions of this companion standard *)
    eIEC870_QOI_INROGEN 	:= 20, (* global station interrogation *)
    eIEC870_QOI_INRO1 	:= 21, (* group 1 station interrogation *)
    eIEC870_QOI_INRO2 	:= 22, (* group 2 station interrogation...*)
    eIEC870_QOI_INRO3 	:= 23,
    eIEC870_QOI_INRO4 	:= 24,
    eIEC870_QOI_INRO5 	:= 25,
    eIEC870_QOI_INRO6 	:= 26,
    eIEC870_QOI_INRO7 	:= 27,
    eIEC870_QOI_INRO8 	:= 28,
    eIEC870_QOI_INRO9 	:= 29,
    eIEC870_QOI_INRO10 	:= 30,
    eIEC870_QOI_INRO11 	:= 31,
    eIEC870_QOI_INRO12 	:= 32,
    eIEC870_QOI_INRO13 	:= 33,
    eIEC870_QOI_INRO14 	:= 34,
    eIEC870_QOI_INRO15 	:= 35,
    eIEC870_QOI_INRO16 	:= 36 (* group 16 station interrogation*)
    (* <37..63> := reserved for future norm definitions of this companion standard (compatible range) *)
    (* <64..255> := reserved for user definitions (private range) *)
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101QL

TYPE E_IEC870_5_101QL

Qualifier of set-point command.

TYPE E_IEC870_5_101QL :
(
    eIEC870_QL_DEFAULT := 0
    (* <1..63> := reserved for standard definitions (compatible range)
    <64..127> := reserved for special use (private range) *)
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101FRZ

TYPE E_IEC870_5_101FRZ

Freeze/reset qualifier of counter interrogation command.

TYPE E_IEC870_5_101FRZ :
(
    eIEC870_FRZ_READ 		:= 0, (* Read only (no freeze or reset) *)
    eIEC870_FRZ_FREEZE 	:= 1, (* Counter freeze without reset (value frozen represents integrated total) *)
    eIEC870_FRZ_FREEZE_AND_RESET := 2, (* Counter freeze with reset (value frozen represents incremental information) *)
    eIEC870_FRZ_RESET 	:= 3 (* Counter reset *)
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101RQT

TYPE E_IEC870_5_101RQT

Request qualifier of counter interrogation command.

TYPE E_IEC870_5_101RQT :
(
    eIEC870_RQT_NONE 		:= 0, (* No counter read *)
    eIEC870_RQT_REQCO1 	:= 1, (* Group 1 counter interrogation *)
    eIEC870_RQT_REQCO2 	:= 2, (* Group 2 counter interrogation *)
    eIEC870_RQT_REQCO3 	:= 3, (* Group 3 counter interrogation *)
    eIEC870_RQT_REQCO4 	:= 4, (* Group 4 counter interrogation *)
    eIEC870_RQT_REQCOGEN 	:= 5 (* General counter interrogation *)
    (* <6..31> reserved for future norm definitions
    <32..63> reserved for user definitions (private range) *)
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101QRP

TYPE E_IEC870_5_101QRP

Qualifier of reset process command.

TYPE E_IEC870_5_101QRP :
(
    eIEC870_QRP_UNUSED 	:= 0, (* not used *)
    eIEC870_QRP_GENERAL 	:= 1, (* general process reset *)
    eIEC870_QRP_TTEVENTS 	:= 2 (* reset pending events with time tag *)
    (* <3..127> := reserved for future norm definitions
    <128..255> := reserved for user definitions (private range) *)
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101QU

TYPE E_IEC870_5_101QU

Qualifier of command.

TYPE E_IEC870_5_101QU :
(
    eIEC870_QU_UNSPECIFIED 	:= 0,
    eIEC870_QU_SHORTPULSE 	:= 1,
    eIEC870_QU_LONGPULSE 	:= 2,
    eIEC870_QU_PERSISTENT 	:= 3
    (* <4..8> := reserved for standrad definitions of companion standard (compatible range)
    <9..15> := reserved for the selection of other predefined functions
    <16..31> := reserved for special use (private range) *)
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101ES

TYPE E_IEC870_5_101ES

Event state (single event of protection equipment).

TYPE E_IEC870_5_101ES:
(
    eIEC870_ES_INDETERMINATE0 	:= 0,
    eIEC870_ES_OFF 		:= 1,
    eIEC870_ES_ON 		:= 2,
    eIEC870_ES_INDETERMINATE3 	:= 3
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101KPA

TYPE E_IEC870_5_101KPA

Kind of parameter.

TYPE E_IEC870_5_101KPA:
(
    eIEC870_KPA_UNUSED := 0,
    eIEC870_KPA_THRESH := 1,
    eIEC870_KPA_FILTER := 2,
    eIEC870_KPA_LOLIMIT := 3,
    eIEC870_KPA_HILIMIT := 4
    (* <5..31> := reserved for standard definitions (compatible range)
    <32..63> := reserved for special use (private range) *)
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101QPA

TYPE E_IEC870_5_101QPA

Qualifier of parameter activation.

TYPE E_IEC870_5_101QPA:
(
    eIEC870_QPA_UNUSED := 0,
    eIEC870_QPA_GENERAL := 1,
    eIEC870_QPA_OBJECT := 2,
    eIEC870_QPA_TRANSMISSION := 3
    (* <4..127> := reserved for standard definitions (compatible range)
    <128..255> := reserved for special use (private range) *)
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101RCS

TYPE E_IEC870_5_101RCS

Regulating step command state.

TYPE E_IEC870_5_101RCS :
(
    eIEC870_RCS_NOTALLOWED0 	:= 0,
    eIEC870_RCS_DECREMENT 	:= 1,
    eIEC870_RCS_INCREMENT 	:= 2,
    eIEC870_RCS_NOTALLOWED3 	:= 3
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101SPI

TYPE E_IEC870_5_101SPI

Single-point information.

TYPE E_IEC870_5_101SPI :
(
    eIEC870_SPI_OFF 	:= 0,
    eIEC870_SPI_ON 	:= 1
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


E_IEC870_5_101DPI

TYPE E_IEC870_5_101DPI

Double-point information.

TYPE E_IEC870_5_101DPI :
(
    eIEC870_DPI_INDETERMINATE0 	:= 0,
    eIEC870_DPI_OFF 			:= 1,
    eIEC870_DPI_ON 			:= 2,
    eIEC870_DPI_INDETERMINATE3 	:= 3
);
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


T_HAODBTable

TYPE T_HAODBTable

From product version: TwinCAT PLC Library IEC60870-5-104 controlling station v1.0.0 and higher.

Application object data base handle (hash table handle). The table handle has to be initialized once before using with the function F_iecCreateTableHnd.

TYPE T_HAODBTable :
STRUCT
(*...*)
END_STRUCT
END_TYPE

The access to structured variables is not direct, but indirect with the aid of the available functions and function blocks. The following functions can be used:

Function | Description
F_iecCreateTableHnd | Initializes the hash table handle
F_iecAddTableEntry | Configures and adds a new hash table entry
F_iecRemoveTableEntry | Removes a hash table entry
F_iecLookupTableEntry | Checks if a special hash table entry exists
F_iecGetPosOfTableEntry | Determines the linear position of a hash table entry

Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


T_CP16Time2a

TYPE T_CP16Time2a

Two octets binary time format.

TYPE T_CP16Time2a :
STRUCT
    Milliseconds 	: WORD; (* 0..59.999ms = 60sec = 1min *)
END_STRUCT
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


T_CP24Time2a

TYPE T_CP24Time2a

Three octets binary time format.

TYPE T_CP24Time2a :
STRUCT
    Milliseconds 	: WORD; (* 0..59.999ms = 60sec = 1min *)
    IVResMinute 	: BYTE; (* Bit 7 = IV (invalid time), Bit 6 = Res (spare bit), Bit 0..5 = Minutes (0..59min) *)
END_STRUCT
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


T_CP32Time2a

TYPE T_CP32Time2a

Four octets binary time format.

TYPE T_CP32Time2a :
STRUCT
    Milliseconds 	: WORD; (* 0..59.999ms = 60sec = 1min *)
    IVResMinute 	: BYTE; (* Bit 7 = IV (invalid time), Bit 6 = Res (spare bit), Bit 0..5 = Minutes (0..59min) *)
    SURes2Hour 	: BYTE; (* Bit 7 = SU (1=summer time, 0=normal time), Bits 5..6 = Res2, Bits 0..4 = Hours (0..23) *)
END_STRUCT
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.10.0 Build >= 1307 | PC oder CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )


T_CP56Time2a

TYPE T_CP56Time2a

Seven octets binary time format.

TYPE T_CP56Time2a :
STRUCT
    Milliseconds 	: WORD; (* 0..59.999ms = 60sec = 1min *)
    IVResMinute 	: BYTE; (* Bit 7 = IV (invalid time), Bit 6 = Res (spare bit), Bit 0..5 = Minutes (0..59min) *)
    SURes2Hour 	: BYTE; (* Bit 7 = SU (1=summer time, 0=normal time), Bits 5..6 = Res2, Bits 0..4 = Hours (0..23) *)
    DOWDay 		: BYTE; (* Bits 5..7 = Day of week (1..7, not used 0 !!!), Bits 0..4 = Day of month (1..31)*)
    Res3Month 	: BYTE; (* Bits 4..7 = Res3 (spare bits), Bits 0..3 = Month (1..12) *)
    Res4Year 	: BYTE; (* Bit 7 = Res4, Bits 0..6 = Year (0..99) *)
END_STRUCT
END_TYPE

Day of week (DOW): 1 = Monday, 7 = Sunday, 0 = not used;

SU: 1 = Summer time, 0 = normal time;

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


T_CP24IOA

TYPE T_CP24IOA

From product version: TwinCAT PLC Library IEC60870-5-104 substation v3.0.0 / IEC60870-5-104 controlling station v1.0.0 and higher.

Structured TwinCAT object address.

TYPE T_CP24IOA:
STRUCT
    ioMapType 	: E_IEC870_5_101IOMappingType := MAP_AREA_NONE;
    byteOffs 	: WORD := 0;
    bitOffs 		: BYTE(0..7) := 0;
END_STRUCT
END_TYPE

ioMapType: TwinCAT PLC process data area. This parameter defines the mapping for the TwinCAT PLC and IEC application object process data.

byteOffs: TwinCAT PLC process data byte offset. Value range: 0..65535.

bitOffs: TwinCAT PLC process data bit offset. Value range: 0..7.

Development Environment | Target System | PLC Libraries to include
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86, ARM) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically)


T_IEC870_5_101COTBits

TYPE T_IEC870_5_101COTBits

TYPE T_IEC870_5_101COTBits :  ARRAY[0..7] OF BYTE; (* Cause of transfer bit field (e.g. used in compatiblity list mask).*)
END_TYPE
Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


NVA

Normalized value.


S/E

Select/execute state.

  • <0> = Execute;
  • <1> = Select;


BSI

Bitstring of 32 bits.


SVA

Scaled value.


R32

Short floating point value.


TSC

Test command counter.


LPC

Local parameter change flag.

  • <0> = No change;
  • <1> = Changed;


BCR

Binary counter reading.


VTI

Value with transient state indication (8 bits).

Transient state (bit 7):

  • <0> = equipment is not in transient state;
  • <1> = equipment is in transient state;

Value (bits 0..6) = <-64..63>;


Other information elements

Quality descriptor

QDS

OV

Overflow quality flag:

  • <0> = no overflow;
  • <1> = overflow;

BL

Blocked quality flag:

  • <0> = not blocked;
  • <1> = blocked;

SB

Substituted quality flag:

  • <0> = not substituted;
  • <1> = substituted;

NT

Topical quality flag:

  • <0> = topical;
  • <1> = not topical;

IV

Invalid quality flag:

  • <0> = valid;
  • <1> = invalid;

CY

Carry flag:

  • <0> = no carry;
  • <1> = carry;

CA

Adjusted flag:

  • <0> = Counter was not adjusted;
  • <1> = Counter was adjusted;

EI

Elapsed flag:

  • <0> = Elapsed time valid;
  • <1> = Elapsed time not valid;


Group config flags

Group Configuration flags

The Application objects are assigned to groups with the Group-Flags. The Group-Flags for Station interrogation and Count transfer are defined as follows:

  • Station interrogation: All Application objects, which are assigned to the group 1 to 16, belog automatically to the global group: IEC870_GRP_INROGEN;
  • Count transfer: All Application objects, which are assigned to the group 1 to 4, belog automatically to the global group: IEC870_GRP_REQCOGEN;

You can prevent the automatical assignment of the application objects to the global group if you mask the according bits during the configuration

Examples:

IEC870_GRP_INRO3 AND NOT IEC870_GRP_INROGEN

or

IEC870_GRP_REQCO1 AND NOT IEC870_GRP_REQCOGEN

Constant | Value | Description
Station interrogation
IEC870_GRP_INROGEN | 16#00000001 | Interrogated by general interrogation (station or global)
IEC870_GRP_INRO1 | 16#00000003 | Interrogated by group 1 interrogation
IEC870_GRP_INRO2 | 16#00000005 | Interrogated by group 2 interrogation
IEC870_GRP_INRO3 | 16#00000009 | Interrogated by group 3 interrogation
IEC870_GRP_INRO4 | 16#00000011 | Interrogated by group 4 interrogation
IEC870_GRP_INRO5 | 16#00000021 | Interrogated by group 5 interrogation
IEC870_GRP_INRO6 | 16#00000041 | Interrogated by group 6 interrogation
IEC870_GRP_INRO7 | 16#00000081 | Interrogated by group 7 interrogation
IEC870_GRP_INRO8 | 16#00000101 | Interrogated by group 8 interrogation
IEC870_GRP_INRO9 | 16#00000201 | Interrogated by group 9 interrogation
IEC870_GRP_INRO10 | 16#00000401 | Interrogated by group 10 interrogation
IEC870_GRP_INRO11 | 16#00000801 | Interrogated by group 11 interrogation
IEC870_GRP_INRO12 | 16#00001001 | Interrogated by group 12 interrogation
IEC870_GRP_INRO13 | 16#00002001 | Interrogated by group 13 interrogation
IEC870_GRP_INRO14 | 16#00004001 | Interrogated by group 14 interrogation
IEC870_GRP_INRO15 | 16#00008001 | Interrogated by group 15 interrogation
IEC870_GRP_INRO16 | 16#00010001 | Interrogated by group 16 interrogation
Counter interrogation
IEC870_GRP_REQCOGEN | 16#00020000 | Interrogated by general counter request
IEC870_GRP_REQCO1 | 16#00060000 | Interrogated by group 1 counter request
IEC870_GRP_REQCO2 | 16#000A0000 | Interrogated by group 2 counter request
IEC870_GRP_REQCO3 | 16#00120000 | Interrogated by group 3 counter request
IEC870_GRP_REQCO4 | 16#00220000 | Interrogated by group 4 counter request
IEC870_GRP_LOCFREEZE | 16#00400000 | Enable cyclic local freeze of counter value
IEC870_GRP_LOCRESET | 16#00800000 | Enable cyclic local reset of counter value
Others
IEC870_GRP_IV_OFF | 16#01000000 | Don't set invalid quality bit
IEC870_GRP_REVERSE | 16#02000000 | Object used in reverse direction (reserved)
IEC870_GRP_SELECTCMD | 16#04000000 | Force select/execute for this point (reserved)
not defined | 16#08000000 | not used
IEC870_GRP_USERCMD | 16#10000000 | User command (reserved)
IEC870_GRP_BACKGROUND | 16#20000000 | Enable background scan for this point
IEC870_GRP_PERCYC | 16#40000000 | Enable periodic/cyclic data for this point
IEC870_GRP_SPONTOFF | 16#80000000 | Disable event (spontanous) scanning of this point

Development Enviroment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


Quality flags

Quality-Flags

Constant | Value | Description
IECQ_BL_ON | 16#0001 | Blocked
IECQ_BL_OFF | 16#0002 | Not blocked
IECQ_SB_ON | 16#0004 | Substituted
IECQ_SB_OFF | 16#0008 | Not substituted
IECQ_NT_ON | 16#0010 | Not topical
IECQ_NT_OFF | 16#0020 | Topical
IECQ_IV_ON | 16#0040 | Invalid
IECQ_IV_OFF | 16#0080 | Valid
IECQ_OV_ON | 16#0100 | Overflow
IECQ_OV_OFF | 16#0200 | Not overflow
IECQ_EI_ON | 16#0400 | Elapsed time invalid
IECQ_EI_OFF | 16#0800 | Elapsed time valid
IECQ_CY_ON | 16#1000 | Carry
IECQ_CY_OFF | 16#2000 | Not carry
IECQ_CA_ON | 16#4000 | Counter was adjusted
IECQ_CA_OFF | 16#8000 | Counter was not adjusted

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)


IEC60870-5-101 error codes

IEC 60870-5-10x error codes

Codes (hex) | Codes (dec) | Error source | Description
0x00008100-0x000081FF | 33024-33279 | IEC60870-5-10x Error codes | Internal IEC60870-5-10x error


Internal Fehlercodes

IEC 60870-5-10x error codes

Code (hex) | Code (dec) | Symbolic constant | Description
0x00008101 | 33025 | IEC870_COMMERR_INVALIDSTARTBYTE | Invalid frame start character <> 0x68
0x00008102 | 33026 | IEC870_COMMERR_RXBUFFOVERFLOW | Receive buffer overflow
0x00008103 | 33027 | IEC870_COMMERR_TXBUFFOVERFLOW | Send buffer overflow
0x00008104 | 33028 | IEC870_COMMERR_INVALIDUFFMT | Invalid U-Frame format, more than one function (STARTDT, STOPDT, TESTFR) activated
0x00008105 | 33029 | IEC870_COMMERR_INVALIDSFFMT | Invalid S-Frame format, invalid length parameter
0x00008106 | 33030 | IEC870_COMMERR_T1RESPONSE | t1 (response timeout) expired
0x00008107 | 33031 | IEC870_COMMERR_SENDSEQ | Send sequence error
0x00008108 | 33032 | IEC870_COMMERR_KOVERFLOW | k reached
0x00008109 | 33033 | IEC870_COMMERR_FATALERR | Fatal internal error
0x0000810A | 33034 | IEC870_COMMERR_INVALIDSTATE | Device is in invalid state (disconnected?)
0x0000810B | 33035 | IEC870_COMMERR_INVALIDSIZE | Invalid parameter size
0x0000810C | 33036 | IEC870_COMMERR_INVALIDVALUE | Invalid parameter value
0x0000810D | 33037 | IEC870_COMMERR_INVALIDTYPE | Invalid asdu (object) type
0x0000810F | 33039 | IEC870_COMMERR_TIMEOUT | Communication timeout
0x00008110 | 33040 | IEC870_COMMERR_LENGTH1 | Invalid length field value
0x00008111 | 33041 | IEC870_COMMERR_LENGTH2 | Length field and length field copy differs
0x00008112 | 33042 | IEC870_COMMERR_STARTCHAR2 | Invalid second stat character
0x00008113 | 33043 | IEC870_COMMERR_CHECKSUM | Invalid checksum
0x00008114 | 33044 | IEC870_COMMERR_ENDCHAR | Invalid end character
0x00008115 | 33045 | IEC870_COMMERR_LINKADDR | Invalid link address size
0x00008116 | 33046 | IEC870_COMMERR_SRVFUNCODE | Invalid link service function code
0x00008117 | 33047 | IEC870_COMMERR_FRAMETYPE | Invalid frame type
0x00008118 | 33048 | IEC870_COMMERR_UNSUPMODE | Unsupported comunication mode (balanced mode)
0x00008119 | 33049 | IEC870_COMMERR_T2KOVERFLOW | k reached and t2 (response timeout) expired
0x0000811A | 33050 | IEC870_COMMERR_INVALIDCONFIG | Invalid object configuration/initialization
0x0000811B | 33051 | IEC870_COMMERR_UNKNOWNTYPE | Unknown asdu type
0x0000811C | 33052 | IEC870_COMMERR_UNKNOWNCOT | Unknown cause of transfer
0x0000811D | 33053 | IEC870_COMMERR_UNKNOWNASDUADDR | Unknown asdu address
0x0000811E | 33054 | IEC870_COMMERR_UNKNOWNOBJADDR | Unknown object address
0x0000811F | 33055 | IEC870_COMMERR_NEGACTCON | Negative activation confirmation
0x00008120 | 33056 | IEC870_COMMERR_NEGACTTERM | Negative activation termination
0x00008121 | 33057 | IEC870_COMMERR_NEGDEACTCON | Negative deactivation confirmation
0x00008122 | 33058 | IEC870_COMMERR_BUSY | Allready in busy state
0x00008123 | 33059 | IEC870_COMMERR_AODBOVERFLOW | Application object database overflow
0x00008124 | 33060 | IEC870_COMMERR_AODBNOTFOUND | Application object not in database
0x00008125 | 33061 | IEC870_COMMERR_ACTCONTIMEOUT | Activation confirmation timeout error
0x00008126 | 33062 | IEC870_COMMERR_ACTTERMTIMEOUT | Activation termination timeout error
0x00008127 | 33063 | IEC870_COMMERR_DEACTCONTIMEOUT | Deactivation termination error
0x00008128 | 33064 | IEC870_COMMERR_SELEXECTIMEOUT | Command select/execute timeout error
0x00008129 | 33065 | IEC870_COMMERR_READRESTIMEOUT | Read command response timeout error
0x00008130 | 33072 | IEC870_COMMERR_LIBNOTCOMPAT | Product libraries are incompatible
0x00008131 | 33073 | IEC870_COMMERR_DIR | Invalid DIR bit value
0x00008132 | 33074 | IEC870_COMMERR_PRM | Invalid PRM bit value
0x00008133 | 33075 | IEC870_COMMERR_FCV | Invalid FCV bit value
0x00008134 | 33076 | IEC870_COMMERR_SCANTIMEOUT | Station scan cycle timeout error

Development Environment | Target System | PLC libraries to include
TwinCAT v2.9.0 Build >= 1030 | PC or CX (x86) | TcIEC870_5_101.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; are included automatically )
TwinCAT v2.10.0 Build >= 1301 | CX (ARM)