Download: Substation Minimal (slave, unbalanced mode)
Simple substation application using the TwinCAT IEC 60870-5-101 high-level interface.
Download TwinCAT XAE Project (*.zip): MiniSlaveSample101.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).
- Single command: C_SC_NA_1 (IOA := 10).
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_CI_NA_1) of the group: General (eIEC870_RQT_REQCOGEN). Counter interrogation Mode C.
- Single command processing (C_SC_NA_1) (direct command execution)
- Sending spontaneous data of the type (M_SP_NA_1, IOA := 100) when the value of the bSPI variable changes.
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. |
bSPI | BOOL | The ON/OFF value to be sent is mapped directly from the flag address AT%MX1.5 of this allocated PLC variable. |
bSCS | BOOL | The received ON/OFF value is mapped into this PLC variable directly to the allocated flag address: AT%MX0.0. |
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 | STRUCT | In the initialization step, the individual data points of the station are configured once with this function call. |