Download: Substation (slave, balanced mode)
Simple substation application using the TwinCAT IEC 60870-5-101 low-level interface. This sample application can communicate with a central station via an RS232 interface.
Download TwinCAT XAE Project (*.zip): LowLevelSlaveSampleBal101.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: 1 octet.
- Cause of transfer size: 1 octet.
- Originator address: 0 (not used).
- Common ASDU address: 7.
- Common ASDU address size: 1 octet.
- Information object address size: 2 octets.
- Link mode: Balanced.
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)
- Regulating step value: M_ST_NA_1 (IOA := 300)
- Bitstring value: M_BO_NA_1 (IOA := 400)
- Measured value, normalized value: M_ME_NA_1 (IOA := 500)
- Measured value, scaled value: M_ME_NB_1 (IOA := 600)
- Measured value, short floating point value: M_ME_NC_1 (IOA := 700)
- 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)
- Double command: C_DC_NA_1 (IOA := 20)
- Regulating step command: C_RC_NA_1 (IOA := 30)
- Bitstring command: C_BO_NA_1 (IOA := 40)
- Setpoint command, normalized value: C_SE_NA_1 (IOA := 50)
- Setpoint command, scaled value: C_SE_NB_1 (IOA := 60)
- Setpoint command, short floating point value: C_SE_NC_1 (IOA := 70)
Sample implementation of the following services:
- 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. The counter values are frozen locally every 60 seconds.
- Command execution of some commands (see upper data point configuration).
- End of initialization (M_EI_NA_1) is sent once to the central station (after the connection has been established).
- Cyclic data transfer every 60 seconds.
- Simulation and transfer of spontaneous data every 60 seconds if the variable bSimulate is set to TRUE.
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_101S (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. |
fbServices | FB_IEC870_5_101SServices ( FB) | Includes a simple implementation of some services such as general interrogation, clock synchronization, test commands, etc. |
stProcData | ST_IEC870_5_101SProcData (STRUCT) | Here you can found constantly updated process data – either received or to be sent. |
sysPara | ST_IEC870_5_101SSysPara (STRUCT) | Configuration of the system parameters of the substation and the implemented services. |
fbLog | FB_IEC870_DebugLogFifo (FB) | A simple log buffer for debugging/troubleshooting purposes. |