FB_IEC870_5_102TProtocol
The FB_IEC870_5_102TProtocol communication block implements the transport functions of the IEC 60870-5-1 and IEC 60870-5-2 link layer. 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 function block action. 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 actions:
- INIT (initialises the function block). In the default configuration the TX/RX data buffer are cleared. The bRetainBuffer member variable of the protPara structure controls the reset bahaviour of TX/RX data buffer.
Protocol configuration
The communication block has a structured protPara variable. Protocol parameters such as timeout times or connection addresses etc. can be configured via this variable.
VAR_IN_OUT
VAR_IN_OUT
hSerial : T_HSERIALCTRL; (* Serial link control handle *)
buffer : ST_IEC870_5_102TBuffer; (* TX/RX data buffer *)
END_VAR
hSerial: Connection handle to FB_IEC870_SerialLineCtrl function block. The data to be sent and received are exchanged with the FB_IEC870_SerialLineCtrl function block.
buffer: TX/RX data buffer.
VAR_INPUT
VAR_INPUT
protPara : ST_IEC870_5_101ProtocolParams; (* IEC60870-5-101/102 protocol parameters *)
bOutDbg : BOOL; (* Enable/disable debug output *)
END_VAR
protPara: IEC60870-5-101/102 protocol parameters.
bOutDbg:: Activates/deactivates the debug output of the frames in the TwinCAT System Manager logger view.
VAR_OUTPUT
VAR_OUTPUT
bError : BOOL;
nErrID : UDINT;
eDTState : E_IEC870_5_101SerialLinkState := eSERIALLINK_DISCONNECTED; (* 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.
eState: Status of the data exchange to the master.
Example:
Sample projects: IEC60870-5-102 Serial Link Interface
Requirements
Development Environment | Target System | PLC libraries to include |
---|---|---|
TwinCAT v2.10.0 Build >= 1319 | PC or CX (x86, ARM) | TcIEC870_5_102Link.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib; TcIEC870_5_101.Lib; TcIEC870_5_101Link.Lib; COMlibV2.Lib; are included automatically ) |