0% found this document useful (0 votes)
576 views49 pages

User Defined Diagnostics DOC V34 en

Diagnostics in the User Program with S7-1500

Uploaded by

albatrus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
576 views49 pages

User Defined Diagnostics DOC V34 en

Diagnostics in the User Program with S7-1500

Uploaded by

albatrus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

Diagnostics in the

User Program with


S7-1500
Siemens
TIA Portal, S7-1500 Industry
Online
https://support.industry.siemens.com/cs/ww/en/view/98210758 Support
Warranty and Liability

Warranty and Liability

Note The Application Examples are not binding and do not claim to be complete
regarding the circuits shown, equipping and any eventuality. The Application
Examples do not represent customer-specific solutions. They are only intended
to provide support for typical applications. You are responsible for ensuring that
the described products are used correctly. These Application Examples do not
relieve you of the responsibility to use safe practices in application, installation,
operation and maintenance. When using these Application Examples, you
recognize that we cannot be made liable for any damage/claims beyond the
liability clause described. We reserve the right to make changes to these
Application Examples at any time without prior notice.
If there are any deviations between the recommendations provided in these
Application Examples and other Siemens publications – e.g. Catalogs – the
contents of the other documents have priority.

We do not accept any liability for the information contained in this document.
Any claims against us – based on whatever legal reason – resulting from the use of
the examples, information, programs, engineering and performance data etc.,
described in this Application Example shall be excluded. Such an exclusion shall
not apply in the case of mandatory liability, e.g. under the German Product Liability
Act (“Produkthaftungsgesetz”), in case of intent, gross negligence, or injury of life,
body or health, guarantee for the quality of a product, fraudulent concealment of a
© Siemens AG 2019 All rights reserved

deficiency or breach of a condition which goes to the root of the contract


(“wesentliche Vertragspflichten”). The damages for a breach of a substantial
contractual obligation are, however, limited to the foreseeable damage, typical for
the type of contract, except in the event of intent or gross negligence or injury to
life, body or health. The above provisions do not imply a change of the burden of
proof to your detriment.
Any form of duplication or distribution of these Application Examples or excerpts
hereof is prohibited without the expressed consent of the Siemens AG.

Security Siemens provides products and solutions with industrial security functions that
informa- support the secure operation of plants, systems, machines and networks.
tion In order to protect plants, systems, machines and networks against cyber
threats, it is necessary to implement – and continuously maintain – a holistic,
state-of-the-art industrial security concept. Siemens’ products and solutions only
form one element of such a concept.
Customer is responsible to prevent unauthorized access to its plants, systems,
machines and networks. Systems, machines and components should only be
connected to the enterprise network or the internet if and to the extent necessary
and with appropriate security measures (e.g. use of firewalls and network
segmentation) in place.
Additionally, Siemens’ guidance on appropriate security measures should be
taken into account. For more information about industrial security, please visit
http://www.siemens.com/industrialsecurity.
Siemens’ products and solutions undergo continuous development to make them
more secure. Siemens strongly recommends to apply product updates as soon
as available and to always use the latest product versions. Use of product
versions that are no longer supported, and failure to apply latest updates may
increase customer’s exposure to cyber threats.
To stay informed about product updates, subscribe to the Siemens Industrial
Security RSS Feed under http://www.siemens.com/industrialsecurity.

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 2
Table of Contents

Table of Contents
Warranty and Liability ................................................................................................. 2
1 Introduction ........................................................................................................ 4
1.1 Overview............................................................................................... 4
1.2 Components used ................................................................................ 6
2 Test Project Engineering .................................................................................. 8
2.1 Hardware configuration of the test project ........................................... 8
2.2 Configuring the diagnostic settings ...................................................... 9
2.3 IP addresses, PROFIBUS addresses and device names .................... 9
2.4 Setting the PROFIBUS DP address ..................................................... 9
2.5 Assigning the PROFINET device names ........................................... 10
2.6 Integration into the user project .......................................................... 12
2.6.1 Integrating PLC objects ...................................................................... 12
2.6.2 Integrating HMI objects (TP 1200) ..................................................... 16
2.6.3 Integrating HMI objects (PC station) .................................................. 19
2.7 Operation ............................................................................................ 22
2.7.1 Overview............................................................................................. 22
2.7.2 Devices and module icon legend ....................................................... 24
2.7.3 Diagnostics on the operator panel ..................................................... 25
2.7.4 Evaluating the diagnostic information ................................................ 28
3 Valuable Information ....................................................................................... 29
© Siemens AG 2019 All rights reserved

3.1 Basics of system diagnostics for S7-1500 PLCs ............................... 29


3.2 Diagnostic instructions ....................................................................... 29
3.3 Details about how the program blocks work ...................................... 30
3.3.1 Complete overview ............................................................................. 30
3.3.2 “UserDiag_Constants” tag table ......................................................... 31
3.3.3 “UserDiag_DiagnosticsData” DB ........................................................ 31
3.3.4 “UserDiag_HmiData” DB .................................................................... 34
3.3.5 “UserDiag_PLCCheck” FB ................................................................. 36
3.3.6 “UserDiag_IOSystemCheck” FB ........................................................ 39
3.3.7 "UserDiag_Diagnostics" FB ................................................................ 42
3.3.8 FB "UserDiag_GetIPAddress" ............................................................ 44
3.3.9 “UserDiag_DiagnosticsHmi” FB ......................................................... 45
3.3.10 "UserDiag_Main" FB .......................................................................... 47
4 Appendix .......................................................................................................... 48
4.1 Service and Support ........................................................................... 48
4.2 Links and literature ............................................................................. 49
4.3 Change documentation ...................................................................... 49

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 3
1 Introduction

1 Introduction
In the SIMATIC environment, diagnostics of devices and modules are grouped
under the term ‘system diagnostics’. The monitoring functions are automatically
derived from the hardware configuration.
All SIMATIC products have integrated diagnostic functions that allow you to detect
and clear faults. The components automatically report a fault during operation and
provide additional detailed information. Plant-wide diagnostics can minimize
unscheduled downtimes.
Diagnostics with the user program enables you to identify faulty devices and
modules. This allows you to program responses to diagnostic alarms in the user
program.

Note If diagnostic information is only displayed on different visual display devices and
not used in the user program, it is recommended to use the S7-1500 controllers’
integrated system diagnostics. For more information about integrated system
diagnostics, please refer to the following application example:
“System Diagnostics with S7-1500 and TIA Portal”
https://support.industry.siemens.com/cs/ww/en/view/68011497

1.1 Overview
© Siemens AG 2019 All rights reserved

This application example describes how to monitor a PROFINET IO system and a


PROFIBUS DP master system with different devices in the user program. The
devices are connected to an S7-1500 controller via PROFINET IO /
PROFIBUS DP. The devices detect faults on their modules and send the
diagnostic data to the assigned controller. The controller evaluates this diagnostic
information with the diagnostic instructions in the user program and saves it to a
global data block. The operator panel graphically displays the evaluated diagnostic
information in one view per IO system or in a device view.
It considers the following states:
• State OK
• State FAULTY
• State LOST CONNECTION
• State DEACTIVATED
• State PROBLEM / MAINTENANCE
• State WAS FAULTY
• State HAD LOST CONNECTION
• State WAS DEACTIVATED
• State WAS PROBLEM / MAINTENANCE

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 4
1 Introduction

The following figure shows the hardware that was used for testing.

Figure 1-1: Hardware overview

STEP 7 S7-1500 TP1200


Diagnostic
information

PROFINET IE
Fault Fault Fault Fault

ET 200SP PN ET 200MP PN ET 200SP PN G 120


PROFIBUS DP
Fault
© Siemens AG 2019 All rights reserved

ET 200SP DP

Note This application example influences the cycle time of your program. The cycle
time extension size depends on the plant configuration to be monitored and the
CPU used. Therefore, no approximate values can be given at this point.

You can copy the PLC objects of the application example directly to your project.
All you have to do is customize the constants to define the size of the diagnostic
structure (highest device number or slave address in the IO system). In addition,
customize the hardware ID of your CPU and IO system.

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 5
1 Introduction

1.2 Components used


This application example was created with the following hardware and software
components:
Table 1-1: Hardware and software components
Component No. Article no. Note
CPU 1516-3 PN/DP 1 6ES7516-3AN01-0AB0 Alternatively, any other
S7-1500 CPU can be
used.
Memory card, 1 6ES7954-8LE02-0AA0 -
12 Mbytes
Digital input module, 1 6ES7521-1BL00-0AB0 Configurable diagnostics
DI 32x24VDC HF
Front connector, screw- 2 6ES7592-1AM00-0XB0 -
type, 40-pin
Digital output module, 1 6ES7522-1BL00-0AB0 Configurable diagnostics
DQ 32x24VDC/0.5A ST
Analog input module, 1 6ES7531-7KF00-0AB0 Configurable diagnostics
AI 8xU/I/RTD/TC ST
Front connector, 1 6ES7592-1BM00-0XB0 -
push-in type, 40-pin
IM 155-5 PN ST 1 6ES7155-5AA00-0AB0 ET 200MP
© Siemens AG 2019 All rights reserved

Digital input module, 1 6ES7521-1BL00-0AB0 Configurable diagnostics


DI 32x24VDC HF
Digital output module, 1 6ES7522-1BL00-0AB0 Configurable diagnostics
DQ 32x24VDC/0.5A ST
Analog input module, 1 6ES7531-7KF00-0AB0 Configurable diagnostics
AI 8xU/I/RTD/TC ST
Front connector, screw- 2 6ES7592-1AM00-0XB0 -
type, 40-pin
Front connector, 1 6ES7592-1BM00-0XB0 -
push-in type, 40-pin
IM 155-6 PN ST, incl. 1 6ES7155-6AA00-0BN0 ET 200SP
server module, incl. bus
adapter 2xRJ45
DI 8x24VDC HF 1 6ES7131-6BF00-0CA0 Configurable diagnostics
DQ 8x24VDC/0.5A HF 1 6ES7132-6BF00-0CA0 Configurable diagnostics
AQ 4xU/I ST 1 6ES7135-6HD00-0BA1 Configurable diagnostics
BU type A0, 16 push-in, 1 6ES7193-6BP00-0DA0 -
2 infeed terminals
separated (digital/analog,
max. 24VDC/10A)
BU type A0, 16 push-in, 2 6ES7193-6BP00-0BA0 -
2 infeed terminals
bridged (digital/analog,
24VDC/10A)
IM 155-6 PN ST, incl. 1 6ES7155-6AA00-0BN0 ET 200SP
server module, incl. bus
adapter 2xRJ45
DI 16x24VDC ST 1 6ES7131-6BH00-0BA0 Configurable diagnostics

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 6
1 Introduction

Component No. Article no. Note


BU type A0, 16 push-in, 1 6ES7193-6BP00-0DA0 -
2 infeed terminals
separated (digital/analog,
max. 24VDC/10A)
IM 155-6 DP HF 1 6ES7155-6BA00-0CN0 ET 200SP DP
incl. server module,
incl. DP connector
DI 8x24VDC HF 1 6ES7131-6BF00-0CA0 Configurable diagnostics
AI 4xRTD/TC HF 1 6ES7134-6JD00-0CA1 Configurable diagnostics
BU type A0, 16 push-in, 1 6ES7193-6BP00-0DA0 -
2 infeed terminals
separated (digital/analog,
max. 24VDC/10A)
BU type A0, 16 push-in, 1 6ES7193-6BP00-0BA0 -
2 infeed terminals
bridged (digital/analog,
24VDC/10A)
TP1200 Comfort 1 6AV2124-0MC01-0AX0 -
CU240E-2 PN-F 1 6SL3244-0BB13-1FA0 G120 drive
PM340 1 6SL3210-1SB14-0UA0 Power module
STEP 7 Professional 1 6ES7822-1..04-.. -
V14 SP1
© Siemens AG 2019 All rights reserved

WinCC Professional 1 6AV210.-….4-0 -


V14 SP1
SINAMICS 1 6SL3072-4EA02-0X.0 -
Startdrive V14 SP1
STEP 7 Professional 1 6ES7822-1..05-.. -
V15.1 Update 1
WinCC Professional 1 6AV210.-….5-0 -
V15.1 Update 1
SINAMICS 1 6SL3072-4FA02-0X.. -
Startdrive V15.1

Hinweis For the application example you need the free software package SINAMICS
Startdrive Basic. You can download SINAMICS Startdrive under the following
link:
https://support.industry.siemens.com/cs/ww/en/view/109760845

This application example consists of the following components:


Table 1-2: Components of the application example
Component File name
Documentation 98210758_User_defined_diagnostics_DOC_V34_en.pdf
STEP 7 project 98210758_Diag1500_TIAV14SP1_PROJ_V32.zip
TIA V14 SP1
STEP 7-Projekt 98210758_Diag1500_TIAV15.1_Adv_PROJ_V34.zip
TIA V15.1 for
WinCC Advanced
STEP 7-Projekt 98210758_Diag1500_TIAV15.1_Prof_PROJ_V34.zip
TIA V15.1 for
WinCC Professional

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 7
2 Test Project Engineering

2 Test Project Engineering


2.1 Hardware configuration of the test project
Figure 2-1: Hardware configuration of the test project

L+ M L+ M L+ M L+ M L+ M

SIMATIC
AI
SIMATIC DI DQ HMI
8xU/I/RTD/T
CPU 1516 32x24VDC 32x24VDC TP1200
C
Comfort

PN PN DP 1 19 PN PN

Wire break
simulation
PROFINET IO

L+ M L+ M L+ M L+ M

AI
SIMATIC DI DQ
8xU/I/RTD/T
IM 155-5 PN 32x24VDC 32x24VDC
C
© Siemens AG 2019 All rights reserved

PN PN

L+ M L+ M L+ M L+ M L N

SIMATIC DI DQ AQ SINAMIC
IM 155-6 PN 8x24VDC 8x24VDC 4xU/I G120

PN PN PN PN

L+ M L+ M L+ M L+ M L+ M

SIMATIC DI AI SIMATIC DI
IM 155-6 DP 8x24VDC 4xRTD/TC IM 155-6 PN 16x24VDC

DP PN PN

PROFIBUS DP

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 8
2 Test Project Engineering

2.2 Configuring the diagnostic settings


You can enable the module-specific diagnostic settings separately for each module
of your project. You can configure the diagnostic settings in the device view in the
module properties.
The following diagnostic settings can be made:
• No supply voltage L+
• Wire break
• Short circuit to ground
• etc.

Note For examples of how to configure the diagnostic settings, please refer to the
following application example:
“System Diagnostics with S7-1500 and TIA Portal”
https://support.industry.siemens.com/cs/ww/en/view/68011497

2.3 IP addresses, PROFIBUS addresses and device names


© Siemens AG 2019 All rights reserved

The application example uses the following device numbers, device names, IP
addresses and PROFIBUS addresses:

Table 2-1: Overview of IP addresses, PROFIBUS addresses and device names


Component Device IP address PROFIBUS Device name
number address
SIMATIC CPU 1516 0 192.168.0.1 2 PLC_1
SIMATIC IM 155-6 PN 2 192.168.0.2 - ET200SP_1
SIMATIC IM 155-5 PN 3 192.168.0.3 - ET200MP_2
SIMATIC IM 155-6 PN 10 192.168.0.10 - ET200SP_10
SINAMICS G120 30 192.168.0.30 - Drive_1
SIMATIC HMI TP1200 - 192.168.0.4 - HMI_1
SIMATIC PC station - 192.168.0.40 - PC System_1
SIMATIC IM 155-6 DP - - 8 Slave_8

2.4 Setting the PROFIBUS DP address


For the controller to communicate with the PROFIBUS devices, set the PROFIBUS
DP address using the DIP switches on the interface module of the ET 200SP.

Note For more information, please refer to the “SIMATIC ET 200SP IM 155-6 DP HF
interface module” manual, chapter “Setting the PROFIBUS DP address”.
https://support.industry.siemens.com/cs/ww/en/view/73098660/75117321227.

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 9
2 Test Project Engineering

2.5 Assigning the PROFINET device names


For all PROFINET devices to communicate with each other, assign a PROFINET
device name to the devices.
To do this, proceed as follows:
1. Open the network view.
2. Right-click the PROFINET connection line and select “Assign device name”.
The “Assign PROFINET device name” dialog is displayed.

Figure 2-2: Network view


© Siemens AG 2019 All rights reserved

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 10
2 Test Project Engineering

3. In “PROFINET device name”, select the device name.


4. From the list of accessible devices, select the device to which you want to
assign the PROFINET device name. You can update the list by clicking
“Update list”.
5. Click “Assign name”.
This assigns the device name.

Figure 2-3: “IO Systems” screen

4
© Siemens AG 2019 All rights reserved

6. Repeat steps 3 through 5 for all devices.

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 11
2 Test Project Engineering

2.6 Integration into the user project


The application example described here can be fully integrated into your project.
The necessary steps are described below.

Note Chapter 3.3 describes how the program blocks work.

2.6.1 Integrating PLC objects

Copying PLC objects


You can integrate the PLC objects of the application example directly into your
project.
To do this, proceed as follows:
1. Use TIA Portal to open your project.
2. Open the application example in a second instance of TIA Portal.
Alternatively, you can open the application example as a reference project for
your project.
3. In the application example, “PLC_1 > PLC tags”, copy the “UserDiag” folder
and paste the folder into the same location in your project.
4. In the application example, “PLC_1 > PLC data types”, copy the “UserDiag”
© Siemens AG 2019 All rights reserved

folder and paste the folder into the same location in your project.
5. In the application example, “PLC_1 > Program blocks”, copy the “UserDiag”
folder and paste the folder into the same location in your project.
6. Call the FB "UserDiag_Main" in the first network of the OB "Main".
Figure 2-4: Call in OB "Main"

7. Close the second instance of TIA Portal with the application example.

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 12
2 Test Project Engineering

Customizing constants to the project


The user constants allow you to customize the size of the diagnostic structures in
the “UserDiag_DiagnosticsData” DB to your project.
To do this, proceed as follows:
1. In “PLC_1 > PLC tags > UserDiag > UserDiag_Constants”, open the “User
constants”.
2. Optional: If the highest device number/slave address in your project is greater
than 128, modify the “USERDIAG_DEVICES_PER_
IO_SYSTEM_UPPER_LIM” constant to the highest device number/slave
address.
3. Modify the “USERDIAG_IO_SYSTEMS_UPPER_LIM” constant to the number
of IO systems in your project.
4. Create new constants for additional IO systems.
For example, “USERDIAG_IOSYSTEM_3” Int 3

Figure 2-5: “User constants”

2
© Siemens AG 2019 All rights reserved

Customizing the call of the diagnostic blocks to the project


The hardware IDs of the controller and the IO systems in your project may differ
from the hardware IDs in the application example. The hardware IDs are
customized when calling the diagnostic blocks in the "UserDiag_Diagnostics" FB.

Note If you upgrade TIA Portal V13 SP1 projects to TIA Portal V14, you will not find a
hardware ID for the PLC named “Local~Device” in the system constants. In this
case, assign the value “32” to the “plcHwId” parameter of the
“UserDiag_PLCCheck” FB (see step 4).

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 13
2 Test Project Engineering

To do this, proceed as follows:


1. Open the "UserDiag_Diagnostics" FB.
2. In “PLC_1 > PLC tags > Default tag table”, open the system constants.
3. Vertically split the editor area.
4. Use drag and drop to assign the PLC hardware ID to the “plcHwId” parameter
of the “UserDiag_PLCCheck” FB.
5. The PLC’s diagnostic structure has already been assigned to the “plcData”
parameter of the “UserDiag_PLCCheck” FB.
6. Use drag and drop to assign the IO system hardware ID to the “ioSystemHwId”
parameter of the “UserDiag_IOSystemCheck” FB.
7. The diagnostic structure of the appropriate IO system (PROFINET IO system
or DP master system) has already been assigned to the “ioSystemData”
parameter of the “UserDiag_IOSystemCheck” FB.
Please note that each IO system gets its own index, for example
“IO_SYSTEM1”.
8. Repeat steps 6 and 7 for the DP master system.
9. If necessary, insert more instances of the “UserDiag_IOSystemCheck” FB into
the “UserDiag_Main” FB and repeat steps 6 and 7.
An instance of the “UserDiag_IOSystemCheck” FB must be created for each
IO system.
Figure 2-6: Customizing the call to the project
© Siemens AG 2019 All rights reserved

2 1

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 14
2 Test Project Engineering

Calling "UserDiag_GetIPAddress"
With the FB "UserDiag_GetIPAddress" you can read the IP addresses of the
devices of a PROFINET IO system.
Insert additional instances of the FB "UserDiag_GetIPAddress" in the FB
"UserDiag_Main" as needed. For each PROFINET IO system a separate instance
of the FB "UserDiag_GetIPAddress" is necessary.
Notice that each IO system requires a unique index, e.g.
"USERDIAG_IOSYSTEM_1".

Figure 2-7: Call of "UserDiag_GetIPAddress"


© Siemens AG 2019 All rights reserved

Enable System memory


The system memory bit "DiagStatusUpdate" is used in the application example to
evaluate the diagnosis at change of the diagnostic state. Therefore you have to
enable the system memory of the PLC.
To do this, proceed as follows:
1. Open the properties of the PLC.
2. Navigate to "System and clock memory".
3. Enable "Enable the use of system memory byte".

Abbildung 2-8: Enable System memory


1

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 15
2 Test Project Engineering

2.6.2 Integrating HMI objects (TP 1200)

Note Alternatively, you can copy the entire HMI from the application example to your
project.

You can integrate the HMI objects of the application example directly into your
project.
To do this, proceed as follows:
1. Use TIA Portal to open your project.
2. Open the application example in a second instance of TIA Portal.
Alternatively, you can open the application example as a reference project for
your project.
3. In the application example, “HMI_1 > HMI tags”, copy the “UserDiag” folder
and paste the folder into the same location in your project.
4. Open the “UserDiag_TagTable” HMI tag table and in the “Connection” column,
set the HMI connection of your HMI.

Figure 2-9: “UserDiag_TagTable” HMI tag table


© Siemens AG 2019 All rights reserved

5. If you want to create more IO systems, open the “UserDiag_TagTable” HMI tag
table and create one new HMI tag for each additional IO system (e.g.,
“ioSystem3” Int 3).

Figure 2-10: “UserDiag_TagTable” HMI tag table

6. In the application example, “HMI_1 > Scripts > VB scripts”, copy the
“UserDiag” folder and paste the folder into the same location in your project.
7. In the application example, “HMI_1 > Screen management > Pop-up screens”,
copy the “UserDiag” folder and paste the folder into the same location in your
project.
8. In the application example, “HMI_1 > Screens > 001_Application”, copy the
“Topic_001.0_PLC”, “Topic_002.0_IO_System” and “Topic_003.0_Messages”
screens and paste the screens into your project.

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 16
2 Test Project Engineering

9. In the screens’ properties, select your template or no template.


You can also copy the templates in “HMI_1 > Screen management >
Templates” to your project.
10. To be able to open the screens on the operator panel, integrate the screens
into your screen navigation.
11. In “HMI_1 > Text and graphic lists”, change the “Text_list_IO_System” text list
to the number of your IO systems. The text list is used for displaying the IO
system in the “Topic_002.0_IO_System” screen.
The text list has already been created for four IO systems.

Figure 2-11: “Text_list_IO_System” text list

12. If you want to integrate another IO system, open the “Topic_002.0_IO_System”


screen.
© Siemens AG 2019 All rights reserved

a. Copy the group for another IO system.


b. Enter the HMI tag for your additional IO system.

Figure 2-12: “Topic_002.0_IO_System” screen

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 17
2 Test Project Engineering

c. Customize the index to your additional IO system.


Please note: The array for the HMI starts at the lower limit 0 and not, as is
the case in the STEP 7 user program, at 1.

Figure 2-13: “Topic_002.0_IO_System” screen

d. Customize the range to your additional IO system.


Figure 2-14: “Topic_002.0_IO_System” screen
© Siemens AG 2019 All rights reserved

e. Customize the value to your additional IO system.


Figure 2-15: “Topic_002.0_IO_System” screen

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 18
2 Test Project Engineering

2.6.3 Integrating HMI objects (PC station)

Note Alternatively, you can copy the entire PC station from the application example to
your project.

You can integrate the HMI objects of the application example directly into your
project.
To do this, proceed as follows:
1. Use TIA Portal to open your project.
2. Open the application example in a second instance of TIA Portal.
Alternatively, you can open the application example as a reference project for
your project.
3. In the application example, “PC-System_1 > HMI_RT_2 > HMI tags”, copy the
“UserDiag” folder and paste the folder into the same location in your project.
4. Open the “UserDiag_TagTable” HMI tag table and in the “Connection” column,
set the HMI connection of your PC station.

Figure 2-16: “UserDiag_TagTable” HMI tag table


© Siemens AG 2019 All rights reserved

5. If you want to create more IO systems, open the “UserDiag_TagTable” HMI tag
table and create one new HMI tag for each additional IO system (e.g.,
“ioSystem3” Int 3).

Figure 2-17: “UserDiag_TagTable” HMI tag table

6. In the application example, “PC-System_1 > HMI_RT_2 > Scripts > VB


scripts”, copy the “UserDiag” folder and paste the folder into the same location
in your project.
7. In the application example, “PC-System_1 > HMI_RT_2 > Screens”, copy the
“Pop-Up” and “Slide-in” folders and paste the folders into the same location in
your project.
8. In the application example, “PC-System_1 > HMI_RT_2 > Screens >
001_Application”, copy the “Topic_0010_PLC”, “Topic_0020_IO_System” and
“Topic_0030_Messages” screens and paste the screens into your project.
9. To be able to open the screens in Runtime, integrate the screens into your
screen navigation.

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 19
2 Test Project Engineering

10. In “PC-System_1 > HMI_RT_2 > Text and graphic lists”, change the
“Text_list_IO_System” text list to the number of your IO systems. The text list is
used for displaying the IO system in the “Topic_0020_IO_System” screen.
The text list has already been created for four IO systems.
Figure 2-18: “Text_list_IO_System” text list

11. If you want to integrate another IO system, open the “Topic_002.0_IO_System”


screen.
a. Copy the group for another IO system.
b. Enter the HMI tag for your additional IO system.

Figure 2-19: “Topic_002.0_IO_System” screen

a
© Siemens AG 2019 All rights reserved

c. Customize the index to your additional IO system.


Please note: The array for the HMI starts at the lower limit 0 and not, as is
the case in the program, at 1.

Figure 2-20: “Topic_002.0_IO_System” screen

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 20
2 Test Project Engineering

d. Customize the range to your additional IO system.


Figure 2-21: “Topic_002.0_IO_System” screen

e. Customize the value to your additional IO system.

Figure 2-22: “Topic_002.0_IO_System” screen

e
© Siemens AG 2019 All rights reserved

12. In “Connections”, “Access point”, select the desired interface and uncheck the
“Set automatically” check box.

Figure 2-23: “Topic_002.0_IO_System” screen

Note For more information about connections, please refer to the FAQ titled “Why
does communication not work between WinCC Professional Runtime and
S7-1200?”:
https://support.industry.siemens.com/cs/ww/en/view/62612087

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 21
2 Test Project Engineering

2.7 Operation
Operation is shown using the TP1200 Comfort operator panel.

2.7.1 Overview

The following figure shows the user interface of the TP1200 Comfort.

Figure 2-24: HMI screens overview

Slide-in screen navigation

PLC overview IO system device overview Alarm display


© Siemens AG 2019 All rights reserved

Reset saved state


Device detail view pop-up
Show legend
Show previous 32 devices
Show next 32 devices
Select IO system
Enable “faulty devices” filter

Close pop-up

Start screen
The “Topic” screen shows the start screen of the application example.

Screen navigation
The slide-in screen is used for screen navigation.

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 22
2 Test Project Engineering

PLC overview
The “PLC” screen shows the diagnostic information of the controller and its
modules.
• Clicking the “Legend” button opens the pop-up screen with the different
appearances of the icons for the devices and modules and their meaning.
• The “Reset overview” button allows you to delete the saved state of the
controller.
• In the “Wait time Acknowledge” input field, you can enter a wait time after
startup for automatic reset of the saved error state.

Overview of the devices in the IO system


The “IO-Systems” screen shows the configured devices of the selected IO system.
• The “IO System x” buttons allow you to select the IO systems.
• Click the “˅” button to view the next 32 devices. Clicking the “˄” button displays
the previous 32 devices.
• The “Filter” button allows you to view only faulty devices.
• Clicking the “Legend” button opens the pop-up screen with the different
appearances of the icons for the devices and modules and their meaning.
• The “Reset overview” button allows you to delete the saved state of the current
IO system.
• Clicking the button of a device opens the pop-up screen with the detail view of
© Siemens AG 2019 All rights reserved

the device.

Detail view of a device


The pop-up screen displays:
• Diagnostic information of the modules of a device
• Index of the IO system
• Device number / slave address
• IP address
• Device name
Clicking the “close” button closes the pop-up screen.

Alarms
The “Alarms” screen shows the alarms window with the alarms.

Legend
The pop-up screen shows the different appearances of the icons for the devices
and modules and their meaning.

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 23
2 Test Project Engineering

2.7.2 Devices and module icon legend

The devices and modules can each have different states. The following table
shows the appearance of the icons and their meaning.

Table 2-2: Icon legend


State Appearance Meaning
1 State OK

2 State FAULTY

3 State LOST CONNECTION

4 State DEACTIVATED

5 State PROBLEM / MAINTENANCE

12 State WAS FAULTY

13 State HAD LOST CONNECTION


© Siemens AG 2019 All rights reserved

14 State WAS DEACTIVATED

15 State WAS PROBLEM / MAINTENANCE

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 24
2 Test Project Engineering

2.7.3 Diagnostics on the operator panel

Diagnostics of “missing module on ET200SP_1”


To diagnose the fault, proceed as follows:
1. Remove the DQ8 module from slot 2 of the ET200SP_1.
2. On the operator panel, open the “IO Systems” screen.
3. Click the “IO System 1” button.
The screen displays the fault on the device with device number 2.
4. For detailed information about the fault, click the button of device 2.

Figure 2-25: “IO Systems” screen


2

4
© Siemens AG 2019 All rights reserved

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 25
2 Test Project Engineering

5. The pop-up screen with the detail view of device 2 opens. The view displays an
error on slot 2, the index of the IO system, the device number, the IP address
and the device name.
Clicking “close” closes the pop-up screen.

Figure 2-26: Pop-up screen with the detail view of the device
© Siemens AG 2019 All rights reserved

6. Open the “Alarms” screen if you want to view the alarm for the fault.

Figure 2-27: “Alarms” screen

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 26
2 Test Project Engineering

7. Reinsert the module into slot 2.


The icon of device 2 turns green with a yellow border. This means that the
device was faulty and the fault has been cleared.
Clicking “Reset overview” deletes the saved state and the border color returns
to black.

Figure 2-28: “IO Systems” screen


© Siemens AG 2019 All rights reserved

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 27
2 Test Project Engineering

2.7.4 Evaluating the diagnostic information

This chapter uses an example to show you where to find the diagnostic information
in the event of an error. Retrieving this information in your program allows you to
program specific responses to certain faults in the plant.

Evaluating the “missing module on ET200SP_1” diagnostic information


Remove the DQ8 module from slot 2 of the ET200SP_1 to cause a fault. The fault
is saved in the “UserDiag_DiagnosticsData” DB. Clicking the “Monitor all” button
allows you to view the actual values of the tags.
The data in the “UserDiag_DiagnosticsData” DB have to be interpreted as follows:
1. The “ioSystemData > ioSystemData[1]” structure displays the saved diagnostic
information of the entire IO system. The “error = TRUE” tag indicates a fault in
the IO system.
2. The “devices > devices[2]” structure displays the saved diagnostic information
of the device with device number 2. The “error = TRUE” tag indicates a fault in
the device.
3. The “slot > slot[2]” structure displays the saved diagnostic information of the
module on slot 2. The “error = TRUE” tag indicates the fault in the module. The
“exists = FALSE” tag indicates that the module is missing.

Figure 2-29: Diagnostic information about the fault in the “UserDiag_DiagnosticsData” DB


© Siemens AG 2019 All rights reserved

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 28
3 Valuable Information

3 Valuable Information
3.1 Basics of system diagnostics for S7-1500 PLCs
System diagnostics allow you to analyze errors in the system and generate alarms
with a textual error description and the error location.
System diagnostics are integrated in the S7-1500 PLC’s firmware and operate
independently of the cyclic user program. Therefore, system diagnostics are also
available in STOP mode of the PLC. Faults are detected immediately and reported
to the higher-level HMI devices, the web server, the S7-1500 PLC’s display, the
LED displays on the relevant module and TIA Portal even in STOP mode. This
ensures that system diagnostics are always synchronized with the actual plant
status.
All connected diagnostic display media are supplied with the same system
diagnostic information by a uniform mechanism.

Note For more information about integrated system diagnostics, please refer to the
following application example:
“System Diagnostics with S7-1500 and TIA Portal”
https://support.industry.siemens.com/cs/ww/en/view/68011497
© Siemens AG 2019 All rights reserved

3.2 Diagnostic instructions


If you want to retrieve the diagnostic information of a device in the user program,
STEP 7 provides the following instructions:
Table 3-1: Diagnostic instructions overview
Instruction Description
RD_SINFO Read start information of current OB
RT_INFO Read runtime statistics (not part of this application)
LED Read LED status
Get_IM_Data Read identification and maintenance data
GET_NAME Read name of a module
GetStationInfo Read information of an IO device
DeviceStates Read module status information in an IO system
ModuleStates Read module status information of a module
GEN_DIAG Generate diagnostic information
(not part of this application example)
GET_DIAG Read diagnostic information
(not part of this application example)
Get_Alarm Read pending alarm

Note For more information about the diagnostic instructions, please refer to the
STEP 7 Professional V14 SP1 system manual:
https://support.industry.siemens.com/cs/ww/en/view/109747136

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 29
3 Valuable Information

3.3 Details about how the program blocks work


This chapter describes the program blocks of the application example.

3.3.1 Complete overview

The following figure shows the program structure of the entire STEP 7 project.
Figure 3-1: Program structure

UserDiag_
GetStation
GetIP
Address Info

UserDiag_ GEO2LOG
HmiData

Main UserDiag_
Diagnostics
Hmi
LOG2GEO
© Siemens AG 2019 All rights reserved

UserDiag_
UserDiag_ PLCCheck Device
Main States

UserDiag_ UserDiag_
Diagnostics Diagnostics Get_Name
Data

Module
Startup States
UserDiag_
IOSystem
Check

Datenbausteine Anwenderprogramm Systembausteine

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 30
3 Valuable Information

3.3.2 “UserDiag_Constants” tag table

The “UserDiag_Constants” table defines the user constants. With the user
constants, you define the size of the diagnostic structures in the
“UserDiag_DiagnosticsData” DB.
Table 3-2: “UserDiag_Constants” tag table
Constant Type Value Meaning
USERDIAG_SLOTS_ Int 31 Maximum number of modules per
PER_DEVICE_UPPER_LIM device.
USERDIAG_SLOTS_ Int 31 Maximum number of local modules.
PER_PLC_UPPER_LIM
USERDIAG_DEVICES_ Int 128 Upper array limit for devices per IO
PER_IO_SYSTEM_UPPER_LIM system.
USERDIAG_IO_SYSTEMS_ Int 2 Upper array limit for IO systems.
UPPER_LIM
USERDIAG_DEVICES_ Int 32 Upper array limit for number of
PER_SCREEN_UPPER_LIM devices per HMI screen.
USERDIAG_SLOTS_ Int 31 Upper array limit for number of slots
PER_SCREEN_UPPER_LIM per HMI screen.
USERDIAG_IO_SYSTEM_1 Int 1 Index for first IO system.
USERDIAG_IO_SYSTEM_2 Int 2 Index for second IO system.
© Siemens AG 2019 All rights reserved

3.3.3 “UserDiag_DiagnosticsData” DB

The “UserDiag_DiagnosticsData” DB saves the hardware IDs and the diagnostic


information of the controller and the IO systems.
The following table shows the structure of the “UserDiag_DiagnosticsData” DB.
Table 3-3: “UserDiag_DiagnosticsData” DB
Tag name Data type Meaning
plcData UserDiag_typePLC Diagnostic data of the PLC.
(See plcData
[UserDiag_typePlc])
ioSystemData Array [1.. USERDIAG_IO_ Diagnostic data of the IO
SYSTEMS_UPPER_LIM] of systems.
UserDiag_typeIoSystem (See ioSystemData
[UserDiag_typeIoSystem])
startDiag Bool Start Diagnostics.

For greater clarity, the individual tags of the components were grouped into the
following PLC data types.

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 31
3 Valuable Information

plcData [UserDiag_typePlc]
The PLC data type contains the information of the controller and the modules in the
local slots.
Table 3-4: “UserDiag_typePlc” PLC data type
Tag name Data type Meaning
hardwareId HW_DEVICE Hardware ID of the PLC.
error Bool Error pending.
actualConfigured Int Number of configured local
Slots slots.
slots Array [0..USERDIAG_SLOTS_ See slots [UserDiag_typeSlot].
PER_PLC_UPPER_LIM]
of "UserDiag_typeSlot"

slots [UserDiag_typeSlot]
The PLC data type contains the information of a module (slot).
Table 3-5: “UserDiag_typeSlot” PLC data type
Tag name Data type Meaning
hardwareId HW_IO Hardware ID of the module in
the slot
state USInt Module state (see 2.7.2)
© Siemens AG 2019 All rights reserved

exists Bool Module exists


configured Bool Module configured
faulty Bool Module faulty
problem Bool Module has a problem
disabled Bool Module disabled
error Bool Error in the module

ioSystemData [UserDiag_typeIoSystem]
The PLC data type contains the information of an IO system.
Table 3-6: “UserDiag_typeIoSystem” PLC data type
Tag name Data type Meaning
hardwareId HW_IOSYSTEM Hardware ID of the IO system.
number UInt Number of the IO system / DP
master system.
error Bool Error in the IO system / DP
master system.
firstDevice Int Number of the first device in the
IO system / DP master system.
lastDevice Int Number of the last device in the
IO system / DP master system.
actualConfigured Int Number of configured devices in
Devices the IO system / DP master
system.
devices Array [0..USERDIAG_DEVICES_ Diagnostic structure of the
PER_IO_SYSTEM_UPPER_LIM] devices.
of "UserDiag_typeDevice" See devices
[UserDiag_typeDevice].

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 32
3 Valuable Information

Note The array index of the “device” tag corresponds to the device number.

devices [UserDiag_typeDevice]
The PLC data type contains the information of a device (device or slave).
Table 3-7: “UserDiag_typePlc” PLC data type
Tag name Data type Meaning
hardwareId HW_DEVICE Hardware ID of the device.
number UInt Device number / PROFIBUS
address.
name String[50] Device name.
ipAddress IP_V4 IP address of the device
(for IO system only).
state USInt Device state. (See 2.7.2)
exists Bool Device exists.
configured Bool Device configured.
faulty Bool Device faulty.
problem Bool Device has a problem.
© Siemens AG 2019 All rights reserved

disabled Bool Device disabled.


error Bool Error in the device.
nextDevice Int Number of the next device.
actualConfigured Int Number of configured slots of
Slots the device.
slots Array [0..USERDIAG_SLOTS_ Diagnostic structure of the
PER_DEVICE_UPPER_LIM] modules.
of "UserDiag_typeSlot" See slots [UserDiag_typeSlot].

Note The array index of the “slots” tag corresponds to the slot number on the device.

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 33
3 Valuable Information

3.3.4 “UserDiag_HmiData” DB

The “UserDiag_HmiData” DB serves as an interface to the visualization. The DB is


of the PLC data type "UserDiag_typeHmiData".

[UserDiag_typeHmiData]
Table 3-8: “UserDiag_typeHmiData” PLC data type
Tag name Data type Meaning
actIOSystem Int Index of the selected IO system.
actDeviceOf Int Index of the selected device in
Screen the screen.
ioSlotDiagnostics Bool “Device detail view” screen
Loaded open.
actScreenDevices Int Current device overview screen
of the selected IO system.
maxScreens Int Maximum number of device
Devices overview screens of the
selected IO system.
ackWaitTime Int Wait time after startup for
automatic reset of the saved
error state in [s].
ackStates Bool Reset saved error state.
© Siemens AG 2019 All rights reserved

actIOSystemData UserDiag_typeActIOSystem Diagnostic data of the selected


IO system.
(See actIOSystemData
[UserDiag_typeActIOSystem])
actDeviceNumber UInt Device number of the selected
device.
actDeviceName String[50] Device name of the selected
device.
actIPAddress IP_V4 IP address of the selected
device.
errorAtLower Bool Error on the previous device
Screen overview screen of the selected
IO system.
errorAtUpper Bool Error on the next device
Screen overview screen of the selected
IO system.
filterErrorDevices Bool Filter, only faulty devices are
displayed.
ioSystemError Array [0..USERDIAG_IO_ Error in the IO system.
SYSTEMS_UPPER_LIM] of Bool

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 34
3 Valuable Information

actIOSystemData [UserDiag_typeActIOSystem]
The data type contains the information of the selected IO system and the selected
device or the information of the controller.
Table 3-9: “UserDiag_typeActIOSystem” PLC data type
Tag name Data type Meaning
actIoSystem Int Number of the selected IO
Number system.
actIODevice Array [1..USERDIAG_DEVICES_ Device numbers / PROFIBUS
Numbers PER_SCREEN_UPPER_LIM] addresses of the selected IO
of UInt system.
actIODeviceState Array [1..USERDIAG_DEVICES_ State of the devices of the
PER_SCREEN_UPPER_LIM] selected IO system.
of USInt
actDeviceSlots Array [0..USERDIAG_SLOTS_ Slots used of the selected
Used PER_SCREEN_UPPER_LIM] device.
of Bool (Determined during startup.)
actDeviceSlots Array [0..USERDIAG_SLOTS_ State of the slots of the selected
State PER_SCREEN_UPPER_LIM] device.
of USInt
© Siemens AG 2019 All rights reserved

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 35
3 Valuable Information

3.3.5 “UserDiag_PLCCheck” FB

During the first call, the “UserDiag_PLCCheck” FB determines the hardware IDs of
the local components. The FB reads the status information of the local modules
and evaluates it.

Interfaces
Figure 3-2: Call in "UserDiag_Diagnostics"

Table 3-10: Parameters of the block interface


Type Parameter Data type Description
Input plcHwId HW_DEVICE Hardware ID of the controller.
InOut plcData UserDiag_typePlc Diagnostic data of the controller and its
local modules.
© Siemens AG 2019 All rights reserved

Output error Bool An error occurred while processing the


FB.
The “status” and “statusID” outputs
provide related information about
locating the error cause.
status Word Error code of the FB or of a diagnostic
instruction that was called internally. The
error location within the FB can be
additionally read via the “statusID”
output.
statusID Word Specifies an additional error code for
locating the error cause within the FB.

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 36
3 Valuable Information

“status” error code


The following table describes the possible error code:
Table 3-11: Error code at the “status” output
Error code Description
16#0000 No error.
16#8xxx Error (RET_VAL) of the diagnostic instructions.
16#8400 Internal error: The number of configured modules exceeds the array limit,
“USERDIAG_SLOTS_PER_PLC_UPPER_LIM”.

“statusID” error sources


The following table describes the error sources:
Table 3-12: Error source at the “statusID” output
statusID Meaning Note
0 No error. -
1 Internal error of the FB. -
2 Error while reading the status information of the modules Reserve
with “ModuleStates” in mode “1: Modules are configured”.
3 Error while reading the status information of the modules -
with “ModuleStates” in mode “2: Modules are faulty”.
© Siemens AG 2019 All rights reserved

4 Error while reading the status information of the modules -


with “ModuleStates” in mode “5: A problem has occurred in
the modules”.
5 Error while reading the status information of the modules -
with “ModuleStates” in mode “4: Modules exist”.

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 37
3 Valuable Information

Functional description
The FB is used to automatically determine the hardware IDs of the local
components using the “GEO2LOG” instruction based on the slot information. The
slot information is rewritten with a tag of the “GEOADDR” system data type before
each call of the instruction.
The “ModuleStates” instruction reads the status information of the local modules for
different modes. The FB evaluates this status information.
The hardware IDs and the evaluated diagnostic information are saved in the
appropriate structure in the “UserDiag_DiagnosticsData” global data block.
The following figure shows the basic program flow of the FB.

Figure 3-3: Program flow of the FB

Start/stop

No
Read HW ID

Yes
Set slot
information
© Siemens AG 2019 All rights reserved

of local module x

GEO2LOG
Read HW ID
of local module

No
Last module

Yes
ModuleStates
Read states of modules
(mode 2, 4, 5)

Evaluate and save


states of
modules

Start/stop

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 38
3 Valuable Information

3.3.6 “UserDiag_IOSystemCheck” FB

During the first call, the “UserDiag_IOSystemCheck” FB determines the hardware


IDs of the components of an IO system. The FB reads the status information of the
distributed devices and their modules and evaluates it.

Interfaces
Figure 3-4: Call in the "UserDiag_Diagnostics" FB for IO system 1 and IO system 2
© Siemens AG 2019 All rights reserved

Table 3-13: Parameters of the block interface


Type Parameter Data type Description
Input ioSystemHwId HW_IOSYSTEM Hardware ID of the IO system.
InOut ioSystemData UserDiag_ Diagnostic data of the IO system.
typeIOSystem
Output error Bool An error occurred while processing the
FB.
The “status” and “statusID” outputs
provide related information about
locating the error cause.
status Word Error code of the FB or of a diagnostic
instruction that was called internally. The
error location within the FB can be
additionally read via the “statusID”
output.
statusID Word Specifies an additional error code for
locating the error cause within the FB.

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 39
3 Valuable Information

“status” error code


The following table describes the possible error code:
Table 3-14: Error code at the “status” output
Error code Description
16#0000 No error.
16#8xxx Error (RET_VAL) of the diagnostic instructions.
16#8400 Internal error: The number of configured modules exceeds the array limit,
“USERDIAG_SLOTS_PER_DEVICE_UPPER_LIM”.
16#8401 Internal error: The number of configured devices exceeds the array limit,
“USERDIAG_DEVICES_PER_IO_SYSTEM_UPPER_LIM”.

“statusID” error sources


The following table describes the error sources:
Table 3-15: Error source at the “statusID” output
statusID Meaning Note
0 No error. -
1 Internal error of the FB. -
2 Error while reading the status information of the modules Reserve
with “ModuleStates” in mode “1: Modules are configured”.
© Siemens AG 2019 All rights reserved

3 Error while reading the status information of the modules -


with “ModuleStates” in mode “2: Modules are faulty”.
4 Error while reading the status information of the modules -
with “ModuleStates” in mode “5: A problem has occurred in
the modules”.
5 Error while reading the status information of the modules -
with “ModuleStates” in mode “4: Modules exist”.
6 Error while reading the status information of the devices -
with “DeviceStates” in mode “1: Devices are configured”.
7 Error while reading the status information of the devices -
with “DeviceStates” in mode “2: Devices are faulty”.
8 Error while reading the status information of the devices -
with “DeviceStates” in mode “5: A problem has occurred in
the devices”.
9 Error while reading the status information of the devices -
with “DeviceStates” in mode “4: Devices exist”.
10 Error while reading the status information of the devices -
with “DeviceStates” in mode “3: Devices disabled”.
11 Error while reading the device name with “GET_NAME”. -

Functional description
The FB is used to automatically determine the hardware IDs of the devices and
modules of an IO system using the “GEO2LOG” instruction based on the slot
information. The slot information is rewritten with a tag of the “GEOADDR” system
data type before each call of the instruction.
The “GET_NAME” instruction reads the names of the PROFIBUS DP slaves /
PROFINET IO devices.

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 40
3 Valuable Information

The “DeviceStates” and “ModuleStates” instructions read the status information of


the devices and their modules for different modes. The FB evaluates the status
information.
The hardware IDs and the evaluated status information are saved in the
appropriate structure in the “UserDiag_DiagnosticsData” global data block.
The following figure shows the basic program flow of the FB.

Figure 3-5: Program flow of the FB

Start/stop

No
Read HW ID

Yes
LOG2GEO Set slot DeviceStates
Read number of information Read states of
IO system of device y module x existing devices

PROFIBUS DP or GEO2LOG DeviceStates


PROFINET IO Read HW ID Read states of
evaluation of module faulty devices
© Siemens AG 2019 All rights reserved

DeviceStates No DeviceStates
Read states of Last module Read states of
configured devices deactivated devices
Yes
Set slot DeviceStates
information
Determine no. of
Read states of
of device x devices and modules “problem” devices

GEO2LOG No Evaluate and save


Read HW ID Last device states
of device of devices
Yes
GET_NAME ModuleStates
Read Read states of
device name “problem” modules

ModuleStates
Read states of
faulty modules

ModuleStates
Read states of
existing modules

Evaluate and save


states
of modules

Start/stop

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 41
3 Valuable Information

3.3.7 "UserDiag_Diagnostics" FB

The "UserDiag_Diagnostics" FB calls all diagnostic blocks of the controller and the
IO systems.

Interfaces
Figure 3-6: Call in "UserDiag_Main" FB

Table 3-16: Parameters of the block interface


Type Parameter Data type Description
© Siemens AG 2019 All rights reserved

InOut startDiag Bool Start Diagnostics.


plcData UserDiag_typePlc Diagnostic data of the
controller and its local
modules.
ioSystemData Array [1.. USERDIAG_ Diagnostic data of the
IO_SYSTEMS_ IO systems.
UPPER_LIM] of (See ioSystemData
UserDiag_typeIoSystem [UserDiag_typeIoSystem])

The “UserDiag_Diagnostics” FB is called by the following program blocks:


• "UserDiag_Main"
• "Startup"

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 42
3 Valuable Information

Functional description
The diagnostics in the FB "UserDiag_Diagnostics" are only executed, if
"statStartDiag" is set to "TRUE" by the system memory bit "DiagStatusUpdate" or
by "UserDiag_DiagnosticsData".startDiag.
The “UserDiag_Diagnostics” FB calls the “UserDiag_PLCCheck” FB to evaluate
the diagnostic information of the controller and the “UserDiag_IOSystemCheck” FB
for each IO system to evaluate the diagnostic information of the IO systems.

NOTE If you activate a device which is not connected to the bus system with the
instruction “D_ACT_DP”, it is possible that the system memory bit
“DiagStatusUpdate” is not be properly set upon activation. In this case you must
start the evaluation of the diagnosis by setting the variable
“UserDiag_DiagnosticsData”.startDiag in the user program.

The following figure shows the basic program flow of the FB.
Figure 3-7: Program flow of the FB

Start/Stop
© Siemens AG 2019 All rights reserved

No
Start Diagnostics

Yes

Reset
Start Diagnostics

UserDiag_
PLCCheck

UserDiag_
IOSystemCheck
IO-System 1

UserDiag_
IOSystemCheck
IO-System 2

Start/Stop

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 43
3 Valuable Information

3.3.8 FB "UserDiag_GetIPAddress"

The FB "UserDiag_GetIPAddress" reads the IP addresses of the devices of a


PROFINET IO system.

Interfaces
Figure 3-8: Call in "UserDiag_Main" FB

Table 3-17: Parameters of the block interface


Type Parameter Data type Description
InOut ioSystemData UserDiag_ Diagnostic data of the IO system.
typeIOSystem
© Siemens AG 2019 All rights reserved

Output error Bool An error occurred while processing the FB.


The “status” and “statusID” outputs provide
related information about locating the error
cause.
status Word Error code of the instruction
"GetStationInfo".
statusID Word ID of the instruction "GetStationInfo".

Functional description
The instruction "GetStationInfo" reads the IP addresses of the PROFINET IO
devices of a PROFINET IO system.
The following figure shows the basic program flow of the FB.
Figure 3-9: Program flow of the FB

Start/Stop

GetStationInfo
Read IP address

Start/Stop

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 44
3 Valuable Information

3.3.9 “UserDiag_DiagnosticsHmi” FB

The “UserDiag_DiagnosticsHmi” FB responds to the inputs made on the HMI and


provides the required diagnostic information to the visualization.

Interfaces
Figure 3-10: Call in the “UserDiag_Main” FB

Table 3-18: Parameters of the block interface


© Siemens AG 2019 All rights reserved

Type Parameter Data type Description


InOut plcData UserDiag_typePlc Diagnostic data of the
controller and its local
modules.
ioSystemData Array [1..USERDIAG_ Diagnostic data of the
IO_SYSTEMS_ IO systems.
UPPER_LIM] of (See ioSystemData
UserDiag_typeIo [UserDiag_typeIoSystem])
System
actIOSystemData UserDiag_typeHmiData Informations for the
visualization.
(See
[UserDiag_typeHmiData])

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 45
3 Valuable Information

Functional description
After startup and a wait time, the “UserDiag_DiagnosticsHmi” FB resets the saved
error state.
The FB responds to the inputs made on the HMI. Following the request, the FB
resets the saved error state and supplies the visualization with the requested data,
for example:
• Diagnostic information of the controller and its local modules
• Diagnostic information of the IO system
• Diagnostic information of the devices and their modules
The following figure shows the basic program flow of the FB.
Figure 3-11: Program flow of the FB

Start/stop

Reset saved error state


after startup and wait time

Check which IO
system has been selected
© Siemens AG 2019 All rights reserved

Yes
Filter

No

Provide states of devices Provide states of faulty devices


of selected IO system of selected IO system
to HMI to HMI

Provide states of modules


of selected device / PLC
to HMI

When requested, reset


error state of selected
IO system / PLC

Start/stop

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 46
3 Valuable Information

3.3.10 "UserDiag_Main" FB

The FB "UserDiag_Main" calls all program blocks that are required for diagnostics.

Interfaces
Figure 3-12: Call in "Main" OB

Functional description
The FB calls the FBs "UserDiag_Diagnostics", "UserDiag_DiagnosticsHMI" and
"UserDiag_GetIPAddresses" for evaluating and visualizing the diagnostics
information of the controller.
The following figure shows the basic program flow of the FB.
Figure 3-13: Program flow of the FB

Start/Stop
© Siemens AG 2019 All rights reserved

UserDiag_
Diagnostics

UserDiag_
GetIPAddress

UserDiag_
DiagnosticsHmi

Start/Stop

Note Call the FB "UserDiag_Main" before the processing of your user program, e.g. in
the first network of the OB "Main". Thus, the evaluated diagnostics information is
consistent for the duration of the cycle.

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 47
4 Appendix

4 Appendix
4.1 Service and Support
Industry Online Support
Do you have any questions or do you need support?
With Industry Online Support, our complete service and support know-how and
services are available to you 24/7.
Industry Online Support is the place to go to for information about our products,
solutions and services.
Product Information, Manuals, Downloads, FAQs and Application Examples – all
the information can be accessed with just a few clicks:
https://support.industry.siemens.com

Technical Support
Siemens Industry’s Technical Support offers you fast and competent support for
any technical queries you may have, including numerous tailor-made offerings
ranging from basic support to custom support contracts.
You can use the web form below to send queries to Technical Support:
www.siemens.com/industry/supportrequest.

Service offer
© Siemens AG 2019 All rights reserved

Our service offer includes the following services:


• Product Training
• Plant Data Services
• Spare Part Services
• Repair Services
• Field & Maintenance Services
• Retrofit & Modernization Services
• Service Programs & Agreements
For detailed information about our service offer, please refer to the Service
Catalog:
https://support.industry.siemens.com/cs/sc

Industry Online Support app


The “Siemens Industry Online Support” app provides you with optimum support
while on the go. The app is available for Apple iOS, Android and Windows Phone:
https://support.industry.siemens.com/cs/ww/en/sc/2067

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 48
4 Appendix

4.2 Links and literature


Table 4-1
No. Topic
\1\ Siemens Industry Online Support
https://support.industry.siemens.com
\2\ Link to the entry page of the application example
https://support.industry.siemens.com/cs/ww/en/view/98210758
\3\ System Diagnostics with S7-1500 and TIA Portal
https://support.industry.siemens.com/cs/ww/en/view/68011497
\4\ STEP 7 Professional V14 SP1 System Manual
https://support.industry.siemens.com/cs/ww/en/view/109747136
\5\ SIMATIC STEP 7 Basic/Professional V15.1 and SIMATIC WinCC V15.1
https://support.industry.siemens.com/cs/ww/en/view/109755202
\6\ S7-1500 System Manual
https://support.industry.siemens.com/cs/ww/en/view/59191792
\7\ SINAMICS Startdrive
https://support.industry.siemens.com/cs/ww/en/view/109760845
© Siemens AG 2019 All rights reserved

4.3 Change documentation


Table 4-2
Version Date Modifications
V1.0 09/2014 First version
V2.0 04/2015 New version with evaluation of errors in error OBs
V2.1 04/2016 New version with SINAMICS G120 and structured HMI tags
V2.2 07/2016 New version: Error analysis modified
V2.3 10/2016 New version: Minor error correction
V3.0 05/2017 Complete revision
V3.1 01/2018 Evaluation of the diagnostics in OB "Main".
The evaluation is triggered by the system memory bit
"DiagStatusUpdate".
V3.2 02/2018 Minor error correction
V3.3 03/2019 Upgrade to TIA Portal V15.1 Update 1
V3.4 09/2019 HMI: Reset of "ioSlot Diagnostics Loaded" even if module
overview is not closed via "close"

Diagnostics in the User Program with S7‑1500


Entry ID: 98210758, V3.4, 09/2019 49

You might also like