FB_IEC870_5_104TProtocol
From product version TwinCAT PLC Library IEC870-5-104 Substation v2.0.6 and higher.
The FB_IEC870_5_104TProtocol communication block implements the ACPI functions of the IEC60870-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 (initialises 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_IN_OUT
VAR_IN_OUT
buffer : ST_IEC870_5_101TBuffer; (* TX/RX data buffer *)
END_VAR
buffer: TX/RX data buffer.
VAR_INPUT
VAR_INPUT
sSrvNetID : T_AmsNetID; (* TwinCAT TCP/IP Connection Server netID *)
hSocket : T_HSOCKET; (* TCP/IP socket connection handle *)
protPara : ST_IEC870_5_104ProtocolParams; (* IEC60870-5-104 protocol parameters *)
bOutDbg : BOOL; (* Enable/disable debug output *)
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: IEC60870-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; (* Data transfer state *)
ND_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 IEC60870-5-104 data exchange (STARTDT, STOPDT)
Example:
Sample projects: IEC60870-5-104 Transport Interface
Requirements
Development environment | Target system type | PLC libraries to be linked |
---|---|---|
TwinCAT v2.10.0 Build >= 1301 | PC or CX (x86) | TcIEC870_5_104.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; TcIEC870_5_101.Lib are included automatically ) |