0% found this document useful (0 votes)
132 views32 pages

TIA PRO2 12 SystemDiag Error OBs

The document covers system diagnostics and error handling in the SIMATIC TIA Portal S7-1500 programming environment. It details the functionalities of CPU system diagnostics, including error detection, diagnostics via web server, and programming diagnostic functions. Additionally, it provides exercises to implement and configure these diagnostic features effectively.

Uploaded by

adamraz
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)
132 views32 pages

TIA PRO2 12 SystemDiag Error OBs

The document covers system diagnostics and error handling in the SIMATIC TIA Portal S7-1500 programming environment. It details the functionalities of CPU system diagnostics, including error detection, diagnostics via web server, and programming diagnostic functions. Additionally, it provides exercises to implement and configure these diagnostic features effectively.

Uploaded by

adamraz
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

SIMATIC TIA Portal S7-1500 Programming 2

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

TIA-PRO2 - System Diagnostics and Error Handling


Training Document V15.01.00 12-1
SIMATIC TIA Portal S7-1500 Programming 2

12. System Diagnostics and Error Handling

At the end of the chapter the participant will ...

... be able to explain the function of system diagnostics

… be familiar with and be able to configure the function


CPU system diagnostics

… be able to use the CPU web server for diagnostics

… be able to program diagnostic functions in the S7 program

TIA-PRO2 - System Diagnostics and Error Handling


12-2 Training Document V15.01.00
SIMATIC TIA Portal S7-1500 Programming 2

12.1. Task Description: Displaying an I/O-Device Failure on the


Touchpanel

"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.

TIA-PRO2 - System Diagnostics and Error Handling


Training Document V15.01.00 12-3
SIMATIC TIA Portal S7-1500 Programming 2

12.2. Functional Principle of the CPU System Diagnostics

CPU diagnostics detects CPU I/O module


a system error
CPU diagnostics detects Diagnostic Diagnostics-
errors in the user program interrupt capable module
detects an
error and
generates a
diagnostic
Error Diagnostic interrupt
OB buffer

Standard Reaction of the CPU when it detects an Error


If the CPU’s operating system detects an error, this error is entered in the diagnostic buffer of the
CPU and the error OB with the associated start event is called. In this OB program, the user has
the opportunity to program a CPU reaction to the error that occurred (switch CPU to STOP, send
message etc.). After the error OB is executed, the execution of the user program resumes at the
point of interruption. If no OB is assigned to the event, the program continues without interruption.
Exception: With a programming error, the CPU goes into the STOP state if there is no error OB.
Caution:
The operating system does not analyze whether the error handling (programmed error OB) really
takes care of the triggering error. For that reason, particular care has to be taken when
programming an error handling so that no dangerous system states result in case of a
failure. If required, the CPU can be sent into a programmed STOP through the use of the
function "STP". (Task Card Instructions → Basic Instructions → Program control… → Runtime
control).

TIA-PRO2 - System Diagnostics and Error Handling


12-4 Training Document V15.01.00
SIMATIC TIA Portal S7-1500 Programming 2

12.3. Overview: Diagnostics - Possibilities

Diagnostic possibilities System diagnostics


Web Service
of the CPU

Visual check of LEDs / Display PG: STEP 7 software User program

Display (S7-1500) Start info Start info Start info


LEDs on the Online & Diagnostics
and LEDs on
IO-Device Diagnostic buffer / status "Diagnostic "Pull or plug of "Rack or station
the IO-Controller error Int" (OB82) modules" (OB83) failure" (OB86)
Diagnostic Pull/plug Station
interrupt module failure

Extended instructions -> Diagnostics/Addressing


Get_IM_Data DeviceStates

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.

TIA-PRO2 - System Diagnostics and Error Handling


Training Document V15.01.00 12-5
SIMATIC TIA Portal S7-1500 Programming 2

12.4. Diagnostics using the PG with STEP 7

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.

Online & Diagnostics


With an existing online connection, you can recognize the failed or faulty devices by the red
symbols in the Project tree (not shown in the picture) and in the "Hardware and Network editor"
both in the Network view and in the Device view.
By activating the "Online & diagnostics" function, further information about the failed device /
module can be queried.

TIA-PRO2 - System Diagnostics and Error Handling


12-6 Training Document V15.01.00
SIMATIC TIA Portal S7-1500 Programming 2

12.5. CPU System Diagnostics

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.

TIA-PRO2 - System Diagnostics and Error Handling


Training Document V15.01.00 12-7
SIMATIC TIA Portal S7-1500 Programming 2

12.5.1. CPU System Diagnostics: Functional Principle

CPU System Diagnostics


The CPU system diagnostics is integrated in the firmware of the CPU S7-1500 and works
independent of the cyclic user program. Therefore, it is also available when the CPU is in the
STOP state.
1. If a device or a module detects an error, it signals the CPU this with an interrupt signal.
2. Detected faults are immediately signaled to the higher-level HMI devices, the Webserver and
the Display of the CPU S7-1500. In that way, the system diagnostics is always consistent with
the actual system state.
All clients of a system are provided with diagnostic information via a uniform mechanism.
Regardless of the display medium, the same system diagnostic information is used.

TIA-PRO2 - System Diagnostics and Error Handling


12-8 Training Document V15.01.00
SIMATIC TIA Portal S7-1500 Programming 2

12.5.2. Activating/Parameterizing CPU System Diagnostics

The output of individual alarm


categories can be activated or Always active
deactivated in the System
diagnostic settings.

CPU System Diagnostics


The system diagnostics is always activated and cannot be deactivated.

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.

TIA-PRO2 - System Diagnostics and Error Handling


Training Document V15.01.00 12-9
SIMATIC TIA Portal S7-1500 Programming 2

12.5.3. Displaying System Diagnostics Alarms on the HMI Device with


"System Diagnostics View"

Start page
System diagnostics view

Diagnostic buffer of the CPU


Module status
Level lower/back
→ access of selected module
→ view

View System Diagnostics


This tabular view shows all available devices of one level. Symbols in the first column give
information about the current status of the device.

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

Splitting the View in the System Diagnostics View


The system diagnostics view also offers a split view of the display. In that way, associated details
can immediately be seen in the lower area of the display.

TIA-PRO2 - System Diagnostics and Error Handling


12-10 Training Document V15.01.00
SIMATIC TIA Portal S7-1500 Programming 2

12.6. Diagnostics with the CPU Web Server

Internet

• Standard HTML pages of the module can be


accessed using a commercially available web
browser
→ Easy access to diagnostic data of the
module using standard tools

• Enable the accessing of


- Device status
- Diagnostic information
- Variable (tag) values
- etc.

• Provide the execution of


some device functions

• With operator panels,


activation of remote
maintenance possible

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

TIA-PRO2 - System Diagnostics and Error Handling


Training Document V15.01.00 12-11
SIMATIC TIA Portal S7-1500 Programming 2

12.6.1. Accessing the Web Service

The address in the web browser is the IP address of the CPU.


A general welcome page then appears.
After leaving the Welcome page “Intro”, you get to the “Start page”.

Unique characteristic for access via Pocket-PC or PDA:


IP address of the CPU followed by /basic (for example, http://192.168.111.100/basic)

TIA-PRO2 - System Diagnostics and Error Handling


12-12 Training Document V15.01.00
SIMATIC TIA Portal S7-1500 Programming 2

12.6.2. Web Server: "Start Page"

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.

Multilingual Support of Alarm Texts


If several project languages are activated in the project, then the parameterization of the interface
languages in the CPU apply here. A maximum of 3 languages can be selected and can be
assigned to the available interface languages for CPU-Display and Web Server.

Setting the Project Languages that are downloaded to the CPU:

Maximum of
three different
project
languages

TIA-PRO2 - System Diagnostics and Error Handling


Training Document V15.01.00 12-13
SIMATIC TIA Portal S7-1500 Programming 2

12.6.3. Web Server: "Diagnostic Buffer"

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.

TIA-PRO2 - System Diagnostics and Error Handling


12-14 Training Document V15.01.00
SIMATIC TIA Portal S7-1500 Programming 2

12.6.4. Parameterizing the CPU Web Server

Web Server Activation


The server is activated, as shown in the picture, via the CPU Settings.

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.

TIA-PRO2 - System Diagnostics and Error Handling


Training Document V15.01.00 12-15
SIMATIC TIA Portal S7-1500 Programming 2

12.7. Exercise 1: Displaying System Diagnostics Alarms on the CPU-


Display and in STEP 7

The alarms can also be viewed on the CPU-Display.

Main menu item:

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".

With you get back to the main menu.

Multilingual Support of Alarm Texts


If several project languages are activated in the project, then the parameterization of the interface
languages in the CPU also applies here.
A maximum of 3 languages can be selected and can be assigned to the available interface
languages for CPU-Display and Web Server.

TIA-PRO2 - System Diagnostics and Error Handling


12-16 Training Document V15.01.00
SIMATIC TIA Portal S7-1500 Programming 2

12.7.1. Exercise 2: Displaying System Diagnostics Alarms in STEP 7

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

1. Select the CPU and establish an online connection using .


2. The receiving of sent alarms must be activated in STEP 7. For this, activate the function
"Receive alarms" via the context menu of the CPU, as shown in the picture.
3. 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). The alarm display
occurs in the Inspector window in the "Diagnostics"/"Alarm display" tabs.

Caution: As already mentioned, pull the ET 200SP modules out straight and also reinsert
them straight since the contacts could otherwise be damaged.

4. Terminate the online connection. .

TIA-PRO2 - System Diagnostics and Error Handling


Training Document V15.01.00 12-17
SIMATIC TIA Portal S7-1500 Programming 2

12.7.2. Exercise 3: Viewing System Diagnostics on the HMI Device

Task: Displaying and Viewing System Diagnostics on the HMI Device


The information of the CPU system diagnostics is to be displayed/viewed on the touchpanel with
the Control "System-diagnostics" which is prepared for this.

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.

TIA-PRO2 - System Diagnostics and Error Handling


12-18 Training Document V15.01.00
SIMATIC TIA Portal S7-1500 Programming 2

12.7.3. Exercise 4: Activating and Parameterizing the Web Server

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.

TIA-PRO2 - System Diagnostics and Error Handling


Training Document V15.01.00 12-19
SIMATIC TIA Portal S7-1500 Programming 2

12.8. Diagnostics using the S7 Program

CPU detects an error


SF

Running user program is interrupted and the associated error OB is called

Asynchronous error Synchronous error


e.g.: “Rack or station failure” e.g.: “Programming error”
Start information Start information

Error OB is executed twice: Error OB is executed as often as


the error occurs.
1. Error occurs
(incoming event)
2. Error goes
(outgoing event)

The operating system supplies the OBs with "start information",


which also contains a description of the error

Standard Reaction of the CPU when it detects an Error


If the CPU’s operating system detects an error, this error is entered in the diagnostic buffer of the
CPU and the error OB with the associated start event is called. In this OB program, the user has
the opportunity to program a CPU reaction to the error that occurred (switch CPU to STOP, send
message etc.)

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.

TIA-PRO2 - System Diagnostics and Error Handling


12-20 Training Document V15.01.00
SIMATIC TIA Portal S7-1500 Programming 2

12.8.1. Start Information of the "Non-optimized" Error Organization Blocks

Byte

0/1 Event class and ID Error code Management


Structure of the information
2/3 Priority class OB No.
information read
out with
"RD_SINFO" 4/5 Error info (such as, block type in which the error occurred)
when
actual parameters
are of the data
6/7 Error info (such as, address at which the error occurred)
Error
type information
"SI_Classic" 8/9 Error info (such as, block number of the faulty block)

10 / 11 Error info (such as, relative address of the instruction responsible)

12 / 13 Year Month

14 / 15 Day Hours
Start
time
16 / 17 Minutes Seconds

18 / 19 1/10 Second, 1/100 Second 1 /1000 Second, Weekday

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.

Access to Start Information


Since the start information variables are supplied with defined values by the operating system
when the OB is called, the user program can read them without them having been written to
beforehand. The access to the variables can be symbolic or absolute whereby the symbolic
access is recommended for reasons of program readability and the avoidance of addressing
errors.

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.

TIA-PRO2 - System Diagnostics and Error Handling


Training Document V15.01.00 12-21
SIMATIC TIA Portal S7-1500 Programming 2

12.8.2. Global Error Handling with Asynchronous Error OBs

Type of Error Example Error OB Priority

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

Diagnostic Interrupt Wire break at diagnostics-capable "Diagnostic S7-1200/1500:


RUN module, power supply error error Int."
System reaction w/o OB: (OB82) Can be set: 2 to 26

"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

All events lead to an entry in the diagnostics buffer!

Asynchronous Errors
Asynchronous errors occur asynchronous (independent) to the program execution and
accordingly cannot be assigned to a defined program location.

Time Error Interrupt


They occur when the current cycle time exceeds the cycle monitoring time set in the device
configuration.

Diagnostic Error Interrupt


They are triggered by diagnostics-capable modules, such as, analog modules in case of a fault
(for example, wire break).

Pull or Plug of Modules


These interrupts are triggered when modules are removed or inserted. When a module is
inserted, the operating system checks whether the correct module type was used. With this
function, it is possible to remove/insert modules while the system is running.

Rack or Station Failure


This failure is detected when a rack, a subnet or a station for distributed IO fails.

TIA-PRO2 - System Diagnostics and Error Handling


12-22 Training Document V15.01.00
SIMATIC TIA Portal S7-1500 Programming 2

12.8.3. Determining the Geographic Address (Module Slot) using "LOG2GEO"

Address of the module that lead to


the call of the error OB

System data type "GEOADDR"


(Structure of the geographic address)

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.

System Data Type "GEOADDR" (Geographic Address)


The GEOADDR system data type contains the geographic address of a module, that is, the slot
information.
The geographic address is composed of the ID of the PROFINET-IO system or DP-Master
system, the device / station number, the slot number as well as the submodule number (for
PROFINET-IO if a submodule is used).

Structure of the Data Type "GEOADDR"


HWTYPE: 1 = IO-System (PROFINET/PROFIBUS), 2 = IO-Device / DP-Slave,
3 = rack, 4 = module and 5 = submodule
AREA: 0 = central module; 1 = PROFINET IO; 2 = PROFIBUS DP and 3 = AS-i
IOSYSTEM: Number of the PROFINET IO-System (0=central device in the rack)
STATION: Number of the rack, if area identifier AREA = 0; station number, if area identifier
AREA > 0.
SLOT: Slot number
SUBSLOT: Number of the submodule. (If no submodule exists or can be inserted, this
parameter has the value "0".)

TIA-PRO2 - System Diagnostics and Error Handling


Training Document V15.01.00 12-23
SIMATIC TIA Portal S7-1500 Programming 2

12.8.4. "DeviceStates": Reading the Module Status Information in an IO-System

MODE = 2 Query:
Has an IO-Device failed?

BOOL or ARRAY [0..n] of


BOOL

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")

Parameter STATE (BOOL or Array[0..n] of BOOL)


If the status selected via MODE applies to an IO-Device/DP-Slave, the following bits are set to "1"
at parameter STATE:
• Bit 0 = 1: Group display. Bit n of at least one IO-Device/DP-Slave was set to "1".
• Bit n = 1: The status selected via MODE applies to the IO-Device/DP-Slave.
• For a PROFINET-IO System, Bit n corresponds to the device number of the respective IO-
Device (see Properties of the PROFINET interface in the Device view and Network view)
• For a PROFIBUS-DP System, Bit n corresponds to the PROFIBUS address of the DP-Slave
(see Properties of the DP-Slave in the Device view and Network view)

TIA-PRO2 - System Diagnostics and Error Handling


12-24 Training Document V15.01.00
SIMATIC TIA Portal S7-1500 Programming 2

12.8.5. Global Handling of Synchronous Errors with Error OBs: Principle

Block
OB1 with
program Error
error OB

Type of Error Example OB Priority

"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.

TIA-PRO2 - System Diagnostics and Error Handling


Training Document V15.01.00 12-25
SIMATIC TIA Portal S7-1500 Programming 2

12.8.6. Global Handling of Synchronous Errors with Error OBs: CPU Behavior

Type of Error Example OB Priority

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)

All errors lead to an entry in the diagnostic buffer!

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.

TIA-PRO2 - System Diagnostics and Error Handling


12-26 Training Document V15.01.00
SIMATIC TIA Portal S7-1500 Programming 2

12.8.7. Local Handling of Synchronous Errors

Error in the
OB / FC / FB
block
OB 121
GET_ OB 122
ERROR

GET_ERROR or no OB call, no entry


GET_ERR_ID programmed in diagnostic buffer
in the block

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.

Advantages of Local Error Handling (Handle errors within block):


• With the help of the error information, a reaction to the error that occurred can be
programmed in the program block.
• Programmed error evaluations and reactions do not interrupt the program cycle.
• The system performance is not unnecessarily strained by the local error handling. If no errors
occur, programmed error evaluations and reactions are not executed.

TIA-PRO2 - System Diagnostics and Error Handling


Training Document V15.01.00 12-27
SIMATIC TIA Portal S7-1500 Programming 2

12.9. Task Description: Displaying an IO-Device Error


and Time-of-day Synchronization with the CPU

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.

TIA-PRO2 - System Diagnostics and Error Handling


12-28 Training Document V15.01.00
SIMATIC TIA Portal S7-1500 Programming 2

12.9.1. Exercise 5: Displaying an IO-Device Error

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.

TIA-PRO2 - System Diagnostics and Error Handling


Training Document V15.01.00 12-29
SIMATIC TIA Portal S7-1500 Programming 2

12.9.2. Exercise 6: Determining the Error Time/Downtime

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".

TIA-PRO2 - System Diagnostics and Error Handling


12-30 Training Document V15.01.00
SIMATIC TIA Portal S7-1500 Programming 2

12.9.3. Additional Exercise: Integrating Local Error Handling

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.

Exercise is continued on the next page

TIA-PRO2 - System Diagnostics and Error Handling


Training Document V15.01.00 12-31
SIMATIC TIA Portal S7-1500 Programming 2

4. Read out the diagnostic buffer. Proceed as follows:

− Select your S7-1500 station


− Go Online
− Start "Online & diagnostics"
− There, select the diagnostic buffer in the "Diagnostics" tab.

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).

Optional – Local Error Handling with "GET_ERROR":


Replace the instruction "GET_ERR_ID" with the instruction "GET_ERROR". Save the error
information in a newly created global data block ("DB_Get_Error_Info") and evaluate it. For more
information and for evaluation, use the Help.
Note: In a global data block, create a variable of the data type "ErrorStruct" and use it as the
actual parameter for the formal parameter "ERROR".

Correcting the Project


1. Delete the access to the non-existing data block and once again specify the correct actual
parameter.
2. Compile, download and save your project.

TIA-PRO2 - System Diagnostics and Error Handling


12-32 Training Document V15.01.00

You might also like