TIA PRO2 12 SystemDiag Error OBs
TIA PRO2 12 SystemDiag Error OBs
Contents 12
12. System Diagnostics and Error Handling ............................................................ 12-2
12.1. Task Description: Displaying an I/O-Device Failure on the Touchpanel ............................ 12-3
12.2. Functional Principle of the CPU System Diagnostics ......................................................... 12-4
12.3. Overview: Diagnostics - Possibilities .................................................................................. 12-5
12.4. Diagnostics using the PG with STEP 7 ............................................................................... 12-6
12.5. CPU System Diagnostics .................................................................................................... 12-7
12.5.1. CPU System Diagnostics: Functional Principle .................................................................. 12-8
12.5.2. Activating/Parameterizing CPU System Diagnostics .......................................................... 12-9
12.5.3. Displaying System Diagnostics Alarms on the HMI Device with "System
Diagnostics View" ............................................................................................................. 12-10
12.6. Diagnostics with the CPU Web Server ............................................................................. 12-11
12.6.1. Accessing the Web Service .............................................................................................. 12-12
12.6.2. Web Server: "Start Page" ................................................................................................. 12-13
12.6.3. Web Server: "Diagnostic Buffer" ....................................................................................... 12-14
12.6.4. Parameterizing the CPU Web Server ............................................................................... 12-15
12.7. Exercise 1: Displaying System Diagnostics Alarms on the CPU-Display and in
STEP 7 .............................................................................................................................. 12-16
12.7.1. Exercise 2: Displaying System Diagnostics Alarms in STEP 7 ........................................ 12-17
12.7.2. Exercise 3: Viewing System Diagnostics on the HMI Device ........................................... 12-18
12.7.3. Exercise 4: Activating and Parameterizing the Web Server ............................................. 12-19
12.8. Diagnostics using the S7 Program.................................................................................... 12-20
12.8.1. Start Information of the "Non-optimized" Error Organization Blocks ................................ 12-21
12.8.2. Global Error Handling with Asynchronous Error OBs ....................................................... 12-22
12.8.3. Determining the Geographic Address (Module Slot) using "LOG2GEO" ......................... 12-23
12.8.4. "DeviceStates": Reading the Module Status Information in an IO-System....................... 12-24
12.8.5. Global Handling of Synchronous Errors with Error OBs: Principle ................................... 12-25
12.8.6. Global Handling of Synchronous Errors with Error OBs: CPU Behavior .......................... 12-26
12.8.7. Local Handling of Synchronous Errors ............................................................................. 12-27
12.9. Task Description: Displaying an IO-Device Error and Time-of-day Synchronization
with the CPU ..................................................................................................................... 12-28
12.9.1. Exercise 5: Displaying an IO-Device Error ....................................................................... 12-29
12.9.2. Exercise 6: Determining the Error Time/Downtime........................................................... 12-30
12.9.3. Additional Exercise: Integrating Local Error Handling ...................................................... 12-31
"LOG2GEO" &
"DeviceStates"
CPU system
diagnostics
Task Description
In the new touchpanel screen "Diagnostics", it should be possible to call the status with all
diagnostic information of all available and diagnostics-capable devices (Controller, I/O-Devices as
well as modules).
Furthermore, in the case of an I/O-Device or module failure/error, this is to be detected through
the program and viewed on the "Conveyor" screen stating the station and module number.
Get_Name ModuleStates
LOG2GEO GEO2LOG
STEP 7 Software
Under the "Online & diagnostics" of a device, you can read out the general diagnostic status and
the diagnostics buffer with information about the error that occurred.
User Program
OB82 (Diagnostic error interrupt)
When there are errors on an I/O module, the "Diagnostic error interrupt-OB" is called if the
module is diagnostics-capable and the diagnostic interrupt is also activated in the hardware
configuration. The HW_ID of the defective module is then stored in the start information of the
OB.
OB83 (Pull or plug of modules)
If a configured module is removed or inserted, the "Pull or plug of modules-OB" is called. The
HW_ID of the failed or recovered module is then stored in the start information of the OB.
OB86 (Rack or station failure)
When a distributed I/O module fails or recovers, the "Rack or station failure-OB" is called. The
HW_ID of the failed or recovered module is then stored in the start information of the OB.
System Diagnostics
The CPU system diagnostics is an always activated alarm message function which automatically
generates the error messages of the activated alarm categories and sends them to all connected
HMI devices.
Web Service
All PROFINET-capable S7-CPUs provide a web presence for diagnostics which can be accessed
through a commercially available web browser (such as, Internet Explorer, Netscape, Mozilla
Firefox or Opera). These HTML pages offer access to device status and tags and enables the
execution of device functions.
1xR
1xR
Diagnostics Buffer
In the picture you can see an error message for an IO Device that has failed or been removed. In
this case, the digital output module in Slot 3 of the "ET 200SP" IO Device has failed.
System Diagnostics
The system diagnostics view offers an overview of all available devices in the system. You
navigate directly to the cause of the error and to the associated device and you have access to all
diagnostics-capable devices of the controller with which a connection is configured.
Use
Through the system diagnostics view, the highest possible level of detail is achievable. A precise
diagnosis is possible since all available data is displayed. The system state of the entire system is
available in one glance.
Advantages
Compared to the frequently used discrete alarm procedure, the system diagnostics offers the
following advantages:
• The system diagnostics is an active alarm procedure. If an alarm occurs, the CPU actively
sends an appropriate message to all connected operator panels and doesn’t wait until the
operator panels make inquiries.
• The process values always coincide exactly with the values at the time of the alarm. This is
not guaranteed in the discrete alarm procedure.
• The timestamp specifies exactly when an event occurs, even then, when the operator panel is
only connected later on.
Alarm Settings
In the "Common data" folder under "System diagnostic settings" you can define which alarm
categories belong to which alarm classes, whether they have to be acknowledged or not and
which are (to be) output with the help of the system diagnostics.
Start page
System diagnostics view
Level Lower
By double-clicking on a device, either the subordinate devices or the Details view is opened.
• Higher-level components (for example, PN interface)
→ subordinate components/modules are displayed
• Diagnostics buffer or module without subordinate components
→ Details view of the Diagnostics buffer entry or the module is displayed
Internet
Web Service
All S7-CPUs with PROFINET interface provide a web server for diagnostics. Assessments and
diagnostics are therefore possible over great distances. All that is needed is a commercially
available web browser (such as, Internet Explorer, Netscape, Mozilla Firefox or Opera). HTML
pages offer access to device status, tags, Trace recordings that can be found on the SMC etc. In
addition, the web service enables the execution of some functions, such as, carrying out firmware
updates. All these functions can be limited or enabled through user rights. As well, you can also
create your own HTML pages.
Security
Please bear in mind that you must protect the CPU against compromise through various
techniques, for example, through network access limitations and the use of firewalls.
The web server offers the following security features:
• Access via the safe transmission protocol HTTPS
• Configurable user authorizations via user lists
User administration
Select the
display language
Start Page
Through the navigation that appears on the left, different information can be queried.
Furthermore, the language can be selected.
Maximum of
three different
project
languages
Among other things, the entries of the diagnostic buffer can be read out with the help of the Web
server.
Furthermore, as can be seen in the picture, accesses to diverse diagnostics, the module
information, alarms, communication, the topology, to tags, watch tables released in the
parameterization of the CPU, Traces existing on the memory card, Log files as well as online
security and more are possible.
User Administration
Different users with different rights can be created.
The default setting for the user is "Everyone" and has the access level "Minimum". When
accessing the CPU Web server, this user can only read the Start page of the web server.
Users whose access level is "Administrative" can, on the other hand, query all information of the
CPU web server and also have – depending on the web site called – write permission.
Diagnostics
Display diagnostic buffer
Display CPU alarms
Task
You are to monitor the CPU alarm messages using the CPU-Display.
What to Do:
1. In STEP 7 in the "Common data" folder under "System diagnostic settings" check that all
categories are activated.
2. Provoke an alarm message using System diagnostics, for example, by pulling an ET 200SP-
DI module or by switching off the ET 200SP (Switch under the touchpanel).
Caution: So as not to damage the contacts of the ET 200SP modules, they must be pulled
out straight and must also be reinserted straight. A tilting damages them.
3. On the CPU, select the menu item "Diagnostics"
With the cursor keys and select the menu item "Diagnostics" and confirm the
selection with the OK button.
4. Look at the alarm message
With the cursor keys and select the menu item "Alarms".
Activate
Inspector
window
Task
The alarm messages of the CPU can be displayed with the help of the STEP 7 software. You are
to monitor these in the Inspector window.
What to Do
Caution: As already mentioned, pull the ET 200SP modules out straight and also reinsert
them straight since the contacts could otherwise be damaged.
What to Do
1. Insert a new touchpanel screen and rename it "Diagnostics".
2. There, configure a "System diagnostics view" using drag & drop (see picture).
3. As screen navigation, configure one button each which are to be used to call the screens
"Conveyor" and "Statistic". For this, use drag & drop to pull the touchpanel screens
"Conveyor" and "Statistic" one after the other from the Project view into the opened
"Diagnostics" screen. (Change the texts in the buttons, if you like.)
Also configure a project navigation in the other touchpanel screens in order to be able to
select the newly created "Diagnostics" screen.
4. Download the modified configuration into the touchpanel.
5. Check the new function by provoking an IO-Device error by pulling and inserting an ET
200SP module or switching off the ET 200SP.
6. Save your project.
Task:
The CPU Web server is to be activated and set up so that it can be used.
What to Do
1. Open the Properties of the CPU.
2. Under the item Web server → General, activate the Web server on the CPU,
3. Activate (enable) the Automatic update and set the Update interval.
4. Create a new user with the name ‘Admin’ who is given administrator rights (authorize for all
accesses).
5. Give the new user "Admin" a password.
6. Under the item Watch tables, select the already existing watch table "Conveyor".
7. Save, compile and download the modified hardware configuration.
8. Test the changes by calling the CPU Web server on the Field-PG using the Internet Explorer.
Asynchronous Errors
Asynchronous errors occur regardless of the program execution and accordingly cannot be
traced to a defined point in the program:
• for example, module failure
• for example, I/O fault (exceeding the measuring range, wire break)
These OBs are executed exactly twice:
1. When the error occurs (with start information that contains the identifier "incoming")
2. When the error goes (with start information that contains the identifier "outgoing")
Synchronous Errors
Synchronous errors occur through the program execution and accordingly can be traced to a
defined point in the program:
• for example, indirect access to a non-existent Array element
• for example, direct access to non-existent / defective I/O
These OBs are executed as often as the error occurs. If, for example, in a cyclically executed
block, there is an indirect access to a non-existent Array element, the error OB that is assigned to
the start event "Programming error" is also called and executed cyclically.
Byte
12 / 13 Year Month
14 / 15 Day Hours
Start
time
16 / 17 Minutes Seconds
Start Information
When the operating system calls organization blocks, the user is provided with a uniform system
start information in the local data stack. The start information or the pre-declared variables are
OB-specific and have a length of 20 bytes in total.
The start information as well as their absolute L-stack addresses is only completely available for
those OBs where the block attribute "Optimized block access" is not activated.
Notes
With the help of the instruction "RD_SINFO", the start information for OBs with "Optimized block
access" can also be read out.
The user can change and/or supplement the standard declaration table. However, you must
make sure that the dimensions or the memory space requirements and with that the initial (start)
addresses of the given variables are not changed. Accordingly, additional variables must only be
declared at the end, after the standard variables.
An explanation of the meanings of the individual variables can be found in the Help of the
respective organization block.
Time Error:
Max. allowed cycle time
exceeded once Exceeding the
System reaction with OB:RUN max. allowed cycle time, "Time error
interrupt" S7-1200/1500:
without OB: STOP delayed call (OB80) Can be set: 22 to 26
Max. allowed cycle time of a time OB
exceeded by more than double
System reaction with OB:STOP
"Pull or plug
Remove / Insert Interrupt S7-1200/1500:
Remove / Insert a module of modules"
System reaction w/o OB: RUN (OB83) Can be set: 2 to 26
"Rack or S7-1200/1500:
Rack Failure Failure of a DP-Slave
RUN station failure"
System reaction w/o OB: or an IO-Device (OB86) Can be set: 2 to 26
Asynchronous Errors
Asynchronous errors occur asynchronous (independent) to the program execution and
accordingly cannot be assigned to a defined program location.
INOUT parameter
With the "LOG2GEO" instruction, you can determine the geographic address, that is, the module
slot using the hardware identifier.
Accordingly, there is also the instruction "GEO2LOG" which in turn determines the hardware
identifier based on the geographic address.
MODE = 2 Query:
Has an IO-Device failed?
The instruction "DeviceStates" supplies status information for all modules in an IO-System.
Beyond that it displays whether the status information to be read applies to at least one of the IO-
Devices or DP-Slaves. The instruction can be called in the startup, in the cyclic program as well
as in the call environment of any other OB (such as, OB82 "Diagnostic error interrupt").
Parameter LADDR:
Hardware identifier of the PROFINET-IO or DP-Master system (system constant)
Parameter MODE
Through the parameter MODE you can select which status information is to be read.
• 1: IO-Devices/DP-Slaves are configured
• 2: IO-Devices/DP-Slaves faulty
• 3: IO-Devices/DP-Slaves deactivated
• 4: IO-Devices/DP-Slaves exist
• 5: IO-Devices/DP-Slaves, in which a problem has occurred (such as, "Maintenance
necessary")
Block
OB1 with
program Error
error OB
"Programming
A non-existent Array element error"
Programming error is indirectly accessed in
(OB121) According to
the program
(only S7-1500) the OB
that was
"IO access interrupted by
A defective or non-existent the error
I/O module is directly error"
Access error accessed in the program (OB122)
(only S7-1500)
Synchronous Errors
Synchronous errors occur synchronously (dependent) to the program execution and accordingly
can be assigned to a defined program location.
For a programming error, the OB "Programming error" (OB121) is called; for an access error, the
OB "IO access error" (OB122) is called.
If, in case of a programming error, OB121 is not available in the CPU, the CPU switches to the
STOP state.
12.8.6. Global Handling of Synchronous Errors with Error OBs: CPU Behavior
S7-1200
Programming error Access to non-existing DB no OB
Access error Direct access to non-existing exists
System reaction w/o OB: RUN or defective I/O module
"Programming
Programming error error"
Access to non-existing DB
System reaction w/o OB: STOP
(OB121)
Can be set:
S7-1500
2 to 26
"IO access
Access error Direct access to non-existing error"
System reaction w/o OB: RUN or defective I/O module
(OB122)
Synchronous Errors
Synchronous errors occur synchronously (dependent) to the program execution and accordingly
can be assigned to a defined program location.
Priority:
The priority of synchronous error OBs can be set from 2 to 26.
Error in the
OB / FC / FB
block
OB 121
GET_ OB 122
ERROR
If the "Handle errors within block" is programmed, then if this block is integrated in another
program, the adjustment of possibly already existing error OBs is not necessary. Thus the "local
error handling" contributes to designing the block as re-usable.
Local error handling with the "GET_ERROR" or "GET_ERROR_ID" block has to be programmed
separately in every block and has no impact on the calling and called blocks.
With the programming of the call of "GET_ERROR" or "GET_ERROR_ID", the block receives the
attribute "Handle errors within block".
If the call of "GET_ERROR" or "GET_ERROR_ID" is programmed after the instruction at which
an error could occur, GET_ERROR supplies an "ERROR_STRUCT" with a detailed error
description as a result, and "GET_ERROR_ID" supplies an error number whose meaning can be
read in the help. The information always refers to the first error that occurred since the last time
"GET_ERROR" or "GET_ERROR_ID" was executed.
Furthermore, the call of the associated error OB (OB121 or OB122) and an entry in the diagnostic
buffer is suppressed.
If the call of "GET_ERROR" or "GET_ERROR_ID" is programmed before the instruction at which
an error could occur, the blocks do not supply an error description and only the call of the
associated error OB (OB121 or OB122) and an entry in the diagnostic buffer is suppressed.
Task Description
As soon as an IO-Device has failed or an error has occurred on the IO-Device, the message
shown in the picture – with the device number of the IO-Device concerned and the slot number of
the module concerned – is to appear in the touchpanel screen "Conveyor".
The message indicating the device number and the slot number is already configured in the
touchpanel. All you have to do is create an S7 program which assigns status '1' to the tag
(variable) "DB_OP".IODevError for as long as the message is to be displayed, which assigns the
device number of the station concerned to the tag (variable) "DB_OP".IODeviceNo and which
assigns the slot number of the module concerned to the tag (variable) "DB_OP".Slot.
In addition, the error time/downtime of the modules or the IO-Device is to be determined.
Start information of
the OB
Temp variable
data type "GEOADDR"
Task
You are to create an S7 program which assigns status '1' to the tag (variable)
"DB_OP".IODevError, which assigns the device number of the station concerned to the tag
(variable) "DB_OP".IODeviceNo and which assigns the slot number of the module concerned to
the tag (variable) "DB_OP".Slot when there is a station error/failure or during pulling / inserting.
Note: The text with station and slot number (see picture on the previous page) displayed in the
touchpanel screen "Conveyor" is already configured and is displayed as long as the tag (variable)
"DB_OP".IODevError has status '1'.
What to Do
1. Create the block "OB_ Pull or plug of modules".
2. In this newly created OB, program the required functions (see picture).
− Use the input variable #Event_Class for determining whether the module has failed or was
re-inserted.
− Create the temporary variables #temp_Adress [GEOADDR] and #temp_RetVal [WORD]
− With the help of the instruction "LOG2GEO", determine the geographic address of the
module that causes the OB to be called.
− Read-out the values of the station number and module number from the structure of
#temp_Adress and write these in the tags (variables) "DB_OP".IODeviceNo and
"DB_OP".Slot
3. Create the block "OB_ Rack or station failure".
4. Also program the required functions in it.
Note: since the station failure is detected in this OB, the module number is always 0.
5. Download all program changes into the CPU.
6. Check the functions. Caution: once again, when you pull and insert the modules make sure
you do not damage them.
7. Save your project.
Task
The length of time that an IO-Device or a module is down is to be determined and stored in the
tag (variable) "DB_Conveyor".FailDuration.
What to Do
1. In "DB_Conveyor", create the tags (variables) "DeviceFail" [LDT] for storing when the failure
occurs, "DeviceReturn" [LDT] for storing the point in time when the device returns and
"FailDuration" [LTime] for storing how long the downtime is.
2. Expand the program of the relevant OB in such a way that the above-mentioned functions are
fulfilled.
3. With the PG, check the program function by means of a suitable Watch table or by monitoring
"DB_Conveyor" (see picture).
4. Save your project.
Solution Hints:
In order to recognize whether the error or the failure occurs or is eliminated, use the appropriate
Input parameter in optimized OBs or for non-optimized OBs, the appropriate Start information in
the temporary variables (for this, see the Help).
For determining when the failure occurs and the point in time when the device returns, use the
"Extended instruction" "RD_SYS_T" or "RD_LOC_T" and for calculating how long the slave
downtime is, the instruction "T_DIFF".
Task
In "OB_Cyclic interrupt_1", you are to program an access to a non-existing data block (as shown
in the picture) and test the system reaction without and with local error handling.
What to Do
1. In "OB_ Cyclic interrupt_1", program an access to a non-existing data block as shown in the
picture (without NW4: get error locally).
2. Download the modified block into the CPU.
3. Perform a CPU restart, by switching the CPU mode selector switch to STOP and then back to
RUN.
5. In "OB_Cyclic interrupt_1", after the access to the non-existing data block, program a new
network with local error handling. For this, insert a new network and call the instruction
GET_ERROR_ID (you will find the instruction in "Basic instructions -> Program control
operations"). Pass the instruction a local, temporary variable at the Output ID.
6. Download the extended block into the CPU and perform a restart.
7. The CPU should now stay in RUN in spite of programming errors. Open "OB_Cyclic
interrupt_1" and activate the function "Monitor block".
8. At the Output ID of the instruction, an Error-ID is output. Read about its meaning in the online
help (select instruction -> F1).