F_iecAddTableEntry

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

 F_iecAddTableEntry 1:

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

Requirements

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 )