Download: Central station Minimal (master, unbalanced mode)
Simple central station application that uses the TwinCAT IEC 60870-5-101 high-level interface.
Download TwinCAT XAE Project (*.zip): MiniMasterSample101.zip
In the sample project, the following station parameters are set for the central station:
- Standard PC interface: COM1.
- Baud rate: 19200 baud.
- Link address: 220.
- Link address size: 2 octets.
- Cause of transfer size: 2 octets (including originator address).
- Originator address: 1.
- Common ASDU address: 7.
- Common ASDU address size: 2 octets.
- Information object address size: 3 octets.
- Link mode: Unbalanced.
Data point configuration (it should be the same as the data point configuration of the substations):
- Single point information: M_SP_NA_1 (IOA := 100).
- Single command: C_SC_NA_1 (IOA := 10).
Initialization sequence that is executed once/automatically after the connection is established:
- Test command (C_TS_NA_1).
- Clock synchronization command (C_CS_NA_1).
- General interrogation command (C_IC_NA_1) of the group: General (eIEC870_QOI_INROGEN).
- Counter interrogation command (C_CI_NA_1) of the group: General (eIEC870_RQT_REQCOGEN). Counter interrogation Mode C
Sample implementation of the following services:
- Test command (C_TS_NA_1) every 60 seconds.
- Clock synchronization command (C_CS_NA_1) every 60 seconds.
- General interrogation command (C_IC_NA_1) of the group: General (eIEC870_QOI_INROGEN) every 60 seconds.
- Counter interrogation command (C_CI_NA_1) of the group: General (eIEC870_RQT_REQCOGEN) every 60 seconds. Counter interrogation Mode C.
- If the value of the bSCS variable changes, the single command (C_SC_NA_1) is sent (direct command execution)
- When spontaneous data of type (M_SP_NA_1, IOA := 100) is received, the ON/OFF value is mapped to the PLC variable bSPI.
The following table briefly describes the main components of the project:
Component | Type | Description |
---|---|---|
P_MAIN_LowSpeed | PRG | This program part implements the telecontrol protocol (slow task). |
P_SerialComm_HighSpeed | PRG | This program part implements TwinCAT background communication via the serial interfaces of the PC (fast task). |
fbClient | FB_IEC870_5_101Master (FB) | Implements the central station. An instance of this function block can only communicate with one substation. For each additional substation to communicate with, another instance of this function block is required. |
bSPI | BOOL | The received ON/OFF value is mapped into this PLC variable directly to the allocated flag address: AT%MX0.0. |
bSCS | BOOL | The ON/OFF value to be sent is mapped directly from the flag address AT%MX1.5 of this allocated PLC variable. |
AODB | ARRAY of ST_IEC870_5_101AODBEntry (STRUCT) | Application object database. It's an array variable. An array element is required for each data point. |
hTable | T_HAODBTable (STRUCT) | Application object database handle. These variables are used to access the application object database and never directly the individual array elements. |
F_iecCreateTableHnd | FUNCTION | In the initialization step, all array elements of AODB are initialized once with this function call. If successful, this function call returns the handle. |
F_iecAddTableEntry | FUNCTION | In the initialization step, the individual data points of the station are configured once with this function call. |