FB_IEC870_5_102TProtocol
The communication block FB_IEC870_5_102TProtocol implements the transfer procedures of the link layer according to the IEC 60870-5-1 and IEC 60870-5-2 standards.
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 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). In the default configuration, the TX/RX data buffers are reset. Clearing of the buffers can be prevented by setting the bRetainBuffer variables in the protocol parameter structure.
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;
buffer : ST_IEC870_5_102TBuffer;
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;
bOutDbg : BOOL;
END_VAR
protPara: IEC 60870-5-101/102 protocol parameters.
bOutDbg:: Activates/deactivates the debugging output of the frames in the TwinCAT XAE->"Error List" window.
VAR_OUTPUT
VAR_OUTPUT
bError : BOOL;
nErrID : UDINT;
eState : E_IEC870_5_101SerialLinkState := eSERIALLINK_DISCONNECTED;
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.
eState: Connection status to the communication partner.
Example (Low-Level interface): IEC 60870-5-102 central station (master);
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) |