ST_IEC870_5_104ProtocolParams

TYPE ST_IEC870_5_104ProtocolParams :
STRUCT
    t0              : TIME := T#30s; (* MASTER only: Connection establishment *)
    t1              : TIME := T#15s; (* Response Timeout (STARTDTAct, STOPDTAct, TESTFRAct only ) *)
    t2              : TIME := T#10s; (* Send ACK in case of no data frames *)
    t3              : TIME := T#20s; (* Time for sending test frames *)
    iK              : INT := 12; (* Max. difference RSN to send ACK *)
    iW              : INT := 8; (* Latest ACK after receiving I-frames *)

    bSFrameACK      : BOOL := TRUE; (* Send S-Frame ACK *)
    bTESTFRAct      : BOOL := TRUE; (* Send TESTFR *)
    bDTControlled   : BOOL := TRUE; (* STARTDT, STOPDT controlled (wait for STARTDT, STOPDT) *)
    bControlDT      : BOOL := FALSE; (* Send START, STOPDT frames *)

    bSTARTDTCon     : BOOL := TRUE; (* Send STARTDT confirmations *)
    bSTOPDTCon      : BOOL := TRUE; (* Send STOPDT confirmations *)
    bTESTFRCon      : BOOL := TRUE; (* Send TESTFR confirmations *)

    eAcceptMode     : E_SocketAcceptMode := eACCEPT_ALL; (* Connection accept flags *)
    sRemoteHost     : STRING(15) := ''; (* Remote (server) address. String containing an (Ipv4) Internet Protocol dotted address. *)
    nRemotePort     : UDINT := 0; (* Remote (server) Internet Protocol (IP) port. *)

    APDULength      : BYTE(MIN_IEC870_5_104_APDULEN..MAX_IEC870_5_104_APDULEN) := MAX_IEC870_5_104_APDULEN;(* Defaults:
               Max. length of APDU = 255 bytes - 1 start octet - 1 length octet = 253 octets,
                Max. length of ASDU = 253 - 4 control octets = 249 octets*)
    bThrottleMode   : BOOL := FALSE; (* If set reduces the number of polling socket read requests *)
    bPackFrames     : BOOL := FALSE; (* Binds more than one APDU frames to one big TCP/IP frame *)
    bRetainBuffer   : BOOL := FALSE; (* TRUE => Don't reset the tx/rx buffer in offline mode, FALSE => reset tx/rx buffer in offline mode *)

    bCOTFilter      : BOOL := TRUE; (* Only used if bRetainBuffer = TRUE. If TRUE = filter asdu by COT and session ID, FALSE = don't filter the asdu's *)
    cotFilter       : T_IEC870_5_101COTBits := 2#10001111, 7(16#FF);(* COT (cause of transfer) filter, default: eIEC870_COT_CYCLIC or eIEC870_COT_BACKGROUND or eIEC870_COT_SPONTAN *)
END_STRUCT
END_TYPE

t0 : Not used, reserved.

t1 : Max. Timeout time for an answer to a STARTDTAct-, STOPDTAct- or TESTFRAct-Frame.

t2 : Latest time to send a S- Frame.

t3 : Latest time to send a Test- Frame.

iK : Latest after these sent  APDU's in I-Format, without acknowledgement, the connection is to be closed.

iW : Latest acknowledgement after receiving of  APDU's in I-Format.

bSFrameACK : Send S- Frame.

bTESTFRAct : Send Test-Frames.

bDTControlled : Wait for STARTDT-, STOPDT-Frame from master.

bControlDT : Not used, reserved.

bSTARTDTCon : Send STARTDT confirmation.

bSTOPDTCon : Send STOPDT confirmation.

bTESTFRCon : Send TESTFR confirmation.

eAcceptMode : Defines if connections to all Remote Clients, or only to clients with specified Host and Port address are allowed. Default: accept all arriving connections.

sRemoteHost : Host address of Remote-Client. If eAcceptMode = eACCEPT_ALL this parameter will be ignored.

nRemotePort : Port address of Remote-Client. If eAcceptMode = eACCEPT_ALL this parameter will be ignored.

APDULength : Max. length of APDU.

bThrottleMode: Implemented from IEC870-5-104 slave library v2.0.0 and higher. The TCP/IP sockets are polled by the PLC. This parameter reduces the number of polled read accesses and so the system load. This makes sense for infrequent data receiving ( e.g. General query or  time synchronisation query). 

bPackFrames: Implemented from IEC870-5-104 slave library v2.0.4 and higher. By default a TCP/IP send call only sends a single APDU. The send performance can be increased substantially (thereby reducing send buffer overflows) by setting this parameter to TRUE.

bRetainBuffer: Implemented from IEC870-5-104 slave library  v3.0.14 and higher. In the standard setting (FALSE) the internal Tc/Rx buffers are deleted when the connection is severed. If this flag is set to TRUE, the ASDUs in the internal send buffer that have not yet been sent are not deleted. Hence, offline buffering of approx. 100-200 measured values (dependent on the ASDU size) in the RAM memory is possible. The station then always removes the ASDUs from the send buffer once their receipt has been confirmed. Please note that the ASDUs that have already been sent but not yet confirmed also remain in the buffer and are sent again the next time. The other station may then receive the values twice. You can configure this behaviour via two further parameters: bCOTFilter and cotFilter.

 

bCOTFilter: Implemented from IEC870-5-104 slave library  v3.0.14 and higher. Activates/deactivates the filter mask with the causes of transfer. This parameter is only valid when the bRetainBuffer parameter is also set to TRUE. A SessionID is incremented internally with each establishment of a new connection. This SessionID is always attached to the received and sent ASDUs. Hence, the ASDUs that have not yet been sent and remain in the offline buffer are assigned to the old connection. These ASDUs can then be filtered and discarded with the aid of the COT mask (cotFilter) (COT = Cause Of Transfer). This is sometimes necessary if the other communication partner does not accept the repeated ASDUs.

 

cotFilter: Implemented from IEC870-5-104 slave library  v3.0.14 and higher. Filter mask with causes of transfer (COT = Cause Of Transfer). This parameter is only valid when the bRetainBuffer and bCOTFilter parameters have also been set. The cause of transfer of the ASDUs to be sent is only checked if their SessionID does not correlate to the current SessionID (i.e. the ASDUs originating from the previous connection). Each bit corresponds to a cause of transfer. The cause of transfer is only checked if the appropriate bit has been set.

The causes of transfer are coded in the following way in the bits:

cotFilter[0].7 = eIEC870_COT_UNUSED
cotFilter[0].6 = eIEC870_COT_CYCLIC
cotFilter[0].5 = eIEC870_COT_BACKGROUND
cotFilter[0].4 = eIEC870_COT_SPONTAN
cotFilter[0].3 = eIEC870_COT_INIT
cotFilter[0].2 = eIEC870_COT_REQ
cotFilter[0].1 = eIEC870_COT_ACT
cotFilter[0].0 = eIEC870_COT_ACT_CON
cotFilter[1].7 = eIEC870_COT_DEACT
cotFilter[1].6 = eIEC870_COT_DEACT_CON
cotFilter[1].5 = eIEC870_COT_ACT_TERM

... and so on.
 

Requirements

Development Environment

Target System

PLC libraries to include

TwinCAT v2.9.0 Build >= 1030

PC or CX (x86)

TcIEC870_5_104.Lib

( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcpIp.Lib; TcUtilities.Lib; TcSocketHelper.Lib; TcIEC870_5_101.Lib  are included automatically)

TwinCAT v2.10.0 Build >= 1301

CX (ARM)