Diagnosing Nodes on Profibus DP Bus in Siemens S7-300 PLC Programming

In Siemens automation systems, the use of the Profibus DP bus is very widespread. It is essential to diagnose running bus devices and detect faults during usage. Today, I will summarize these issues briefly, hoping that everyone can complete the diagnosis and monitoring of the DP bus after learning.When applying PROFIBUS-DP and SIMATIC S7 for diagnostic evaluation of remote configuration, user programs can utilize two different S7 function blocks.

If detailed information about errors and faults on the bus nodes is needed in addition to the diagnostic overview, please use the function block FB125.

The function block FC125 is a simplified version that only provides information about “which bus nodes have faults or errors” (diagnostic overview). This function block cannot display detailed information.

1 Application Areas of FB125 and FC125

FB125 and FC125 can be used with the following integrated DP interfaces and external DP interfaces:

CPU 313C-2 DP

CPU 314C-2 DP

CPU 315-2 DP (from 6ES7 315-2AF02-0AB0 onwards)

CPU 315-2 DP (only applicable for 6ES7 315-2AF01-0AB0):

FC125 cannot be used

FB125 cannot detect faulty slaves via Start/RESET

CPU 316-2 DP

CPU 318-2 DP

C7-626 DP (from 6ES7 626-2AG01-0AE3 onwards)

C7-633 DP and C7-634 DP

SINUMERIK 840D with integrated CPU315-2 DP (6ES7 315-2AF01-0AB0):

FC125 cannot be used

FB125 cannot detect faulty slaves via Start/RESET

SINUMERIK 840DI, with integrated CPU315-2 DP (6ES7 315-2AF03-0AB0)

CPU 41x-2/3/4 DP

CP 443-5

IM 467 and IM 467 FO

WIN AC

WIN LC

Not applicable for CP 342-5

2 Hardware Configuration Example

The following hardware configuration serves as an example to illustrate how to invoke FC125【FC_Siemens_DP_Diag】to complete the diagnosis of the Profibus bus.

Diagnosing Nodes on Profibus DP Bus in Siemens S7-300 PLC Programming

3 Introduction to FC125 “FC_Siemens_DP_Diag” Interface

Diagnosing Nodes on Profibus DP Bus in Siemens S7-300 PLC Programming

Parameter description:

CHECK_ACTIVE :

When set to 1, start detecting slaves.

EXTERNAL_DP_INTERFACE :

Select the DP master interface, 0 indicates the integrated DP master on the CPU, 1 indicates an external DP master interface, such as CP443-5.

DP_MASTERSYSTEM :

The ID number of the PROFIBUS, which can be viewed in the hardware configuration. If there are multiple PROFIBUS networks, FC125 needs to be invoked multiple times, assigning their PROFIBUS ID numbers, data type is INT.

DATA_FIELD :

A 50-byte data area, for internal use within FC125, data type is POINTER.

SUM_SLAVES_DIAG :

The total number of slave diagnostics, data type is INT.

LIST_SLAVES_NOT_PRESENT:

Detects missing slaves (software configured but hardware not connected), a 16-byte data area, each bit corresponds to a slave, setting to 1 indicates a slave is missing; if the missing slave returns or is repaired, the corresponding bit resets. Data type is POINTER.

LIST_SLAVES_ERROR :

Faulty slaves (some modules are faulty, while others can continue running), a 16-byte data area, each bit corresponds to a slave, setting to 1 indicates a slave is faulty; if the faulty slave returns or is repaired, the corresponding bit resets. Data type is POINTER.

RETVAL :

The status return value when invoking FC125, data type is INT.

BUSY :

When set to 1, indicates currently executing.

4 Create DB125 Data Block to Save FC125 Runtime Data, Already Established. As Follows:

Diagnosing Nodes on Profibus DP Bus in Siemens S7-300 PLC Programming

5 Insert FC125 into OB1 and Assign Interface Parameters as Shown Below.【Note: When CHECK_ACTIVE, m0.0=1, the diagnostic function is enabled】

Diagnosing Nodes on Profibus DP Bus in Siemens S7-300 PLC Programming

6 How to Read Diagnostic Information?

Diagnosing Nodes on Profibus DP Bus in Siemens S7-300 PLC Programming

Diagnosing Nodes on Profibus DP Bus in Siemens S7-300 PLC Programming

After processing the above program, two data areas LIST_SLAVES_NOT_PRESENT and LIST_SLAVES_ERROR can be obtained. Each of these parameters has 16 bytes of data. Each bit of these 16 bytes represents a DP slave device. It can represent 16×8=128 sites.

If a bit is set to 1, it indicates that the slave represented by that bit is missing or faulty; once the slave fault disappears, that bit will automatically reset to 0. For DP network 1, it has 4 slaves, whose diagnostic bits are in “GLOBAL_DIAG_DB”.DP_SLAVE1.LIST_SLAVES_NOT_PRESENT

or “GLOBAL_DIAG_DB”.DP_SLAVE1.LIST_SLAVES_ERROR data area bits 1-4, while for DP network 2, which has 3 slaves,

the diagnostic bits are in “GLOBAL_DIAG_DB”.DP_SLAVE2.LIST_SLAVES_NOT_PRESENT

or “GLOBAL_DIAG_DB”.DP_SLAVE2.LIST_SLAVES_ERROR data area bits 1-3.

The next question is how to extract the diagnostic bit information corresponding to the slaves from the diagnostic dataset.

There are many methods, the most direct method is to directly find the absolute address of these bits in the DB, for instance, the absolute address of the second slave’s missing diagnostic bit in DP network 1 is: DB100.DBX52.1, and the absolute address of the fault diagnostic bit is: DB100.DBX68.1.

This method is simple and direct, but not conducive to program portability.An indirect method is to right shift the diagnostic bits in the diagnostic dataset to the rightmost end of the double word, that is, the lowest bit of the double word, and then perform an XOR operation with the constant DW#16#1; if the result = 1, then the moved diagnostic bit indicates that the corresponding slave has a loss or fault.

The specific method used to obtain the exact information of the diagnostic bits depends on the habits of the specific programmer. Importantly, once the diagnostic bit information of the slaves is obtained, how to utilize the diagnostic bits to control the process.

Source: WeChat public account Network Industrial Control Guest World

Qicheng Intelligent

About Us:Qicheng Automation Training, China’s leading industrial robot training service provider

Contact Number: 13809869603

Training Projects:Robots, PLC System Integration, Machine Vision

Special Services:3000 square meters training center + recommended employment + industry-leading curriculum

Address:Shenzhen Bao’an District Shajing Huiju 107 Chuangzhi Park

Diagnosing Nodes on Profibus DP Bus in Siemens S7-300 PLC Programming

+ Teacher WeChat, learn more about course details

Leave a Comment