Control station (master)
Simple central station application that uses the TwinCAT IEC 60870-5-104 low-level interface. This sample application can only communicate with one substation.
Download TwinCAT XAE Project (*.zip): LowLevelMasterSample104.zip
In the sample project, the following station parameters are set for the central station:
- Server host address (IP address of the substation): 127.0.0.1 (You must at least adapt this parameter on your target platform!).
- Server port address (port address of the substation): 2404.
- k: 12.
- w: 8.
- t0: 30s.
- t1: 15s.
- t2: 10s.
- t3: 20s.
- Cause of transfer size: 2 octets (including originator address).
- Common ASDU address size: 2 octets.
- Information object address size: 3 octets.
- Originator address: 0.
- Common ASDU address: 7.
- Max. APDU length: 253.
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_NA_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_NA_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_TA_1) every 10 seconds.
- Clock synchronization command (C_CS_NA_1) every 20 seconds.
- General interrogation command (C_IC_NA_1) of the group: General (eIEC870_QOI_INROGEN) every 40 seconds.
- Counter interrogation command (C_IC_NA_1) of the group: General (eIEC870_RQT_REQCOGEN) every 60 seconds. Counter interrogation Mode A.
- Simulation and transmission of the commands every 60 seconds if the variable bSimulate 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 |
---|---|---|
MAIN | PRG | This program part implements the telecontrol protocol |
fbClient | FB_IEC870_5_104M (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. |
fbServices | FB_IEC870_5_104MServices ( FB) | Includes a simple implementation of some services such as general interrogation, clock synchronization, test commands, etc. |
stProcPara | ST_IEC870_5_104MProcData (STRUCT) | Here you can found constantly updated process data – either received or to be sent. |
sysPara | ST_IEC870_5_104MSysPara (STRUCT) | Configuration of the system parameters of the central station and the implemented services. |
fbLog | FB_IEC870_DebugLogFifo (FB) | A simple log buffer for debugging/troubleshooting purposes. |