Download: Substation tutorial (slave, unbalanced mode)
A more complex substation application with different data points in both directions and a connection to the central station. The sample application uses the TwinCAT IEC 60870-5-101 high-level interface.
Download TwinCAT XAE Project (*.zip): TutorialSampleSlave101.zip
In the sample project, the following station parameters are set for the substation:
- 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 central station):
- 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).
Sample implementation of the following services:
- End of initialization (M_EI_NA_1) is sent once.
- 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_IC_NA_1) of the group: General (eIEC870_RQT_REQCOGEN, Mode A). Counters are stored locally in the substation every 15 seconds and transmitted as spontaneous data to the central station.
- Command execution of some commands (direct commands, see upper data point configuration).
- Simulation and transmission of spontaneous data every 10 seconds if the variable bSendSpont was set to TRUE (see upper data point configuration).
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). |
fbServer | FB_IEC870_5_101Slave (FB) | Implements the substation. An instance of this function block can only communicate with one central station. For each additional central station 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. |
F_iecInitAOEntry | 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. |
F_iecSetAOQuality | FUNCTION | This function demonstrates how the quality flags of M_SP_NA_1(IOA := 100) can be set/reset. |
F_iecGetAOQuality | FUNCTION | This function demonstrates how the quality flags of M_SP_NA_1(IOA := 100) can be queried. |