Download: Central station Tutorial (master, unbalanced mode)
A more complex central station application with different data points in both directions and a connection to the substation. The sample application uses the TwinCAT IEC 60870-5-101 high-level interface.
Download TwinCAT XAE Project (*.zip): TutorialSampleMaster101.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.
- Class 1 poll cycle: 100ms.
- Class 2 poll cycle: 100ms.
Data point configuration (it should be the same as the data point configuration of the substation):
- Single point information: M_SP_NA_1 (IOA := 100), M_SP_TA_1(IOA := 101), M_SP_TB_1(IOA := 102).
- Double point information: M_DP_NA_1 (IOA := 200), M_DP_TA_1 (IOA := 201), M_DP_TB_1 (IOA := 202).
- Regulating step value: M_ST_NA_1 (IOA := 300), M_ST_TA_1 (IOA := 301), M_ST_TB_1 (IOA := 302).
- Bitstring value: M_BO_NA_1 (IOA := 400), M_BO_TA_1 (IOA := 401), M_BO_TB_1 (IOA := 402).
- Measured value, normalized value: M_ME_NA_1 (IOA := 500), M_ME_TA_1 (IOA := 501), M_ME_TD_1 (IOA := 502).
- Measured value, scaled value: M_ME_NB_1 (IOA := 600), M_ME_TB_1 (IOA := 601), M_ME_TD_1 (IOA := 602).
- Measured value, short floating point value: M_ME_NC_1 (IOA := 700), M_ME_TC_1 (IOA := 701), M_ME_TF_1 (IOA := 702).
- Binary counter value: M_IT_NA_1 (IOA := 800), M_IT_TA_1 (IOA := 801), M_IT_TB_1 (IOA := 802).
- Single command: C_SC_NA_1 (IOA := 10), C_SC_NA_1 (IOA := 11), C_SC_TA_1 (IOA := 12).
- Double command: C_DC_NA_1 (IOA := 20), C_DC_NA_1 (IOA := 21), C_DC_TA_1 (IOA := 22).
- Bitstring command: C_BO_NA_1 (IOA := 40), C_BO_NA_1 (IOA := 41), C_BO_TA_1 (IOA := 42).
- Setpoint command, normalized value: C_SE_NA_1 (IOA := 50), C_SE_NA_1 (IOA := 51), C_SE_TA_1 (IOA := 52).
- Setpoint command, scaled value: C_SE_NB_1 (IOA := 60), C_SE_NB_1 (IOA := 61), C_SE_TB_1 (IOA := 62).
- Setpoint command, short floating point value: C_SE_NC_1 (IOA := 70), C_SE_NC_1 (IOA := 71), C_SE_TC_1 (IOA := 72).
Initialization sequence that is executed once/automatically after the connection is established:
- No test command (C_TS_NA_1, deactivated).
- Clock synchronization command (C_CS_NA_1).
- General interrogation command (C_IC_NA_1) of the group: General (eIEC870_QOI_INROGEN).
- No counter interrogation command (C_IC_NA_1) of the group: General (eIEC870_RQT_REQCOGEN, disabled). Counter interrogation Mode A (counters are stored locally in the substation and sent to the central station as spontaneous data).
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.
- No counter interrogation command (C_IC_NA_1) of the group: General (eIEC870_RQT_REQCOGEN, disabled). Counter interrogation Mode A (counters are stored locally in the substation and sent to the central station as spontaneous data).
- Simulation and transmission of the commands every 10 seconds if the variable bSendCmd was set to TRUE (see upper data point configuration).
- Reception of spontaneous data.
- Reception of M_EI_NA_1 (end of initialization).
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. |
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. |
memory | ST_MemoryData (STRUCT) | This structure contains constantly updated process data – either received or to be sent. |
fbHandler | FB_IEC870_5_101TableEventHandler (FB) | This function block informs the application when data point data has been changed or updated. |