FB_IEC870_5_104TProtocol
The communication block FB_IEC870_5_104TProtocol implements the ACPI functions of the IEC 60870-5-104 standard (start/stop data transfer, test frames, send/receive frame counter etc.). In the event of a protocol error an associated error code is issued at the function block output and the data transfer is interrupted. The data exchange can be reactivated by calling the INIT task. The frame counters and the send and TX/RX data buffers are reset. The communication block expects a TX/RX data buffer variable. This variable must be transferred to the block via VAR_IN_OUT.
The function block features the following tasks:
- INIT (initializes the function block);
- STARTDT (sends a start data transfer frame to the communication partner);
- STOPDT (sends a stop data transfer frame to the communication partner);
Establishing the connection
The TCP/IP connection has to be established and closed via a separate block, e.g. FB_ServerClientConnection. The PLC application can respond independently to possible protocol errors and close the connection or implement the process reset service, for example. At the output this block provides a connection handle, the connection status and information about errors that have occurred during establishment/closing of the connection.
The connection handle is required by the communication block.
Protocol configuration
The communication block has a structured protPara variable. Protocol parameters such as iK, iW, start/stop data transfer behaviour etc. can be configured via this variable.
VAR_INPUT
VAR_INPUT
sSrvNetID : T_AmsNetID;
hSocket : T_HSOCKET;
protPara : ST_IEC870_5_104ProtocolParams;
bOutDbg : BOOL;
END_VAR
sSrvNetID: String containing the network address of the TwinCAT TCP/IP Connection Server. For the local computer (default) an empty string may be specified.
hSocket: TCP/IP connection handle of the communication partner for receiving or sending data.
protPara: IEC 60870-5-104 protocol parameters.
bOutDbg:: Activates/deactivates the debug output of the TCP/IP frames in the TwinCAT System Manager logger view.
VAR_OUTPUT
VAR_OUTPUT
bError : BOOL;
nErrID : UDINT;
eDTState : E_IEC870_5_104DataTransferState := eIEC870_STOPDT;
END_VAR
bError: This output is switched to TRUE if an error occurs during data transfer.
nErrID: Returns an error code if the bError output is set;
eDTState: Status of the IEC 60870-5-104 data exchange (STARTDT, STOPDT).
Examples:
Requirements
Development environment |
Target system type |
PLC libraries to be linked (category group) |
---|---|---|
TwinCAT v3.1.4012.0 |
PC oder CX (x86, x64, ARM) |
Tc2_IEC60870_5_10x (Communication->IEC60870) |