Download as pdf or txt
Download as pdf or txt
You are on page 1of 490

Private copy for Recep Yigit Samsa, rysamsa@borusan.

com

TIA-PRO2
ry ry
sa sa

SITRAIN
m m

Academy
sa sa
@ @

SIMATIC Programming 2 in the TIA Portal


Digital Industry
bo bo
ru ru
sa san
n. .c
co
m om
om
.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Register
m
sa

1. Training Devices
ry

2. Commissioning - S7-1500

3. Commissioning - Distributed I/O

4. PLC Tags

5. Commissioning - HMI
m
6. Program Design Methods
co

7. Analog Value Processing and Arithmetic


n.

8. FCs, FBs and Multiple Instances


sa

9. Complex Data and Addressing


ru

10. Optimized Blocks


bo

11. HMI Alarm Messages

12. System Diagnostics and Error OBs


@

13. Commissioning a Drive with Startdrive and Technology Object


sa

14. Introduction to SCL


m

15. Appendix: Introduction to S7-GRAPH


sa

16. Appendix: Introduction to STL


ry

17. Training and Support

Course version V18.00.00


om
.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

This document was produced for training purposes. Siemens assumes no responsibility for its
m

contents.

The reproduction, transmission, communication or use exploitation of this document or its


sa

contents is not permitted without express written consent authority. Offenders will be liable
to damages. Non-compliances with this prohibition make the offender inter alia liable for
damages.
ry

© Siemens 2023. All rights, including particularly the rights created by to file a by patent
and/or other industrial property right application and/or cause the patent and/or other
industrial property right to be granted grant or registration of a utility model or design, are
reserved.

Published by: Siemens AG, Digital Industries, Customer Services, P.O. Box 31 80, 91050
Erlangen, Germany

For the US published by: Siemens Industry Inc., 100 Technology Drive, Alpharetta, GA 30005,
m
United States
co

SITRAIN courses on the internet: www.siemens.com/sitrain


n.
sa
ru
bo
@
sa
m
sa
ry
SIMATIC Programming 2 in the TIA Portal

om
1 Training Device

.c
an
1.1LearningLearning
objectives objectives

s
• You know how to use the TIA Portal Information Center

ru
• You know the principle setup of an S7-1500

bo
• You know the configuration of the training area

• You know the wiring of the training area components

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

om
c
n.
sa
ru
bo
@
sa
m
sa
ry

1-1 SITRAIN
SIMATIC Programming 2 in the TIA Portal
TIA1.2
Portal Information Center
TIA Portal Information Center

om
https://support.industry.siemens.com

.c
Entry ID 65601780

s an
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

By entering the Product/Article No. (Entry ID) 65601780, you arrive at the start page "TIA Portal
sa

- An Overview of the Most Important Documents and Links".


ry

Here you will find all important documents and links about TIA Portal as well as the S7-1200
and S7-1500 controllers.

In addition, you can get to the "TIA Portal Information Center". Through it you can also get to all
important links and information.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

1-2 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Overview
1.3 of Controller
Overview of Controllers

.c
Engineered with TIA Portal

an
System performancee

Advanced Controller
Software

s
SIMATIC S7-1500
Controller

ru
SIMATIC

bo
S7-1500
Distributed
Controller

Basic Controller
SIMATIC S7-1200
@ SIMATIC
ET 200
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Application complexity
sa

Depending on the complexity, different controllers from S7-1200 to S7-1500 can be used.
ry

c om
n.
sa
ru
bo
@
sa
m
sa
ry

1-3 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
1.4 SIMATIC S7-1500: Modular Controller for the Mid to Upper
SIMATIC S7-1500: Modular Controller
Performance Range for the Mid to Upper Performance Range

.c
s an
New design

ru
CPU 1511C and
CPU 1512C

bo
article number:
6ES751x-1CK01-0AB0

as well as
@ CPU 1511(F) and
CPU 1513(F)
sa
(article number:
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

6ES751x-xyy02-0AB0)
m
sa

Highlights of the SIMATIC S7-1500 System


ry

• Highest performance of the entire system (terminal-terminal)


− High performance program execution in the CPU
− High performance backplane bus
− PROFINET interface with PROFINET IO IRT on every CPU
− Automatically activated system diagnostics, right down to the
IO channel
om
• Trace for all CPU tags
c
a n.

• CPU - Display for:


us

− Access to MLFB (article number), FW version, and serial number


− Commissioning (e.g. Setting the IP address, station name)
r

− Backup/Restore
bo

− Diagnostics
@

• Simplified programming through user-friendly instructions


sa
m
sa
ry

1-4 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
SIMATIC S7-1500: Modules
1.4.1 SIMATIC S7-1500: Modules

.c
an
Single-tier assembly max. 32 central modules in rack
Multi-tier distributed ET 200MP

s
ru
bo
PS/PM
@
CPU DI, DQ, PS
TM:
- Counting
...

- Position sensing
sa
(optional) AI, AQ new power
segment
CM/CP:
- Point-to-Point max. 2 per rack
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

for backplane bus supply of


m

(RS232, RS485)
- PROFIBUS subsequent I/O modules
- PROFINET
sa

Slot Rules
ry

• 1x PS/PM Slot 0
• 1x CPU in Slot 1
• As of Slot 2 any

Signal Modules
• Digital input modules: 24VDC, 230VAC
• Digital output modules: 24VDC, 230VAC
• Analog input modules: voltage, current, resistance, thermocouple
om
• Analog output modules: voltage, current

Communication Modules (CP - Communication Processor, CM - Communication Module)


.c

• Point-to-Point connection

an

PROFIBUS
• PROFINET
us

CPs and CMs are both communication modules.


CPs have, as a rule, somewhat more functionality than CMs (e.g. own web server,
firewall, or the like).
r
bo

Technology Modules (TM - Technology Module)


• Counting
@

• Position sensing
sa
m
sa
ry

1-5 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Power Supply
I/O modules in the central rack of the S7-1500 require a system power supply via the backplane
bus (communication connection to the CPU) and a load power supply (input or output circuits for

.c
sensors/encoders and actuators).
• PM - Power Module → Load Power Supply

an
supplies modules with 24VDC for input and output circuits as well as sensors/encoders and
actuators

s
If the CPU is supplied 24V via a load power supply (PM), it supplies the system power

ru
supply of 12W for the first inserted I/O modules.
• PS - Power System → System Power Supply

bo
supplies S7-1500 modules in the central rack via the backplane bus
Each CPU offers a system power supply of 12W for the first inserted I/O modules.

required. @
Depending on the I/O modules used, further power segments have to be set up, as

A system power supply (PS) can also supply the load circuit for 24VDC modules in
sa
addition to the CPU.
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Power Supply and Power Segments of the I/O Modules


It is necessary to set up power segments in the central rack for larger configurations or
sa

configurations with greater I/O module power requirements (as a rule, when using CP, CM, TM).
A maximum of 3 power segments can be set up per rack (1xCPU segment plus 2 more).
ry

If the configuration includes additional power segments, additional system power supply
modules (PS) are inserted to the right next to the CPU. The CPU continues to control all
modules of the rack. Only the system power supply of the I/O modules is subdivided here.

Example of a Small S7-1500 Configuration om


c
a n.

Example of an S7-1500 Configuration with a 2nd. Power Segment


r us
bo
@
sa

Interface Modules for Expansion Rack


m

There are no plans for a central multi-tier assembly. An expansion can be realized using the
distributed ET 200MP I/O system.
sa
ry

1-6 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
SIMATIC
1.4.2 S7-1500: CPU-Display
SIMATIC → Menu and→Colors
S7-1500: CPU-Display Menu and Colors

.c
Main menu items and their meaning:

an
Overview (Info on: CPU, program protection, memory card, fail-safe (operation)…)

s
Diagnostics (alarms, diagnostic buffer, message display, watch tables, cycle time, current memory)

ru
Settings (addresses, date & time, operating mode, CPU Reset, unlock Display, Backup, FW update
…)

bo
Modules (status, MLFBs, version, information,… of individual modules)

@
Display (setting: brightness, language Display/diagnostic message,
standby,…, Display info: MLFB, version, …)
Colors of status information and their meaning:
sa
green RUN of CPU,
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

yellow STOP or CPU HOLD


m

red Error
white Connection setup or connection to CPU lost
sa

Depending on the current CPU state, the color on the Display varies.
ry

Additional Symbols in the Status Information

Password is configured but not entered

Password is configured and has been entered


m
An Alarm exists
co

A Force job is active on the CPU


n.
sa

F-ability activated. Safety operation active (for fail-safe CPUs)


With deactivated safety operation, the icon is greyed out.
ru

Fail-safe CPU (for fail-safe CPUs)


bo

S7-1500 Display Simulator


Under the link "TIA Portal Information Center > First steps > Getting Started > SIMATIC S7-
@

1500 and STEP 7 - Getting Started > Displays of the SIMATIC S7-1500 controller family" you
can test the S7-1500 display simulator as an online version or you can download it and test it
offline.
sa
m
sa
ry

1-7 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
SIMATICSIMATIC
1.4.3 S7-1200/1500: Memory Card
S7-1200/1500: Memory Card

.c
an
1 Serial number of the SIMATIC Memory Card (SMC)
2 Product version
3 Order number

s
4 Card size
Slide switch for write-protect (must not be write-protected)

ru
5

Written with:
• Commercially available SD card reader

bo
• Field PG
SIMATIC Memory Card in the S7-1200: SIMATIC Memory Card in the S7-1500:

@
• External load memory • Load memory
• Distribution of programs • Firmware update
• Firmware update • Documentation
• Documentation • Memory Card Binding
sa
• Memory Card Binding • Unlinked DBs
• Unlinked DBs • Archiving of data
• Module exchange without PG • Module exchange without PG
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Memory Card Binding – Copy Protection


The executability of the program can be bound to the serial number of the card.
ry

Load Memory
• S7-1500
This has no integrated load memory and therefore it is imperative that a card is inserted.
• S7-1200
This has an integrated load memory. Here, an inserted memory card can replace (expand)
the integrated load memory or the card can be used for program updates (distribution of
programs).

Distribution of Programs  only S7-1200


The use as Transfer card (card mode = "Transfer") is only supported by the S7-1200. Here, a
program can be downloaded into the CPU without a PG if a card is inserted.
m

Archiving of Data  only S7-1500


co

It is possible to archive process values on the card.


n.

The use of this functionality influences the operating life of the Memory Card
sa
ru
bo
@
sa
m
sa
ry

1-8 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Configuration
1.5 of the S7-1500 Training
Configuration of the Device
S7-1500 Training Device

.c
an
Slot No.

s
ru
bo
@
sa
Module: PM CPU DI 32 DO 32 AI 8
I/O Address:
m

0..3 0..3 10..25


Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Addresses to be parameterized
sa
ry

Addresses of the Central S7-1500 I/O Modules


Two digital 32-channel modules are available as central I/O. The assigned addresses are to
begin at Address = 0.
Since digital channels are also available on the distributed I/O, the analog module of the central
I/O is to be assigned Addresses starting at 10.
om
.c
an
r us
bo
@
sa
m
sa
ry

1-9 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Configuration
1.5.1 of the ET 200SP
Configuration of the Training
ET 200SP Device
Training Device

.c
Slot No.

s an
ru
Server module
(Bus termination module)

bo
Module:
I/O Address:
IM
@ DI8

4
DI8 DO16 AI4

6
AO4

4..5 30..37 30..37


sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Addresses of the Distributed ET 200SP I/O Modules


sa

Three digital modules are available as distributed I/O. These are to follow the central digital I/O
in the address space, with address assignments beginning at 4.
The analog modules are to be assigned Addresses starting at 30.
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

1-10 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Training Area Setup with S7-1500 (Classroom)
1.6 Training Area Setup with S7-1500 (CLASSROOM)

.c
an
Training case

s
ru
bo
Drive

@
Conveyor
model
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

Components of the Training Area with S7-1500


The training area for this course contains the following components:
• SIMATIC Field PG
• Training case with S7-1500, ET 200SP, touchpanel, operating elements (switches and slide
controls), and display elements (lights (LEDs) and voltage displays)
• Sinamics G120 drive
• Conveyor model
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

1-11 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Operating
1.6.1 and Display
Operating andElements
Displayof the Training
Elements Device
of the (Classroom)
Training Device (CLASSROOM)

.c
%Q2.3

an
%Q2.1 Switches LEDs
%Q2.2
%Q2.0
%I0.0 %Q0.0

s
%QW32
%I0.1 %Q0.1
TopLights (green, red)

ru
%QW34 %IW30/32 %QW30/32

0..12V

bo
%IW10
%I0.7 %Q0.7

@
%IW30

%IB0 %IW10/12
sa
%QB0/2 QW32 with short circuit QW30 to IW12 via
switch to ground wire break switch
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Operating Elements
sa

In addition to the touchpanel, separate operating elements are also available for operating the
system:
ry

• 8 switches
• 2 potentiometers for setting or simulating analog input signals
• Wire break switch that interrupts the connection of Channel 1 (%QW30) of the distributed
I/O analog output module with Channel 2 (%IW12) of the central I/O analog input module
• Short circuit switch that short-circuits Channel 2 (%QW32) of the distributed I/O analog
output module to ground

Display Elements
In addition to the touchpanel, separate display elements are also available for the visualization
m
of process information:
• 8 LEDs
co

• 2 digital voltage displays for displaying analog output signals


• On top of the training device there are, to the right and left, 2 LED bars "TopLights" (2x
n.

green, 2x red). These can be controlled by means of 4 digital outputs.


sa

Addressing
For the addressing shown in the picture, the relevant module address settings must be made in
ru

the device configuration.


bo
@
sa
m
sa
ry

1-12 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
1.6.2 Setup and Connection of the Conveyor Model to the Distributed I/O
Setup and Connection of the Conveyor Model to the Distributed I/O (Classroom)
(CLASSROOM)

.c
an
"conveyorIn".B_bay1 (%I4.5) ″conveyorOut".P_horn (%Q4.7)

"conveyorIn".B_bay2 (%I4.6)

s
"conveyorOut".K_right (%Q4.5) "conveyorIn".B_bay3 (%I4.7)

ru
"conveyorOut".K_left (%Q4.6) %IB 4
"conveyorIn“.B_BayLB (%I4.0)

bo
%QB 4

ET 200 DI/DO

@ (Back of case)

OFF button
sa
ON button

"conveyorOut".P_bay1 "conveyorOut".P_bay2 "conveyorOut".P_bay3 "conveyorOut".P_BayLB


m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

(%Q4.1) (%Q4.2) (%Q4.3) (%Q4.4)


"conveyorIn".S_bay1 "conveyorIn".S_bay2 "conveyorIn".S_bay3 "conveyorIn".S_BayLB
(%I4.1) (%I4.2) (%I4.3) (%I4.4)
sa
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

1-13 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Networking and IP Addresses of the Modules
1.6.3 Networking and IP Addresses of the Modules

.c
TP X1.1
X1.2

an
P2
CPU X1.1
192.168.111.121 PROFINET-IO interfaces
X1.2
for PG and Drive

s
ET200 X1.1
192.168.111.129 X1.2

ru
P1

bo
192.168.111.124

@
X1: 192.168.111.122
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Subnet 192.168.111.xxx
P1 P2
sa
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

1-14 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal

1.6.4 Training Area as Plant with Distribution Conveyor and Touchpanel


Training (CLASSROOM)
Area as Plant with Distribution Conveyor and Touchpanel (Classroom)

.c
s an
ru
Weight Speed
setting setting

bo
DI DO AI

PROFINET

@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Functional Description
ry

The distribution conveyor is used to transport parts and can be operated in the operating modes
Manual mode or Automatic mode, which can be set via the associated buttons on the
touchpanel.

Manual Mode, "P_operation" = Off


In this mode, the conveyor motor can be jogged to the right and to the left. This can be done
with the relevant buttons on the touchpanel.

Automatic Mode, "P_ operation" = On


In Automatic mode, parts are placed on the conveyor belt at the light barrier bay, weighed
(weight simulation via the left slider on the operator panel simulator) and, after pressing the bay
pushbutton, are transported to the next free Bay (1, 2 or 3), when a Bay is free and the weight is
m
within the permissible range. When a part reaches the bay, the indicator light flashes to indicate
that the part can be physically removed. After removing the part, a continuous light signals that
co

the bay is still occupied in memory. The Bay occupied memory may be cleared by pressing the
associated bay pushbutton.
n.

Every transport sequence is monitored for time. If it takes longer than six (6) seconds, there is a
fault and the conveyor motor is automatically switched off. Only after acknowledging the fault via
"S_acknowledge" or the "Error Acknowledge" button on the touchpanel, can a new transport
sa

sequence be started.
The transported parts are counted for each bay and the following data is determined and
ru

displayed: number of parts per bay; total number of parts; the utilization of the three (3) bays;
and the current weight of the parts at the respective bays, at the light barrier, and on the
bo

conveyor. Only after the operation has been switched off and subsequently switched on again is
the data deleted. The weight values of the parts at the bays are the only data maintained.
If none of the Bays are free or the weight of the part at the light barrier is too high, no part
@

transportation can be started. These statuses are output on the touchpanel as a message. An
I/O Device failure will also cause a message to be displayed.
The weight values of the parts are stored in a weight storage register. If the maximum quantity
sa

of data stored in the register is reached, it is no longer possible to make a bay free.
From the stored values, the statistical values – maximum weight, minimum weight, average
m

weight, and total weight of all parts – are determined and displayed. By means of the
touchpanel, the weight storage and the statistical values can be deleted.
sa
ry

1-15 SITRAIN
SIMATIC Programming 2 in the TIA Portal

Integrating the G120 Drive

om
With the help of a Technology Object, the G120 drive is controlled as if it would drive the
conveyor. The speed of the motor can be preset via the right slider on the operator panel
(simulator).

.c
s an
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m
sa
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

1-16 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Training Area
1.7 Setup with
Training AreaS7-1500
Setup(Online)
with S7-1500 (ONLINE)

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Components of the Training Area with S7-1500


The training area for this course contains the following components:
ry

• SIMATIC Field PG
• Training case with S7-1500, ET 200SP, touchpanel, operating elements (switches and slide
controls) and display elements (lights (LEDs) and voltage displays)
• Sinamics G120 drive
• Conveyor model
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

1-17 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Operating
1.7.1 and Display
Operating andElements
Displayof the Training
Elements Device
of the (Online)
Training Device (ONLINE)

.c
an
I4.4

s
Q0.1 Q4.4

ru
bo
Create package Q0.5

@
Q0.6
Q0.7
sa
Q0.0 IW10 QW32
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Operating Elements
In addition to the touchpanel, separate operating elements are also available for operating the
ry

system:
• 8 switches
• 2 potentiometers for setting or simulating analog input signals

Display Elements
In addition to the touchpanel, separate display elements are also available for the visualization
of process information:
• 8 LEDs
• 2 digital voltage displays for displaying analog output signals
• On top of the training device there are, to the right and left, 2 LED bars "TopLights" (2x
m
green, 2x red). These can be controlled by means of 4 digital outputs.
co

Addressing
For the addressing shown in the picture, the relevant module address settings must be made in
n.

the device configuration.


sa
ru
bo
@
sa
m
sa
ry

1-18 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
1.7.2 Setup and Connection of the Conveyor Model to the Distributed I/O
Setup and Connection of the Conveyor Model to the Distributed I/O (Online)
(ONLINE)

.c
an
″B_Bay1″ ″B_Bay2″ ″B_Bay3″
(I 4.5) (I 4.6) (I 4.7)

s
ru
″K_Right″ (Q 4.5)
″K_Left″ (Q 4.6)

bo
″S_Bay1″
(I 4.1)
@
″S_Bay2″
(I 4.2)
″S_Bay3″
(I 4.3)
sa
″P_Bay1″ ″P_Bay2″ ″P_Bay3″
(Q 4.1) (Q 4.2) (Q 4.3)
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

c om
n.
sa
ru
bo
@
sa
m
sa
ry

1-19 SITRAIN
SIMATIC Programming 2 in the TIA Portal

1.7.3 Training Area as Plant with Distribution Conveyor and Touchpanel


Training (ONLINE)
Area as Plant with Distribution Conveyor and Touchpanel (Online)

om
.c
an
Weight
setting

s
ru
DI DO AI

bo
PROFINET

@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

Functional Description
The distribution conveyor is used to transport parts and can be operated in the operating modes
sa

Manual mode and Automatic mode, which can be set via the associated buttons on the
touchpanel.
ry

Manual Mode, "P_operation" = Off


In this mode, the conveyor motor can be jogged to the right and to the left. This can be done
with the relevant buttons on the touchpanel.

Automatic Mode, "P_ operation" = On


m
In Automatic mode, parts are placed on the conveyor belt at the light barrier bay, weighed
(weight simulation via the left slider on the operator panel simulator) and, after pressing the bay
co

pushbutton, are transported to the next free Bay (1, 2 or 3), when a Bay is free and the weight is
within the permissible range. When a part reaches the bay, the indicator light flashes to indicate
n.

that the part can be physically removed. After removing the part, a continuous light signals that
the bay is still occupied in memory. The Bay occupied memory may be cleared by pressing the
sa

associated bay pushbutton.


Every transport sequence is monitored for time. If it takes longer than six (6) seconds, there is a
fault and the conveyor motor is automatically switched off. Only after acknowledging the fault via
ru

"S_acknowledge" or the "Error Acknowledge" button on the touchpanel, can a new transport
sequence be started.
bo

The transported parts are counted for each bay and the following data is determined and
displayed: number of parts per bay; total number of parts; the utilization of the three (3) bays;
and the current weight of the parts at the respective bays, at the light barrier, and on the
@

conveyor. Only after the operation has been switched off and subsequently switched on again is
the data deleted. The weight values of the parts at the bays are the only data maintained.
If none of the Bays are free or the weight of the part at the light barrier is too high, no part
sa

transportation can be started. These statuses are output on the touchpanel as a message. An
I/O Device failure will also cause a message to be displayed.
m

The weight values of the parts are stored in a weight storage register. If the maximum quantity
of data stored in the register is reached, it is no longer possible to make a bay free.
sa

From the stored values, the statistical values – maximum weight, minimum weight, average
weight, and total weight of all parts – are determined and displayed. By means of the
ry

touchpanel, the weight storage and the statistical values can be deleted.

1-20 SITRAIN
SIMATIC Programming 2 in the TIA Portal

1.8Menu Functions
Menu within the Amazon
Functions VE Lab
within the Amazon VE Lab

om
.c
an
App Start Activate Multiple Monitors

s
If several screens available
→ Move individual app(s) to

ru
another monitor

bo
Full Screen Mode

Upload/Download in/out of
Home/Temporary Folder
@ Task overview, if
necessary, switch
Upstream settings of Amazon
VE Lab
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Multiple Monitors
m
sa

A further task of the Amazon app is opened:


This can then be moved to an extended monitor for a running app (for example, insert Process
ry

Simulation Factory-IO).
All Amazon tasks are linked with one another so that even internal communication connections
are retained. om
c
an.
r us
bo
@
sa
m
sa
ry

1-21 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
1.8.1
VE Lab –VE Lab
Daily – Daily Routine
Routine

Course begin in the morning:

.c
• Start VE Lab
• Copy all folders and files from "Home Folder" into "Temporary Folder"

an
→ Key combination <CTRL>+<C> <CTRL>+<V>
→ Context menu

s
Course end in the evening:

ru
• Copy all folders and files from "Temporary Folder" into the Home Folder
• In "Temporary Folder", create a Zip file from all files
• Download the ZIP file to a local PC

bo
@ Click Zip file or context menu
sa
Course end in the evening:
• Logout from VE Lab
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

After maximum 2 hours inactivity, the VE Lab session is automatically ended.


ry

With the Logout from VELab, the directory "Temporary Folder" is also deleted.
For that reason, the project must first be backed up in the directory "Home Folder"...
• If a break > 2 hours exists, an Auto Logout from the system then occurs
• When the course day comes to an end and you logout from VE Lab

Copying between "Home Folder" and "Temporary Folder"


The VE LabE Explorer works just like the Windows Explorer.
→ Key combinations for selecting and Copy/Paste
om
or context menu (right mouse button)
→ "Send to" with compression function
User interface language is English.
.c

Download (external backup to your own PC)


an

This is only supported for single files.


If a project is to be backed up on your own PC, you must first compress it in the VE Lab
Explorer so that one singular ZIP file results for the entire project.
us

For the download, the "My Files" Explorer must then be used.

r

A click on the file name of a single file


bo

automatically starts the download to the local PC in the Standard Download directory of
Windows

• A click on of a single file


@

opens the additional menu that contains the function "Download".


sa
m
sa
ry

1-22 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Process Process
1.8.2 Simulation – Basic Settings
Simulation – Basic Settings

om
.c
an
Basic settings of the simulation:

s
• e.g. Interface language

ru
bo
Driver settings for PLCSIM connection:
• Driver "Siemens S7-PLCSIM"
@ • Model "S7-1500"
• Simulation "Auto connect"
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

What to Do
m

1. Start Factory IO: Factory IO can be started with a Scene file, with the ending .factoryio.
sa

2. Basic settings of the simulation


Via the "" at "WELCOME" you get to the ‘empty’ hall
In the menu FILE > OPTIONS > General, you can set the language.
ry


om
You get back with " OPTIONS".
3. Driver Settings
c

FILE > DRIVER >


a n.
r us
bo
@

Select PLCSIM, S7-1500 and "Auto connect".


sa

You get back via " Configuration" and " DRIVER".

Note:
m

These settings are automatically saved and are set for all scenes.
sa
ry

1-23 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Functions
1.8.3 within thewithin
Functions Process
theSimulation
Process Simulation

.c
Orbit Camera Flight Camera

s an
ru
VIEW

bo
@
Keyboard Navigation
sa
VIEW
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Cameras
A double-click on a stored camera position sets this view.
ry

Start view: with Orbit Camera for camera navigation

Camera Navigation

This function is also


located on the mouse
wheel
m
co

This control has the following functions:



n.

Zoom
• Turn camera to the right/left/up/down
sa

• Move camera to the right/left/forward/backward


The assignment of the above-mentioned arrow button functions and +/- depends on the
ru
bo

currently set camera type (Orbit or Flight Camera).


@
sa
m
sa
ry

1-24 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
1.9 Exercise 1: Starting the Virtual Training Area and Testing
Exercisethe
1: Starting
Access the Virtual
DataTraining Area and Testing the Access Data

.c
an
Cloud

s
ru
Link to VE Lab
Access data

bo
Engineering

Engineering Software

@ Internet
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
You are to start the virtual training area, log on, and start the TIA Portal as application.
ry

What to Do
Start the virtual training area (VE Lab - Virtual Exercise Laboratory)

Along with the invitation to the course, you have received an access link and access data (sign-
up email address with a temporary password).

Start the Cloud application and log on with this.


The recommended browser is Google Chrome.
om
Pay attention to the precise notation of the email address (upper/lower case and special
characters).
With the first logon you are prompted to select a personal password.
.c

First start the app "TIA Portal Vx" .


an

The start of the test environment can take several minutes...


The start is completed when this menu is at the top left:
r us
bo
@
sa
m
sa
ry

1-25 SITRAIN
SIMATIC Programming 2 in the TIA Portal
ExerciseExercise
1.9.1 2: Preparing the Virtual the
2: Preparing Training Area
Virtual Training Area

om
.c
Cloud

an
Load archive in
Temporary Folder

s
Extract (unzip)
archive and copy in

ru
Home Folder

VE Lab Explorer

bo
Internet
@
Load course archive, extract it, and copy it
only is persistent
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Task
m

You are to prepare the virtual training area for usage.


sa

You have two storage directories in the VE Lab:

• → persistent Cloud storage but too slow as working area


ry

 after starting VE Lab, copy the contents into "Temporary Files"

• → volatile, but fast as working area


 before exiting VE Lab, backup the contents to "Home Folder"

What to Do
m
The VE Lab was started in Exercise 1.
co

1. Copy the course archive into the virtual training area


n.

A ZIP file that contains the course archive data is located in the Sitrain web under
MyCourses. Copy this into the virtual training area:
sa

Start "My Files"


ru
bo
@
sa
m
sa
ry

1-26 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Select the "Home Folder"

.c
s an
ru
bo
Choose "Upload Files"
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

Select your ZIP archive loaded from MyCourses and upload it.

2. Extract the work data


om
Unzip the archive and copy this into the Home Folder with the explorer:
.c
an
r us
bo
@
sa
m
sa
ry

1-27 SITRAIN
SIMATIC Programming 2 in the TIA Portal

2 Hardware Commissioning S7-1500

om
.c
2.1LearningLearning
objectives objectives

an
• You know how to establish an online connection to the controller

s
• You know how to create a hardware station and assign parameters to it

ru
• You can read-in the ACTUAL (online) configuration

bo
• You know how to make settings and read-out information using the display

@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m
sa
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-1 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
2.2 Task Description: Hardware Commissioning: Commissioning
Task Description: Hardware Commissioning of the S7-1500
the S7-1500

.c
s an
ru
bo
DI DO AI

PROFINET
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task Description
ry

You are to commission the hardware components of the S7-1500 Station central module.

Note
The ET 200SP distributed I/O, the TP700 Comfort touch panel and the G120 drive, which are
also part of the training area, will be commissioned later.om
c
n.
sa
ru
bo
@
sa
m
sa
ry

2-2 SITRAIN
SIMATIC Programming 2 in the TIA Portal

Project View
2.3 Project View

om
.c
Task Cards
Menu bar and toolbar (tools)

an
Project

s
navigation Working area
(Project tree)

ru
bo
Reference
projects

Details view
@ Inspector window
- Properties
Group
- Info output
Task bar opened editors
- Diagnostics
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
(opened editors)
m

Project Navigation (Tree)


The Project tree contains all components and project data of an automation solution. All
sa

components can be opened from here.


ry

Working Area
The objects opened for editing are displayed in the working area. These objects include, for
example, hardware components, blocks, PLC tag tables, screens of operator panels (HMI
devices), etc. If several objects are open at the same time, they are displayed in the task bar as
tabs. m
Task Cards
These provide tools for configuring/programming. The content of the Task Cards depends on
co

the object displayed in the working area.


If a hardware station is open, the Hardware catalog, for example, is available as a Task card.
n.

If a program block is open, there is a Task card with Instructions.


sa

Inspector Window
Additional information on a selected object or on executed actions is displayed in the Inspector
ru

window. The available properties of the selected objects can also be edited here (for example,
properties of screens, screen objects, tags).
bo

The Inspector window displays all system messages from the engineering, for example, those
resulting from generating a project. This window should always be checked for any errors and
warnings after a generation is completed.
@

Details View
The Details view displays the elements of the configuration object selected in the Project tree.
sa

These elements can be used in the active working area (by dragging them to the working area
using drag & drop). This enables fast access to the required objects (for example, tags).
m
sa
ry

2-3 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Working Areas
2.4 of the Hardware
Working Areas ofand Network
the Editor and Network Editor
Hardware

.c
s an
ru
Connection configuration

bo
@
Device configuration and
module parameter
sa
assignment
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Topology configuration
m
sa

Components of the Hardware and Network Editor


The Hardware and Network editor consists of a Device, Network, and Topology view.
ry

Topology View
The Topology view is used for displaying, configuring, and determining the physical structure of
networks.
• Configure the port assignment and the relationship between devices
• Online-Offline (actual-setpoint) comparison as well as synchronization of the port
assignment and relationships
• Topology makes it possible to exchange physical devices without a node initialization
om
.c
an
r us
bo
@
sa
m
sa
ry

2-4 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
HardwareHardware
2.4.1 and Network
andEditor:
NetworkDevice ViewDevice View
Editor:

.c
an
Device selection Horizontal / vertical split

s
Graphic area

ru
bo
Tabular area

@ Module parameter assignment


→ Properties in the Inspector window
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Device View
sa

The Device view is used for configuring and parameterizing devices and modules.
• Hardware configuration
ry

• Device and module parameter assignment


This editor consists of 2 areas, a tabular (left/top) and a graphic (right/bottom). The splitting left-
right or top-bottom can be changed as required.
– Graphic area = Module configuration
– Tabular area = Address parameterization of configured modules

"Properties" Tab in the Inspector Window


om
This tab is used to assign parameters to the module selected in the working area. Here, all the
properties or parameters of the selected module are displayed and can also be modified. In the
left-hand part of the Properties tab there is a navigation section in which the parameters are
arranged in groups.
c
n.

"Hardware Catalog" Task Card


a

Module catalog for the configuration (module grouping) in the working area
us

Project Tree → "Local Modules"


In the Project tree, the modules along with their parameter assignments (for example,
r

addresses) are stored under the relevant device in the "Local modules" folder.
bo
@
sa
m
sa
ry

2-5 SITRAIN
SIMATIC Programming 2 in the TIA Portal
HardwareHardware
and Network
andEditor: Network View

om
2.4.2 Network Editor: Network View

.c
s an
ru
bo
Subnetze
Subnets

Overview
Übersicht derofprojektierten
the configuredNetz-
Networks,
und
Verbindungs-,
Connections andE/A-Kommunikation
I/O Communications

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Network View
sa

The Network view is used for configuring, parameterizing and networking devices.
• Configure and parameterize devices
ry

• Configure Connections
Just like the Device view, the Network view is also divided into a tabular area and a graphic
area.
In the graphic area, devices, networks, and connections relevant to the network are displayed.
Here, new devices can be inserted and connected with one another and the communication
settings can be adjusted.
The tabular area contains various tables on the devices, connections, and communication
settings.
c om
a n.
r us
bo
@
sa
m
sa
ry

2-6 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
HardwareHardware
2.4.3 and Network
andEditor:
NetworkTopology
Editor:View
Topology View

.c
an
Adopt position of devices
as in Network view

s
ru
bo
All network
components
(even unmanaged)
Offline-Online comparison

@ Overview of the individual port interconnections


sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

In the Topology View, you carry out the following tasks:


• Display Ethernet topology
ry

– Display all PROFINET devices and passive Ethernet components of the project
including ports
– Display interconnections between the ports
– Display associated logical networks
– Display the diagnostic information of all ports
• Configure Ethernet topology
– Create, change, and delete interconnections of ports
– Rename stations, devices, interfaces, ports
– Add PROFINET devices and passive Ethernet components to the project from the
m
Hardware catalog
• Determine differences between the offline and online (setpoint and actual) topology and
co

minimize them
– Carry out offline/online comparisons of Ethernet modules, Ethernet ports, and Ethernet
n.

port interconnections
– Adopt topology information existing online in the offline project
sa

The Topology overview is also divided into a graphic and a tabular area.
ru

The "Topology Overview" tab of the tabular area offers the following functions:

bo

Overview of the modules


• Ports and port interconnections
@
sa
m
sa
ry

2-7 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Topology Comparison

om
Topology Comparison

Adopt position of devices

.c
as in Network view

s an
ru
Compare
Synchronize

bo
Update

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

The "Topology Comparison" tab of the tabular area offers the following functions:

sa

Determining the differences between the offline and online (setpoint and actual) topology
• Minimizing the differences between the offline and online (setpoint and actual) topology
ry

In the "Action" column, you specify which Offline/Online differences are to be adopted. All
differences to be adopted are activated via the context menu (Apply > Apply all).
Then the selected differences can be adopted with the "Synchronize" button.

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-8 SITRAIN
SIMATIC Programming 2 in the TIA Portal

2.5
Selecting Selecting
the Controllerthe
and Controller
the Modules and the Modules

om
Manual: “SIMATIC S7-1500 / ET 200MP Software: “TIA Selection Tool” (online or offline)

.c
Automation system In a nutshell”

s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Entry ID: 109481357 TIA Portal Information Center > Tools & Apps > Configurator
m
sa

SIMATIC S7-1500 provides you with a wide range of CPUs that can be integrated. You can
expand each CPU with I/O modules, communication modules, and technology modules. If, for
example, the memory and performance of a CPU 1511-1 PN are sufficient for you, then you
ry

expand it with communication modules for PROFINET and PROFIBUS. For technology
functions, technology CPUs, and technology modules are available in addition to the Compact
CPUs.

To select the correct controller there is the manual "SIMATIC S7-1500 / ET 200MP
Automation system In a nutshell" which contains further useful guidelines. It can be found
under the Entry ID: 109481357.
m
co

There is also the software TIA Selection Tool which provides an opportunity for selecting,
configuring and ordering the devices for Totally Integrated Automation. After configuring the
hardware in the TIA Selection Tool, you are given a list with all hardware components which are
n.

required (modules, plugs, cables, profile rails etc.).


In addition, the order via the Industry Mall can be started directly from the TIA Selection Tool.
sa
ru
bo
@
sa
m
sa
ry

2-9 SITRAIN
SIMATIC Programming 2 in the TIA Portal

Adding a Adding
2.6 New Device
a (Controller)
New Device (Controller)

om
.c
Project view

s an
ru
bo
Portal view

@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

Add new device: controller


It is possible to create a new device in the project using the Hardware and Network editor with
sa

the help of the "Hardware catalog" task card or through the Project tree "Add new device".
When a new device is created, a suitable rack is also created automatically. The selected
ry

device is inserted into the first permitted slot in the rack.


Regardless of the method selected, the added device is visible in the Device view and in the
Network view of the Hardware and Network editor.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-10 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Adding anAdding
2.6.1 Unspecified CPU (Controller)
an Unspecified CPU (Controller)

om
Programming can be started even

.c
though controller is not yet known

s an
ru
bo
Select modules from
the Hardware catalog
@
Read-in central I/O without
parameter assignment
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Unspecified CPU
For the selection of the controller, you can also choose an "Unspecified CPU". This is necessary
sa

when the real CPU is not yet known but you would like to start programming first. Here, you only
need to specify the firmware of the CPU which is to be used later on. The actual hardware can
ry

later be configured from the Hardware catalog or determined online.

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-11 SITRAIN
SIMATIC Programming 2 in the TIA Portal

HardwareHardware
2.7 Catalog Catalog

om
.c
Search function Create /
Select the current
Select module version before

an
HW Profile inserting.

Filter function

s
ru
bo
@
Information
(selected
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

module)
m

The Hardware catalog contains all devices and hardware components in a tree structure.
sa

From the catalog, selected devices or modules can be dragged to the graphic working area of
the "Hardware and Network" editor.
ry

Search Function
This allows a convenient search for specific hardware components. The search also includes
the module description texts.

Filter Function
m
enabled: Only modules that match the current context are displayed.
co

disabled: All existing objects of the catalog are displayed


n.

Contents of the Hardware Catalog for Enabled Filter


• Network view → only objects that can be networked
sa

• Device view → all modules or, if Filter is enabled, only the modules that belong to the
current device in the working area
ru

Profile
bo

It is possible to create and to use your own profiles. This expands the filter possibilities.

Information
@

The "Information" pane shows detailed information about the object selected in the catalog.
• Name
sa

• Order number (Article no.)


• Version number
m
sa
ry

2-12 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Inserting /Inserting
2.8 Deleting a Module
/ Deleting a Module

.c
an
Inserting from the
Hardware catalog
Possible

s
slots

ru
Deleting in the Device view

bo
deletes individual modules

Deleting in the Network


@
sa
view deletes entire station
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Inserting a Module
Modules can be inserted using drag & drop or by means of a double-click.
ry

Selecting a Version
When selecting a module, you must pay attention to the correct version. If the module is
selected (highlighted) in the task card "Hardware catalog > Catalog", the version can be
selected in the task card "Hardware catalog > Information".

Deleting a Module
Deleted hardware components are removed from the system and assigned addresses are made
available again.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-13 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
ChangingChanging
2.8.1 a Device / a
Module
Device / Module

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Changing a Module
sa

Compared to deleting and then inserting a new module, the advantage of ‘Change device’ is
that when a module is changed (replaced), all the parameters of the old module are adopted on
ry

the new module. A module exchange can, be advantageous when, for example, the CPU
version in the offline project is to be adapted to the CPU version (online) following a firmware
update.
Hardware components can only be exchanged if the components are compatible.

It is also possible to change a device by dragging the new module from the Hardware catalog
onto the old module using drag & drop.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-14 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
I/O-Addresses
2.8.2 of Modulesof Modules
I/O Addresses

.c
s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Module Parameter Assignment


ry

After the hardware components have been inserted in your rack, the preset properties,
such as names, parameters, or addresses, can be edited.
The parameters of all modules are downloaded into the CPU which must be in the STOP state for
this. With a subsequent restart, the CPU independently distributes the parameters to the relevant
modules via the backplane bus.

I/O Address (Peripheral address)


I/O addresses (input/output addresses) are needed to read inputs and set outputs in the
user program.
Input and output addresses are automatically assigned when modules are inserted in the
rack. The address of the first channel is the start address of a module. The addresses of
m
the remaining channels results from this start address. The end address results from the
module-specific address length.
co

Organization Block and Process Image


n.

The values of input and output modules can automatically be read-into the process image for
inputs (PII) and written from the process image for outputs (PIQ). The general PII and PIQ (called
sa

"Automatic update" in the screen/picture) is not assigned to any OB as process image partition
and is read-in or written in the peripherals cyclically at the cycle control point.
ru

If the address is assigned to a process image partition (PIP), which in turn is assigned to a
specific OB, then the process image is updated at the beginning of the OB and the peripherals
bo

updated at the end of the OB.


If the PIP is not assigned to any OB, then it must be updated in the user program with the
functions "UPDAT_PI" and "UPDAT_PO".
@
sa
m
sa
ry

2-15 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
2.9 Compiling the Hardware / Software and Downloading it into the
CompilingCPU
the Hardware / Software and Downloading it into the CPU

.c
s an
ru
bo
@
sa
Status / Error
information
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

Compiling and Downloading


The following components of a hardware station can be compiled and downloaded:
• Hardware and software (only changes)
The entire hardware configuration and hardware parameter assignment as well as all
changes to the user program are compiled/downloaded.
• Hardware (only changes)
Only the changes are compiled.
• Hardware (rebuild all) / Hardware configuration
The entire hardware configuration and hardware parameter assignment is
compiled/downloaded.
• Software (only changes)
om

Only the changed blocks of the user program are compiled/downloaded.


• Software (rebuild all)
All blocks of the user program are compiled.
.c

• Software (all)
an

All blocks are downloaded even if they have already been downloaded into the CPU.
Caution: the CPU is stopped for this.

us

Software (reset memory reserve)


All changed blocks of the user program are compiled and the data blocks which use
memory reserves (through newly inserted tags) are re-initialized. The current data of the
r

changed data blocks in the CPU is overwritten with the start values the next time there is a
bo

download and the memory reserves are made available, even if a memory reserve (for
loading a DB structure change with value retention) is activated in the Properties of the data
block.
@
sa
m
sa
ry

2-16 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Online Tools
2.10 Online Tools

.c
an
with CPU

Task Card

s
ru
bo
online → Status,
Diagnostics

@
offline → Configuration,
Parameterization
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Online Tools
If it is possible to establish an online connection to the CPU, diagnostics and status information
ry

of all modules can be viewed.


With CPUs that can be accessed online, the mode can also be controlled using the "Online
tools" task card and further status information (cycle time statistics and memory load) can be
viewed. c om
n.
sa
ru
bo
@
sa
m
sa
ry

2-17 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Default Visible
2.10.1 Interfaces
Default Visible for Online Access
Interfaces for Online Access

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

In the Settings, you can have a default setting for the connection path for online access(es).
In the Online access folder, all possible interfaces of the PG/PC are displayed. Since not all of
ry

these are required or can be used, interfaces can be hidden for better clarity.

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-18 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Online Access: Accessible Devices

om
Online Access: Accessible Devices

.c
1

an
2

s
1

ru
2 3

bo
3

Online access or
Accessible devices
1
(Project or Portal view)

@ Select interface for the


search
sa
Update accessible
devices or Start search
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Accessible Devices in the Portal View


sa

This function provides the option of fast access (for example, for service purposes) even when
the PG does not have the TIA Portal Project.
ry

All accessible, programmable modules (CPUs, FMs CPs, operator panels) are listed in the
Portal view, even if they are located in other subnets.

Access Online Functions → Button


Whenever there is an attempt to access a module online with the "Show" button and this is
located in a different subnet from the PG, a dialog opens asking whether an additional IP
address should be assigned to the PG.
Following confirmation, an additional IP address is assigned to the PG that is located in the
same subnet as the address of the CPU. After that, all online functions can be used.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-19 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Accessible
2.10.2 Devices: Online
Accessible & Diagnostics,
Devices: Task Card: Online
Online & Diagnostics, Tools Online Tools
Task Card:

.c
an
s
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Online Access to the CPU


If the PG and the target system (for example, CPU) are located in the same subnet, various
ry

Online & diagnostics functions are available in the "Accessible devices" function.
• in the working area of TIA Portal
• in the "Online tools" task card

CPU Operator Panel: Mode Selector Switch


The operating mode of the CPU can be changed.
• RUN → STOP:
If there is a change from RUN to STOP, the CPU ends the running user program.
• STOP → RUN:
om
If there is a change from STOP to RUN, the CPU performs a restart.

Cycle Time:
.c

"Shortest", "Current" and "Longest" are the cycle times since the last CPU restart
an

With a Memory Reset (MRES), a CPU reset is carried out:


– All user data (even the retentive) is deleted (delete work memory)
us

(process images, memory bits, timers, counters, all program/data blocks)


– Retained are: IP addresses, the retentive part of the diagnostics buffer, operating hours
r

counter, time-of-day.
bo
@
sa
m
sa
ry

2-20 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Accessible Devices: Online & Diagnostics: Diagnostics buffer

om
Accessible Devices: Online & Diagnostics: Diagnostics Buffer

.c
s an
ru
bo
Details for the entry line
selected above

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Diagnostics Buffer
sa

The diagnostics buffer is a buffered memory area on the CPU organized as a circular buffer.
It contains all diagnostics events (error alarms, diagnostics interrupts, start-up information etc.)
ry

of the CPU in the order in which they occurred. The highest entry is the most recent event.
All events can be displayed on the programming device in plain language and in the order in
which they occurred.
The size of the diagnostics buffer depends on the CPU. In addition, not all of the
diagnostics buffer is buffered with PowerOFF (only a part is retentive).

• Number of entries, 1000 to 3200


• Of that, retentive 250 to 500
m
Details on Event
Some additional information is also provided for the selected event in the "Details on event" box:
co

• Event name and number



n.

Additional information depending on the event, such as the address of the instruction that
caused the event, etc.
sa
ru
bo
@
sa
m
sa
ry

2-21 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Online Access to the CPU: IP Address, Name, Time, FW Update, Memory Card
Online Access to the CPU: IP Address, Name, Time, FW Update, Memory Card

.c
s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

• Set Time (of Day)


Each S7 CPU has a real-time clock that can be set here.
ry

• Assign IP Address
As long as no IP address has been specified already by a hardware configuration that was
downloaded earlier, this can be assigned or modified here (this function is also available
when the PG/PC and the CPU are not assigned to the same subnet).
• Reset to Factory Settings
Unlike the "memory reset", all the memory areas of the CPU (work, load and retentive
memory, diagnostics buffer and time) are deleted here. Optionally (see dialog in the
picture), the IP address can also be deleted so that the CPU then only has a MAC address
(Media Access Control).
• Format Memory Card
The CPU memory card can also be deleted in the CPU via this online function. After that,
the CPU only has its IP address. All other data (including the device configuration) is
m
deleted.
The card cannot be deleted in the card reader via the Project tree. Device configuration and
co

blocks have a gray background, that is, are write-protected (only status information or open
with a double-click).
n.

• Assign Name
In PROFINET, each device must be assigned a unique device name that is stored
sa

retentively
on the device. The device name identifies a distributed I/O module (PROFINET IO) and
allows module replacement without a PG/PC.
ru

• Firmware Update
Here, the firmware version of the device and the modules can be updated. Under
bo

"Diagnostics -> General", the current firmware version is displayed.


Caution
@

If the CPU and Display have to be updated, first update the Display and then the CPU


sa


m
sa
ry

2-22 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
AccessingAccessing
2.10.3 the CPU using the Display
the CPU using the Display

.c
CPU Memory

an
Reset / Factory Delete / Format
Language Addresses Update Firmware
Defaults SMC

s
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-23 SITRAIN
SIMATIC Programming 2 in the TIA Portal
ResettingResetting
2.10.4 the CPU using the Mode
the CPU usingSelector
the ModeSwitch or Mode
Selector Selector
Switch Buttons
or Mode Selector Buttons

om
RUN 1. Set the mode selector switch to STOP or
Older

.c
STOP press the STOP mode selector button
Design -> New design will display <Stop Active>
RUN/STOP-LED
MRES of the S7-1500

an
RUN 2. Press and hold the mode selector
STOP
switch in the MRES position or
press and hold the STOP button
MRES
until the RUN/STOP LED flashes 2x

s
and then shows a continuous light
RUN STOP
New

ru
STOP
MRES Design 3. Let go of the switch/button

bo
RUN
4. Within 3 seconds, once again press the
STOP mode selector switch in the MRES
MRES position or press the STOP button
-> RUN/STOP LED flashes quickly
RUN Result:
STOP
MRES
@ 5. Let go of the switch/button
With inserted SMC
→ Memory Reset
Without inserted SMC
RUN
STOP
6. Set the mode selector switch to RUN or → Reset to factory settings
sa
press the RUN button
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

MRES -> A CPU restart is carried out


m

Particular Feature for CPU Memory Reset (MRES) using the Mode Selector Switch:

sa

when SIMATIC Memory Card (SMC) is inserted => Memory Reset


− All user data is deleted (work memory, retentive memory)
(process images, memory bits, counters, timers, all program/data blocks)
ry

− Retained are: parameter assignment of the X1 (Ethernet) interface, the retentive part of the
diagnostics buffer, operating hours counter, CPU time-of-day
− The CPU copies all load memory data relevant for execution (memory card) into the
internal RAM work memory. (Data relevant for execution: device configuration, program
blocks, data blocks).
• when no SIMATIC Memory Card (SMC) is inserted => Reset to factory settings
om
− All memory areas of the CPU (work memory, retentive memory, diagnostics buffer, time-of-
day) and the IP address are deleted.
c

After the SMC is inserted, the load memory data relevant for execution is reloaded into the
internal RAM work memory from the memory card:
n.

Device configuration (with IP address), program blocks, data blocks


a
r us
bo
@
sa
m
sa
ry

2-24 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
SIMATIC S7-1200/1500:
2.10.5 Memory Concept
SIMATIC S7-1200/1500: MemoryforConcept
CPU Memory Reset
for CPU Memory Reset

.c
With Memory Reset...

an
1 internal memory areas
Time-of-day Operating IP addresses
(system memory, entire data hours counter
and code working memory)
are deleted

s
internal Flash Diagnostics
buffer

ru
2 the user program and the
hardware configuration as well Load memory
as active Force jobs are
Force jobs

bo
copied from the load memory
RAM
2

@
System memory

Force 1
jobs 2 Code working memory
internal Flash
sa
Data working memory
inserted Flash Card Retentive memory
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Load memory
m
sa

CPU Memory Reset


• What to do:
ry

– STEP 7 online function → MRES in "CPU operator panel" of "Test" and "Online tools"
Task Cards
– Display (only S7-1500) → Main menu "Settings", submenu "Memory reset"
– CPU mode selector switch (with inserted memory card)
• Impact
– An existing online connection between PG/PC and the CPU is disconnected.
– The entire RAM work memory is deleted, that is, all user data (process images, memory
bits, counters, timers, all program/data blocks, even the retentive ones)

om
Retained are: IP addresses, retentive part of the diagnostics buffer (depends on the
CPU), operating hours counter, CPU time-of-day.
– After that, the CPU copies all data relevant for execution into the RAM work memory
.c

from the memory card. (Data relevant for execution: device configuration, program
blocks, data blocks, current Force jobs).
an
r us
bo
@
sa
m
sa
ry

2-25 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
SIMATIC S7-1200/1500:
2.10.6 Memory Concept
SIMATIC S7-1200/1500: MemoryforConcept
CPU Reset
fortoCPU
Factory Settings
Reset to Factory Settings

.c
an
With Reset to factory
settings... Time-of-day Operating IP addresses
01.01.2012 hours counter
internal memory areas (incl.

s
1
time-of-day, diagnostics buffer,
internal Flash Diagnostic

ru
operating hours counter) and
module parameters are deleted buffer
IP addresses query in STEP 7 Load memory

bo
Force jobs
2 the user program, the RAM
hardware configuration and
active Force jobs are copied

@
from the external load memory
(Flash Card) System memory

Force 1
sa
jobs 2 Code working memory
internal Flash

Data working memory


inserted Flash Card Retentive memory
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Load memory
sa

CPU Reset to Factory Settings


ry

• What to do:
– STEP 7 online function → MRES in "CPU operator panel" of "Test" and "Online tools"
Task Cards
– Display (only S7-1500) → Main menu "Settings", submenu "Memory reset"→ Factory
Defaults
– Mode selector switch (only without memory card)
• Impact
– An existing online connection between PG/PC and the CPU is disconnected.
– The entire RAM work memory is deleted, that is, all user data (process images, memory
bits, counters, timers, all program/data blocks, even the retentive ones, diagnostic
buffer), IP addresses are deleted if this is selected in STEP 7.
m
– All IP addresses are retained if this was specified in STEP 7.
co

If a memory card is inserted (or is already inserted), the CPU copies all data relevant for
execution into the internal RAM work memory from the memory card. (Data relevant for
execution: device configuration incl. IP address, program blocks, data blocks, current Force jobs
n.
sa
ru
bo
@
sa
m
sa
ry

2-26 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
2.10.7 Uploading the Actual Configuration to the Project (1)
Uploading(Hardware
the Actual with
Configuration
ParametertoAssignment
the Project (1)
and Software)

.c
(Hardware with Parameter Assignment and Software)

s an
CPU must have at least
one IP address

ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Select device
sa

An already existing configuration of an S7 station can be read-out by means of the function


ry

"Upload device as new station".


This is then necessary when the appropriate offline station doesn’t exist on the PG. After
reading out the S7 station, the hardware as well as the program can be adjusted or modified,
saved and downloaded into the CPU.

Requirement:
An IP address has been assigned to an interface of the station or the station has already been
configured.
c om
n.
sa
ru
bo
@
sa
m
sa
ry

2-27 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Uploading thethe
Uploading Actual Configuration
Actual to the
Configuration Project
to the (2) (2)
Project
(Hardware
(Hardware with
with Parameter
Parameter Assignment
Assignment andand Software)
Software)

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Station with Configuration:


If the station is already configured, then the entire station (central and distributed hardware with
ry

parameter assignments, the entire program with comments and symbols) is available to the
user offline for further processing after the device is uploaded.

Station without Configuration:


If the CPU was only assigned an IP address without further configuration, only the actual
configuration of the central hardware is available to the user after the upload.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-28 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Setting the
2.11 simulation
Setting ability
the of the blocks
simulation for PLCSIM
ability of the blocks for PLCSIM

.c
s an
1
2

ru
bo
3

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
In order to be able to simulate the program, the blocks must have the property that they can be
ry

simulated.

What to Do
1. In the Project tree, right-click on the project name and select “Properties”
2. Switch to the tap "Protection"
3. Enable the function "Support simulation during block compilation"
om
.c
an
r us
bo
@
sa
m
sa
ry

2-29 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Card Reader
2.12 Card/ USB Memory/Device
Reader USB Memory Device

.c
S7-1200/1500

an
S7-300/400

s
ru
bo
@ Removable media:
SMC
sa
Internal/external prommer: external hard drive
Memory Card USB memory device
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Micro Memory Card Reader_X (user-defined memory):


Folder on hard drive
m
sa

Card Reader / USB Memory


In the Card Reader/USB memory folder, you can access an SMC inserted in the SD Reader,
ry

the internal/external prommer, removable (media) devices or user-defined folders.

Card Type of the SIMATIC Card for S7-1200/1500:


The SIMATIC Memory Card is used as a Program card or a Transfer card or for Firmware
Updates. Before the relevant data is stored on the SMC, the card type must be selected as
shown in the picture.
• SIMATIC Memory Card as Program Card:
The card contains all configuration and parameterization data for the station as well as the
entire user program with documentation. During operation, the card must remain inserted in
om
the CPU because it is used as a replacement for the internal CPU load memory which
remains unused.
• SIMATIC Memory Card as Transfer Card (only for S7-1200):
.c

The card contains the same data as a Program card but it doesn’t have to remain inserted
during operation. After inserting the card and subsequent Power ON, all data is copied into
an

the internal load memory of the CPU. Then the card has to be removed and a restart has to
take place.
• SIMATIC Memory Card to Update Firmware:
us

The SIMATIC Memory Card contains the files required for a firmware update. After
execution, the SIMATIC Memory Card must be removed.
r
bo

S7-300/400:
An S7-300 or S7-400 CPU does not have an SMC as load memory but a Memory Card or Micro
Memory Card. You can only access these cards with the help of an internal or external
@

prommer.
Note: A SIMATIC Field PG has an internal prommer.
sa
m
sa
ry

2-30 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
2.13 Task Description (CLASSROOM):
Task Description
Creating (CLASROOM): Creating
a Project with ana Project with an
S7-1500 S7-1500 Station
Station

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task Description
ry

You are to create a project with the name "MyProject". It is to contain an S7-1500 station whose
configuration is to correspond exactly to that of your training unit.
Furthermore, the modules are to be assigned parameters in such a way that the input and
output addresses match those shown in the chapter "Training Devices".
c om
n.
sa
ru
bo
@
sa
m
sa
ry

2-31 SITRAIN
SIMATIC Programming 2 in the TIA Portal

2.13.1 Exercise 1 (CLASSROOM): Formatting the SMC of the CPU via

om
Exercise 1Online
(CLASSROOM):
Access orFormatting the SMC of the CPU via Online Access or the
the Display
Display

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
In order to completely erase the CPU, the SIMATIC Memory Card of the CPU must be erased
ry

first. This can be carried out as follows:


• with Windows Explorer (SMC is inserted in the PG’s Card Reader)
• with TIA Portal (SMC is inserted in the PG’s Card Reader)
• with TIA Portal (SMC is inserted in the CPU)
• via the Display of the CPU

What to Do using Online Access:


m
1. Check whether the SMC is inserted in the CPU.
co

2. In the Project view, under the interface connected to the training case, display all
"Accessible devices"
n.

3. Under the S7-1500 station, activate "Online & diagnostics" (see picture)
4. Under "Format memory card", activate the function "Format" (see picture)
sa

What to Do using the Display:


ru

1. As required, switch the Display language in the Menu Display.


2. Check whether the SMC is inserted in the CPU.
bo

3. Activate the menu option "Settings" > "Card handling"


4. Start the function "Format card" and confirm the subsequent information with "OK"
@

Note
If a password is stored on the CPU that is unknown to you, it is only possible to erase the SMC
if it is inserted in the PG’s Card Reader.
sa
m
sa
ry

2-32 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
2.13.2 Exercise 2 (CLASSROOM): Resetting the CPU to Factory Settings using
Exercise 2the
(CLASSROOM):
Mode SelectorResetting the CPUor
Switch/Button tothe
Factory Settings using the Mode
Display
Selector Switch/Button or the Display

.c
an
RUN 1. Remove the SIMATIC Memory Card
Older STOP
Design MRES 2. Set the mode selector switch to STOP or

s
press the STOP mode selector button
RUN -> New design will display <Stop Active>

ru
STOP
MRES 3. Press and hold the mode selector switch
in the MRES position or press and hold the

bo
RUN STOP button until the RUN/STOP LED
STOP New flashes 2x and then shows a continuous
MRES Design light

RUN 4. Let go of the switch/button

@
STOP
5. Within 3 seconds, once again press the
MRES
mode selector switch in the MRES
RUN position or press the STOP button
-> RUN/STOP LED flashes quickly
sa
STOP
MRES
6. Let go of the switch/button
RUN
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

7. Set the mode selector switch to RUN or


m

STOP
press the RUN button
MRES -> A CPU restart is carried out
sa

Task
ry

In the last exercise you erased the SMC of the CPU. Now, you are also to reset the CPU to its
factory settings.

What to Do using the Mode Selector Switch:


1. Carry out a memory reset directly on the CPU following the steps shown in the picture.

What to Do using the Display:


1. Activate the menu option "Settings" > "Reset"
2. Start the function "Factory defaults" and confirm the subsequent information with "OK"
m
Result:
co

• The CPU remains in the STOP state because no user program is loaded.

n.

The I/O modules indicate with green flashing lights that they are not parameterized.
sa
ru
bo
@
sa
m
sa
ry

2-33 SITRAIN
SIMATIC Programming 2 in the TIA Portal

2.13.3 Exercise 3 (CLASSROOM): Determining the CPU Firmware Version and


Exercise 3Assigning
(CLASSROOM):
the IP Determining the CPU
Address (Node Firmware Version and Assigning the IP
Initialization)

om
Address (Node Initialization)

.c
s an
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

Task
sa

In order to later be able to create an S7-1500 station in the offline project which exactly matches
your training controller, you are to determine online the Firmware version of the CPU and make
ry

note of it.

What to Do:
1. As required, switch the Display language in the Menu Display.
2. Activate the menu option "Overview" or "Overview" > "PLC"
m
3. Make note of the Firmware version of the CPU.
co
Firmware Version: _________________
n.
sa
ru
bo
@
sa
m
sa
ry

2-34 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 4Exercise
2.13.4 (CLASSROOM): Creating a Project
4 (CLASSROOM): Creating a Project

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

You are to create a new project with the name "MyProject".


ry

What to Do
1. In the Portal view, activate "Start > Create new project", or, in the Project view, navigate to
the text menu "Project" and choose "New”.
2. Enter the project name and the given path as shown in the picture and "Create" the project.
om
c
a n.
r us
bo
@
sa
m
sa
ry

2-35 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 5Exercise
2.13.5 (CLASSROOM): Creating anCreating
5 (CLASSROOM): Unspecified CPU
an Unspecified CPU

.c
s an
ru
Change device name

bo
@ Select Firmware
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
In your project, you are to create a new "Unspecified CPU 1500" that has the Firmware
determined in Exercise 5.
ry

What to Do
1. Switch to the Project view.
2. Start the function "Add new device"
3. In the dialog that appears, select the device type "Controller"
4. Under "SIMATIC S7-1500 > Unspecified CPU 1500", select the Article number "6ES7 5XX-
XXXXX-XXXX"
5. Select the one with the Firmware determined in Exercise 5.
m
6. Confirm the selection with "OK"
co

7. In the Network view of the Devices & Networks editor, change the device name of the new
CPU to S7-1500.
n.
sa
ru
bo
@
sa
m
sa
ry

2-36 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 6Exercise
2.13.6 (CLASSROOM): DeterminingDetermining
6 (CLASSROOM): (Detect) the ACTUAL Configuration
(Detect) the ACTUAL Configuration

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
You are to determine (detect) the ACTUAL configuration of the CPU.
ry

What to Do
1. Switch to the Device view of the Devices & Networks editor.
2. In the window "The device is not specified", choose the function ‘detect’ (see picture).
3. As ‘Type of the PG/PC interface’ set "PN/IE" as well as the associated PG/PC interface
4. Start the search for accessible devices.
5. Select the displayed S7-1500 and start the detection of the configuration with the button
"Detect"
m
Result
co

The central configuration of the CPU is displayed with Default parameters.


n.
sa
ru
bo
@
sa
m
sa
ry

2-37 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 7Exercise
2.13.7 (CLASSROOM): Setting the Setting
7 (CLASSROOM): IP Address
the IP Address

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
In the CPU Properties, you are to change the IP address of the CPU.
ry

What to Do
1. Highlight the CPU in the Device view.
2. In the Inspector window, select the “Properties” tab and then the menu item “PROFINET
interface > Ethernet addresses”.
3. Enter the IP address and Subnet mask shown in the picture.
4. Save the changes.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-38 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
2.13.8 Exercise 8 (CLASSROOM): CPU Properties: Parameterizing the Display
Exercise 8Language
(CLASSROOM): CPU Properties:
and Display ProtectionParameterizing the Display Language
and Display Protection

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
In the CPU Properties, you are to parameterize the display language of the CPU-Display and
ry

the display protection.

What to Do
1. In the "Properties" tab under "Display > General", select the item Display language and set
the display language to "English".
2. In the Password menu, enable write access and display protection.
3. Enter a password.
m
4. Save your project.
co

Note on Password Assignment:

Upper and lower case is not relevant, since only the letters A to Z and digits 0 to 9 can be
n.

selected when making entries on the Display.


Since there is no Display keypad, it is recommended for this exercise that you select a
sa

simple (possibly only numerical) password.


ru
bo
@
sa
m
sa
ry

2-39 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 9Exercise
2.13.9 (CLASSROOM): CPU Properties:
9 (CLASSROOM): Password Protection
CPU Properties: Password Protection

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
Since the CPU is an F-CPU (fail-safe CPU), the password protection for fail-safe programs is
ry

activated even though the "F-capability" was deactivated in the default settings. This requires
that a password be entered. So that you don’t have to enter a password, set the password
protection of the CPU to "Full access incl. fail-safe (no protection)".

What to Do
1. In the Properties of the CPU, switch to the folder "Protection & Security" > Access level.
2. Activate the access level "Full access incl. fail-safe (no protection)".
3. Save your project.

Information regarding Access Level


m
Since every user can read-out and modify the parameter assignments as well as the user
co

program of the CPU using a PG with the protection level "Full access", a warning is output
during compilation.
When the "Read access" level is set, the password must be entered for write accesses using a
n.

PG.
sa

When the "HMI access" level is set, you require the relevant password for every access
(reading and writing).
When the "No access (complete protection)" level is set, each HMI device also requires the
ru

appropriate password. This is stored in the parameter assignments of the HMI device.
bo
@
sa
m
sa
ry

2-40 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 10
2.13.10 (CLASSROOM):
Exercise Addresses of
10 (CLASSROOM): the DI Module
Addresses of the DI Module

.c
san
ru
bo
@
When and in which
sa
process image are
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

the inputs updated


m

Task
sa

You are to parameterize the I/O addresses of the DI module as shown in the picture.
ry

What to Do
1. In the Device view, select the DI module (see picture).
2. In the Inspector window, in the "Properties > General" tab, navigate to "Input 0 - 31 > I/O
addresses".
3. Enter the I/O address 0 shown in the picture.
4. Set the update of the Process image to Automatic so that the address is automatically
updated by the system in every program cycle.
m
5. Save your project.
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-41 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Exercise 11
2.13.11 (CLASSROOM):
Exercise Addresses of
11 (CLASSROOM): the DO Module
Addresses of the DO Module

.c
s an
ru
bo
@
sa
When and in which
m

process image are


Private copy for Recep Yigit Samsa, rysamsa@borusan.com

the outputs updated.


sa

Task
ry

You are to parameterize the I/O addresses of the DO module as shown in the picture.

What to Do
1. In the Device view, select the DO module (see picture).
2. In the Inspector window, in the "Properties > General" tab, navigate to "Output 0 - 31 > I/O
addresses".
3. Enter the I/O address 0 shown in the picture and set the update of the Process image to
Automatic.
4. Save your project.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-42 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 12 (CLASSROOM): Addresses of the AI Module

om
2.13.12 Exercise 12 (CLASSROOM): Addresses of the AI Module

.c
san
ru
bo
Set it so that the
@
inputs are not
sa
updated in any
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

process image.
m

Task
sa

You are to parameterize the I/O addresses of the AI module as shown in the picture.
ry

What to Do
1. In the Device view, select the AI module (see picture).
2. In the Inspector window, in the "Properties > General" tab, navigate to "Input 0 - 7 > I/O
addresses".
3. Enter the I/O address 10 shown in the picture.
4. In the assignment of the process image, set "None" since the analog value of the module is
to be read directly by the I/O later in the program and thus does not have to be updated with
any process image.
om
5. Save your project.
c
a n.
r us
bo
@
sa
m
sa
ry

2-43 SITRAIN
SIMATIC Programming 2 in the TIA Portal

2.13.13 Exercise 13 (CLASSROOM): Setting the Channel Parameters of the Analog

om
Exercise 13 (CLASSROOM):
Input Module Setting the Channel Parameters of the Analog Input Module

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
You are to set the analog channels to the appropriate parameters:
ry

– Set the Channel template (Measurement type) to ‘Deactivated’


– Channel 0 → Voltage +/-10V
– Channel 1 → Current (4-wire transducer) +/-20 mA

What to Do
1. In the Inspector window, in the "Properties” tab, navigate to “Module parameters > Channel
template > Inputs" and set Measurement type ‘Deactivated’ as the template.
m
2. Under "Input 0 - 7 > Inputs" set the Measurement type "Voltage" +/-10V for Channel 0 and
for Channel 1 set the Measurement type "Current (4-wire transducer)"
co

+/-20 mA.
3. Save your project.
n.
sa
ru
bo
@
sa
m
sa
ry

2-44 SITRAIN
SIMATIC Programming 2 in the TIA Portal

2.13.14 Exercise 14 (CLASSROOM): Compiling the Device Configuration and


Exercise 14 (CLASSROOM): Compiling
the CPUthe Device Configuration and Downloading it

om
Downloading it into
into the CPU

.c
an
Delta Compile Delta Download

s
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

Task
sa

The configuration and parameterization of the S7-1500 hardware station is to be compiled and
then downloaded into the CPU. So that the CPU can switch to the RUN state after loading, the
ry

software or one CPU program would also have to be loaded.


At the moment, your CPU program consists of the automatically created organization block
"Main" (Event source "Cyclic program"), which doesn’t contain any instructions yet but would be
sufficient so that the CPU can switch to the RUN state during a restart.

What to Do
m
1. In the Project view, select your S7-1500 station.
2. Compile the HW-Station and the software via the context menu (right-click on the station) or
co

via the button shown here on the left (see picture) and in the Inspector window in the "Info"
tab, check whether the compilation was completed without errors.
n.

3. After an error-free compilation, download the HW-Station complete with hardware and
software into the CPU (either via the context menu [right-click on the station]) or via the
sa

button shown here on the left (see also picture)


4. In the dialog "Load results", activate the action "Start module" and confirm the dialog with
ru

the "Finish" button.


5. In the "Inspector window" under "Info -> General" check the result of the hardware
bo

configuration download.
6. Save your project.
@

Result:
sa

All LEDs of the S7-1500 station show continuous green light.


m
sa
ry

2-45 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
2.14 Task Description (ONLINE):
Task Description
Creating (ONLINE): Creating
a Project a Project
with with an S7-1500
an S7-1500 Station
Station

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task Description
ry

You are to create a project with the name "MyProject". It is to contain an S7-1500 station whose
configuration is to correspond exactly to that of your training unit.
Furthermore, the modules are to be assigned parameters in such a way that the input and
output addresses match those shown in the chapter "Training Devices".

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-46 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 1Exercise
2.14.1 (ONLINE): PLCSIM Project
1 (ONLINE): as the
PLCSIM basisas
Project forthe
Factory
basisI/O
for Factory I/O

om
.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

You are to start the prepared PLCSIM project as the basis for Factory I/O
ry

What to Do
1. Start the prepared PLCSIM Project "PRO"_PLCSIM_Vxx_Factory_IO.simXX"
2. Start Factory I/O by using the file with the ".factoryio" ending in the "Scene_Factory_IO"
folder
3. Change the Driver Settings

FILE > DRIVER >


c om
a n.
r us

Select PLCSIM, S7-1500 and "Auto connect".


bo

You get back via " Configuration" and " DRIVER"


@
sa
m
sa
ry

2-47 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Exercise 2Exercise
2.14.2 (ONLINE): Creating a Project
2 (ONLINE): Creating a Project

.c
s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Task
ry

You are to create a new project with the name "MyProject".

What to Do
1. In the Portal view, activate "Start > Create new project", or, in the Project view, activate the
function "New" in the menu "Project"
2. Enter the project name and the given path as shown in the picture and "Create" the project.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-48 SITRAIN
SIMATIC Programming 2 in the TIA Portal

2.14.3 Exercise 3 (ONLINE): Uploading the Actual Configuration to the Project


Exercise 3(Hardware
(ONLINE): with
Uploading the Actual Configuration to the Project (Hardware with

om
Parameter Assignment and Software)
Parameter Assignment and Software)

.c
s an
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Select device
m

Task
sa

Run a project upload of the PLCSIM Project from Exercise 1


ry

What to Do
1. Change to project view
2. Right-click the project name "MyProject" and select “Properties”
3. Set the Checkbox "Support simulation during block compilation"
4. Navigate to the text menu "Online" > Load device as new station (hardware and software)
m
5. Select the device which is shown
6. Load the information of PLCSIM into the project
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-49 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 4Exercise
(ONLINE): Setting the Setting
IP Address

om
2.14.4 4 (ONLINE): the IP Address

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

In the CPU Properties, you are to change the IP address of the CPU.
ry

What to Do
1. Highlight the CPU in the Device view.
2. In the "Inspector window", select the "Properties" tab and there the menu item "PROFINET
interface > Ethernet addresses”.
3. Enter the IP address and Subnet mask shown in the picture.
4. Save the changes.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-50 SITRAIN
SIMATIC Programming 2 in the TIA Portal

2.14.5 Exercise 5 (ONLINE): CPU Properties: Parameterizing the Display


Exercise 5Language
(ONLINE):and
CPUDisplay
Properties: Parameterizing the Display Language and
Protection

om
Display Protection

.c
s an
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

Task
sa

In the CPU Properties, you are to parameterize the display language of the CPU-Display and
the display protection.
ry

What to Do
1. In the "Properties" tab under "Display > General", select the item Display language and set
the display language to "English".
2. In the Password menu, enable write access and display protection.
om
3. Enter a password.
4. Save your project.
c

Note on Password Assignment:


n.

Upper and lower case is not relevant, since only the letters A to Z and digits 0 to 9 can be
a

selected when making entries on the Display.


us

Since there is no Display keypad, it is recommended for this exercise that you select a
simple (possibly only numerical) password.
r
bo
@
sa
m
sa
ry

2-51 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 6Exercise
2.14.6 (ONLINE): CPU Properties:
6 (ONLINE): Password Protection
CPU Properties: Password Protection

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
Since the CPU is an F-CPU (fail-safe CPU), the password protection for fail-safe programs is
activated even though the "F-capability" was deactivated in the default settings. This requires
ry

that a password be entered. So that you don’t have to enter a password, set the password
protection of the CPU to "Full access incl. fail-safe (no protection)".

What to Do
1. In the Properties of the CPU, switch to the folder "Protection & Security" > Access level.
2. Activate the access level "Full access incl. fail-safe (no protection)".
3. Save your project.
m
Information regarding Access Level
Since every user can read-out and modify the parameter assignments as well as the user
co

program of the CPU using a PG with the protection level "Full access", a warning is output
during compilation.
n.

When the "Read access" level is set, the password must be entered for write accesses using a
PG.
sa

When the "HMI access" level is set, you require the relevant password for every access
(reading and writing).
ru

When the "No access (complete protection)" level is set, each HMI device also requires the
appropriate password. This is stored in the parameter assignments of the HMI device.
bo
@
sa
m
sa
ry

2-52 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 7Exercise7
2.14.7 (ONLINE):(ONLINE):
AddressesAddresses
of the DI Module
of the DI Module

.c
san
ru
bo
@
sa
When and in which
process image are
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

the inputs updated


m

Task
sa

You are to parameterize the I/O addresses of the DI module as shown in the picture.
ry

What to Do
1. In the Device view, select the DI module (see picture).
2. In the Inspector window, in the "Properties > General" tab, navigate to "Input 0 - 31 > I/O
addresses".
3. Enter the I/O address 0 shown in the picture.
4. Set the update of the Process image to Automatic so that the address is automatically
updated by the system in every program cycle.
5. Save your project.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-53 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 8Exercise
2.14.8 (ONLINE): Addresses Addresses
8 (ONLINE): of the DO Module
of the DO Module

om
.c
s an
ru
bo
@
When and in which
process image are
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

the outputs updated.


m

Task
You are to parameterize the I/O addresses of the DO module as shown in the picture.
sa

What to Do
ry

1. In the Device view, select the DO module (see picture).


2. In the Inspector window, in the "Properties > General" tab, navigate to "Output 0 - 31 > I/O
addresses".
3. Enter the I/O address 0 shown in the picture and set the update of the Process image to
Automatic.
om
4. Save your project.
c
a n.
r us
bo
@
sa
m
sa
ry

2-54 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 9Exercise
2.14.9 (ONLINE): Addresses Addresses
9 (ONLINE): of the AI Module
of the AI Module

.c
san
ru
bo
Set it so that the
@
sa
inputs are not
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

updated in any
process image.
m

Task
sa

You are to parameterize the I/O addresses of the AI module as shown in the picture.
ry

What to Do
1. In the Device view, select the AI module (see picture).
2. In the Inspector window, in the "Properties > General" tab, navigate to "Input 0 - 7 > I/O
addresses".
3. Enter the I/O address 10 shown in the picture.
4. In the assignment of the process image, set "None" since the analog value of the module is
to be read directly by the I/O later in the program and thus does not have to be updated with
any process image.
m
5. Save your project.
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-55 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal

2.14.10 Exercise 10 (ONLINE): Setting the Channel Parameters of the Analog


Exercise 10 (ONLINE):
Input ModuleSetting the Channel Parameters of the Analog Input Module

.c
s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Task
ry

You are to set the analog channels to the appropriate parameters:


– Set the Channel template (Measurement type) to ‘Deactivated’
– Channel 0 → Voltage +/-10V
– Channel 1 → Current (4-wire transducer) +/-20 mA

What to Do
1. In the Inspector window, in the "Properties” tab, navigate to "Module parameters > Channel
template > Inputs" and set Measurement type ‘Deactivated’ as the template.
2. Under "Input 0 - 7 > Inputs" set the Measurement type "Voltage" +/-10V for Channel 0 and
for Channel 1 set the Measurement type "Current (4-wire transducer)"
m
+/-20 mA.
3. Save your project.
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-56 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
2.14.11 Exercise 11 (ONLINE): Compiling the Device Configuration and
Exercise 11 (ONLINE): Compiling
Downloading it into thethe Device Configuration and Downloading
CPU
it into the CPU

.c
s an
Delta Compile Delta Download

ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
ry

The configuration and parameterization of the S7-1500 hardware station is to be compiled and
then downloaded into the CPU. So that the CPU can switch to the RUN state after loading, the
software or one CPU program would also have to be loaded.
At the moment, your CPU program consists of the automatically created organization block
"Main" (Event source "Cyclic program"), which doesn’t contain any instructions yet but would be
sufficient so that the CPU can switch to the RUN state during a restart.

What to Do
1. In the Project view, select your S7-1500 station.
2. Compile the HW-Station and the software via the context menu (right-click on the station) or
om
via the button shown here on the left (see picture) and in the Inspector window in the "Info"
tab, check whether the compilation was completed without errors.
3. After an error-free compilation, download the HW-Station complete with hardware and
.c

software into the CPU (either via the context menu [right-click on the station]) or via the
button shown here on the left (see also picture)
an

4. In the dialog "Load results", activate the action "Start module" and confirm the dialog with
the "Finish" button.
us

5. In the Inspector window under "Info -> General" check the result of the hardware
configuration download.
r

6. Save your project.


bo

Result:
@

All LEDs of the S7-1500 station show continuous green light.


sa
m
sa
ry

2-57 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
2.15 Appendix

.c
Area for Modules
2.15.1 Area forNot Plugged
Modules In Plugged In
Not

s an
ru
Open / Close area

bo
Modules can be parameterized

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

Area for Modules Not Plugged In


Modules that are intended to be assigned to a device, for example as the result of a copy
action, but for which the corresponding rack does not have a free compatible slot are moved
automatically to the "area for modules not plugged in".
Modules are added to the area for modules not plugged in under the following conditions:
• When a module is copied or moved within the Project tree.
• When a module is dragged to a device in the Network view, even though there is no
compatible slot free on its rack.
• In the Device view, when a module is directly moved into the area from the rack or
Hardware catalog.
om

The following Rules apply for Modules in the ‘Area’:


• You will find the modules in the Project tree under the appropriate device in the "Local
c

modules" folder.
n.

• The modules retain all previously made settings and parameters.


sa

• The modules are not considered during loading into the target system; that is, there is no
consistency check for modules in the Area for Modules Not Plugged In.

ru

The modules can be copied, cut out or deleted for example, via the context menu.
bo
@
sa
m
sa
ry

2-58 SITRAIN
SIMATIC Programming 2 in the TIA Portal
SwappingSwapping
2.15.2 a Slot / Inserting
a Slot a/ Inserting
Module between Two
a Module ModulesTwo Modules
between

om
.c
s an
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

Swapping a Slot or Inserting a Module between Two Modules.


Using drag & drop, drag the modules in front of or behind the slot number until the marking
sa

appears at the desired location, as shown in the picture. The module is placed where the
marking is and the modules behind it are moved one slot to the right. If there are too many
ry

modules, the excess modules are moved to the "area for modules not plugged in".

Note:
This is not possible from the Hardware catalog. It is only possible with already plugged in
modules or modules from the ‘area for modules not plugged in’. m
co
n.
sa
ru
bo
@
sa
m
sa
ry

2-59 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
3 Commissioning – Distributed I/O

.c
an
Learning
3.1 objectives
Learning objectives

s
• You know how to read-in a distributed I/O

ru
• You can configure, network and commission a distributed PROFINET I/O station

bo
• You know possible configurations of I/O communication

@
• You know how to assign device names of distributed I/O via the communication
table
sa
• You can group devices

• You know how to commission the ET 200SP


Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

om
.c
an
r us
bo
@
sa
m
sa
ry

3-1 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
3.2Task Description: CommissioningCommissioning
Task Description: the ET 200SP Distributed
theI/OET 200SP Distributed I/O

.c
s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Task Description
The ET 200SP distributed I/O station is to be commissioned since the conveyor model is later to
ry

be controlled via its input and output modules.


For this, the ET 200SP station must be configured, assigned parameters, and networked with
the S7-1500 station in the offline project.
Among other things, you will use the functions ‘Hardware detection’ and ‘Assigning device
names with the help of the communication table’.
After compiling the new hardware configuration, it must be downloaded into the CPU. In the
function of an I/O Controller, the CPU then automatically undertakes the parameterization of the
ET 200SP I/O-device.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

3-2 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Inserting
3.3 Distributed
InsertingI/O Distributed I/O

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Inserting Distributed I/O


ry

PROFINET IO-Devices are added in the Network view. Here, you can insert the relevant
devices into the project by dragging & dropping them from the Hardware catalog. The correct
Firmware must also be selected here before the device is inserted.
The new device (ET 200SP) is stored in the "Ungrouped devices" folder.
Furthermore, there is a link to the ET 200SP in the "Unassigned devices" folder since it is not
yet assigned to a controller.

I/O Modules
Just as for a CPU, the individual input and output modules can be configured and assigned
om
parameters in the Device view. For this, the device is selected and the Device view opened or in
the Device view, the relevant device is selected via the selection menu.
.c
an
r us
bo

Note
The addresses for the modules of the decentralised periphery can be defined after assigning
the module to a controller.
@
sa
m
sa
ry

3-3 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Reading-in the Configuration of the Distributed I/O
3.3.1 Reading-in the Configuration of the Distributed I/O

om
.c
s an
ru
Selection of the desired
IO-Devices

bo
@
sa
Only the configuration without parameter-
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

assignments and without networking


m
sa

Inserting Distributed I/O


PROFINET IO-Devices are added in the Network view. Here, you can insert the relevant
ry

devices into the project by dragging & dropping them from the Hardware catalog. The correct
Firmware must also be selected here before the device is inserted.

Reading-in the Configuration of the Distributed I/O


If an IO-Device already exists, the configuration can also be read-in. For this, TIA-Portal looks
for which IO-Devices are accessible via the selected interface. After you have selected the
devices, the configuration is read-in and stored in the project. During the reading-in of the
devices, no check is made whether these already exist in the project.
m
co

The new devices are stored in the "Ungrouped devices" folder.


Furthermore, there is a link to the devices in the "Unassigned devices" folder since they are not
n.

yet assigned to a controller.


sa
ru
bo
@
sa
m
sa
ry

3-4 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Networking Distributed I/O and Configuration of the I/O Communication
3.3.2 Networking Distributed I/O and Configuration of the I/O Communication

om
.c
Assigned to this
IO-Controller

s an
ru
bo
Optional IO-Device can be
activated / deactivated in
the program
@ Update time
can be set
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Networking Distributed I/O


After an IO-Device has been inserted, it must be assigned to an IO-Controller or networked with
ry

a CPU. In case there are several CPUs in the network, a co-ordination or monitoring of the I/O
addresses by the IO-Controller and IO-Device can only be done through this unique
assignment.
The link of the IO-Devices that is in the "Unassigned devices" folder is stored in the controller’s
"Distributed I/O" subfolder for the devices that were assigned to a controller. The actual device
is still stored in the "Ungrouped devices" folder.

I/O Communication – Offline Configuration


m
In the table ‘I/O communication’, the update time can be changed as required and the IO-Device
can be set to ‘optional’.
co

Optional IO-Device
n.

Devices that are selected here do not exist from the perspective of the CPU and must be
explicitly introduced into the user program. In this way it is possible to configure a maximum
sa

configuration which makes it possible for a series machine project to use several specific
versions and to vary the configuration of an IO-System for a particular application.
ru

Update Time
bo

This is the time interval in which an IO-Device/IO-Controller in the PROFINET IO-System is


supplied with new data by the IO-Controller/IO-Device.
@

Update Time Mode


The update (time) mode can be set to ‘Automatic’ or ‘Can be set’. For the ‘Can be set’ update
mode, the update time must be set; for ‘Automatic’, the system calculates the time.
sa
m
sa
ry

3-5 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
3.3.3 PROFINET IO Device ET 200SP:
PROFINET IO Device ET 200SP: Assigning the IP Address and Device Name
Assigning the IP Address and Device Name OFFLINE
OFFLINE

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

IP Address, Subnet Mask and PROFINET Device Name


For communication with the IO-Controller, a PROFINET device name must be assigned to the
IO-Device (ET 200SP) OFFLINE. The IO-Controller then assigns the IO-Device a valid IP
address. If the IO-Device is assigned an IP address OFFLINE, this IP address is adopted.
These parameters are downloaded to the IO-Controller (CPU) with the programming device.
The IO-Controller (CPU) then transfers these and other parameters (such as, the I/O
addresses) to the IO-Device (ET 200SP).

Attention:
Only the PROFINET device name is relevant for the transmission of the offline configuration into
the online device (Controller), not the IP address. The offline configured PROFINET device
om

name and the online existing PROFINET device name must match. If the IO-Device has a
different PROFINET device name or doesn’t have a name at all, the IO-Controller cannot
transfer the hardware configuration or the hardware parameter assignments to the IO-Device
c

thus preventing a PROFINET system startup.


n.

Note
sa

The IP addresses can also be entered directly in the Network view in the graphic area. For this,
ru

the IP addresses must be shown (displayed) with the function "Show address labels" .
bo
@
sa
m
sa
ry

3-6 SITRAIN
SIMATIC Programming 2 in the TIA Portal
PROFINET IO Device ET 200SP: Assigning the Device Name ONLINE
3.3.4 PROFINET IO Device ET 200SP: Assigning the Device Name ONLINE

om
.c
s an
offline

ru
configured name

bo
@ online
accessible device(s)
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

IP Address and PROFINET Device Name


The PROFINET device name of the IO-Device configured offline and the device name existing
online must match since the IO-Controller first checks the device names of the connected IO-
ry

Devices and then assigns the configured IP addresses during system startup. If an IO-Device is
not accessible under its configured device name, the IO-Controller cannot establish a
connection to the IO-Device.
The IP address of the IO-Device configured offline and the address existing online do not have
to match. The PROFINET name is relevant for the downloading of the hardware configuration. If
it exists, the online existing IP address is overwritten with the offline configured IP address.
m
Ways of Assigning a Name Online
co

In principle, there are two ways of assigning a PROFINET device name to an IO-Device online:
• Method 1 (safe, since there is no chance of typing errors)
n.

The assignment of the device name is triggered from the device configuration of the IO-Device.
Device configuration of IO-Device → Right-click on the Interface module (Slot 0) → Assign
sa

device name (see picture).


The advantage of this version is that the offline configured device name is adopted exactly and
ru

so no typing errors can be made.


• Method 2 (typing errors possible)
bo

The assignment of the device name is triggered via "Online access":


Project tree → Online access → Ethernet interface → IO-Device → Online & diagnostics →
Functions → Assign name
@

• Method 3 (Assign device name via communication table)


You can also assign the device names to several devices at the same time.
sa

See next page


m
sa
ry

3-7 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Network View – Assigning Device Names via the Communication Table
3.3.5 Network View – Assigning Device Names via the Communication Table

.c
Find devices online

an
Export or Import MAC addresses

Assign name for selected devices with the


status “Ready for assignment"

s
ru
bo
Status:

@
Select for MAC address Assign name, Ready for assignment,
assignment that is checked Access not possible,…
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

PROFINET device names assigned offline can be assigned to the relevant IO-Devices online
using the "Online assignment" tab.
With the help of the MAC addresses, several devices can be assigned the name simultaneously
(mass operation). The MAC addresses can be exported and also imported; for this, a CSV file is
created or required.

What to Do
1. Enter the MAC addresses. This can also be done with the Import function (CSV file). The
device is automatically selected (checkmarked) in the "Assign devices" column.
2. Check whether the devices are available online using the "Check devices" button. This is
m
done by checking the MAC address as well as the device family.
3. Using the "Assign now" button, assign the name online to all devices for which a MAC
co

address is entered, the checkbox "Assign device" is selected and that have the status "Ready
for assignment" (green flag).
n.

Possible Results after Checking


sa
ru
bo
@
sa
m
sa
ry

3-8 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Overview of Distributed I/O Systems

om
3.4 Overview Distributed I/O Systems

.c
SIMATIC ET 200M SIMATIC ET 200MP
High functionality, S7-300 modules I/O modules in the S7-1500 design
…PROFIBUS or PROFINET (up to 12 …the multi-channel and multi-functional

an
modules per station) I/O of the S7-1500

SIMATIC ET 200S SIMATIC ET 200SP

s
Discretely modular and multi-functional Compact I/O modules for variable design
…the scalable I/O with largest

ru
Hot Swapping and fixed wiring
Installation up into Ex-Zone 2 portfolio and smallest space requirement

bo
SIMATIC ET 200pro SIMATIC ET 200iSP
Modular and multi-functional: Power - Intrinsically safe (Ex i) and modular
modules, Motor starters, RFID modules, - Fail-safe modules (SIL3/Cat.4/PLe)
Fail-safe modules, CPU, Frequency - PROFIBUS
inverters
SIMATIC ET 200pro CPU
@
… the power of the S7-1500 in the compact
SIMATIC ET 200SP CPU
…the power of the S7-1500 in the
design of the ET 200pro compact design of the ET 200SP
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

SIMATIC ET 200AL SIMATIC ET 200eco and ET 200eco PN


m

I/O modules for IP65/67 Compact block I/O for IP65/66/67


…the robust I/O for the easiest assembly … for demanding applications
sa

anywhere
ry

c om
n.
a
r us
bo
@
sa
m
sa
ry

3-9 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
3.5PROFINET Addresses Addresses
PROFINET

.c
Device name: S7-CPU Device name: ET200SP

an
IP address: 192.168.111.102 IP address: 192.168.111.104
MAC address: 08 00 06 01 74 10 MAC address: 08 00 06 01 74 20

s
Subnet mask: 255.255.255.0 Subnet mask: 255.255.255.0

ru
bo
@
sa
PN/IE_1
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Internet Protocol
sa

The Internet Protocol (IP) is the basis for all TCP/IP networks. It creates the so-called datagrams
(data packets specially tailored to the Internet protocol) and handles their transport within the
local subnet or their "routing" (forwarding) to other subnets.
ry

IP Addresses
IP addresses consist of 4 bytes. With the dot notation, each byte of the IP address is expressed
by a decimal number between 0 and 255. The four decimal numbers are separated from one
another through dots (see picture).

PROFINET Device Name


In PROFINET, each RT / IRT device must be assigned a unique device name that is retentively
m
stored in the device. A module exchange without PG/PC is made possible through the device
names.
co

MAC Address
n.

Every Ethernet interface is assigned a fixed address by the manufacturer that is unique
worldwide. This address is referred to as the hardware or MAC address (Media Access Control).
sa

It is stored on the network card and uniquely identifies the Ethernet interface in a local network.
Cooperation among the manufacturers ensures that the address is unique worldwide.
ru

Subnet Mask
bo

The subnet mask specifies which IP addresses in the local network can be accessed. It separates
the IP address into the network and device part.
Only IP addresses whose network part is the same can be accessed.
@

e.g.: Subnet mask = 255.255.255.0 and IP address = 192.168.111.10


accessible IP addresses: 192.168.111.1 to 192.168.111.254
sa
m
sa
ry

3-10 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
PROFINET
3.5.1 Communication
PROFINET Model
Communication Model

.c
e.g. Read-out diagnostic
e.g. Call Web
IT Applications PROFINET applications data or program download

an
server on the CPU e.g. by means of a PG
HTTP
SNMP
1 Standard Process
DHCP... data data
Data exchange between

s
IO-Controller and IO-Device

Real time
TCP/UDP

ru
Internet Protocol (IP)

bo
2 RT / IRT

Ethernet Protocol

@ PROFINET based on
sa
Industrial Ethernet!
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Real-time Channel
sa

To be able to fulfill real-time requirements in automation, an optimized real-time


communication channel, the Realtime Channel (RT Channel), was specified in
ry

PROFINET. It uses Ethernet (Layer 2) as a base.


The addressing of the data packets does not take place in this case via an IP address, rather by
means of the MAC addresses of the participating devices. Such a solution minimizes the
throughput times in the communications stack considerably and leads to an increase in
performance with regards to the updating rate of automation data.

IRT Channel
Isochronous Real-time (IRT) as a further development with the following features:
• Clock-synchronous data transmission
om
• Cycle times <1ms with jitter accuracy <1µs
• Typical field of application is Motion Control
.c

IT Standards
an

The design of PROFINET WEB Integration focuses on commissioning and diagnostics. Access to
a PROFINET device from the Internet or Intranet is done with standard protocols (for example,
us

http). The data is transmitted in standard formats such as HTML or XML and can be presented
with standard browsers such as Opera or Internet Explorer.
r

This worldwide accessibility makes it easy for the application manufacturer to support the user
bo

with commissioning, device diagnostics etc. Access to the data is done via Web servers which
are integrated in the modules.
@
sa
m
sa
ry

3-11 SITRAIN
SIMATIC Programming 2 in the TIA Portal

Grouping
3.6 Devices
Grouping Devices

om
.c
s an
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

The individual devices (distributed I/O as well) can all be stored directly in the project. For better
sa

readability of the project, it is recommended to group the individual devices. For this, device
groups can be created in which the individual devices can be stored using drag & drop.
ry

c om
a n.
r us
bo
@
sa
m
sa
ry

3-12 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
3.7 Task Description (CLASSROOM):
Task Description:
Commissioning the ET 200SP Distributed I/O
Commissioning the ET 200SP Distributed I/O

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

© Siemens 2022 SITRAIN


sa

Task Description
The ET 200SP distributed I/O station is to be commissioned
ry

c om
a n.
r us
bo
@
sa
m
sa
ry

3-13 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 1 (CLASSROOM): Reading-out the Firmware Version of the ET 200SP
3.7.1 Exercise 1 (CLASSROOM): Reading-out the Firmware Version of the ET 200SP

.c
an
1

s
ru
MAC address

bo
of the ET 200SP

Assign temporary
IP address

2 @
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
ry

In the following exercises, in order to be able to check the configuration of the ET 200SP in the
Offline Project, you are to determine the firmware version of the ET 200SP online.

Problem
If the ET 200SP hasn’t been assigned an IP address, it is not possible to read out the firmware
version since an IP address is required for this diagnostic service.

What to Do
1. Open the "Online access" and there select the relevant interface.
m
2. There, activate "Update accessible devices" by double-clicking on it and wait until the list is
completed.
co

See the display in the Inspector window or in the status bar:


Scan completed. X compatible devices of y accessible devices found.
n.

3. Open the folder of the ET 200SP and activate the "Online & diagnostics" function.
4. Open the menu "Diagnostics -> General" and their check whether show the firmware
sa

version of the ET 200SP. If this the case, go to Step 9. Otherwise, go to step 5.


5. Switch to the "Functions -> Assign IP address" menu.
ru

6. Enter a temporary IP address as well as a subnet mask as shown in the picture and accept
the entry via "Assign IP address" (see top picture)
bo

7. In the Project tree, once again "Update" the list of "accessible devices".
8. In the device list, the ET 200SP is now displayed as a device with IP address. Once again
activate "Online & diagnostics" (see bottom picture).
@

9. Make note of the firmware version shown in the "Diagnostics -> General" tab.
10. Leave all windows open for the next exercise
sa
m
sa
ry

3-14 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 2 (CLASSROOM): ET 200SP: Reset to factory settings
3.7.2 Exercise 2 (CLASSROOM): ET 200SP: Reset to Factory settings

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
ry

All settings so far (IP address, subnet mask and PROFINET name) of the Interface module and
memory of the ET 200SP station are to be deleted through a "Reset to factory settings". In the
following exercises, you will then transfer your own settings onto the ET 200SP station.

What to Do
1. From the Online & diagnostics section opened in the last exercise, navigate to the menu
"Functions > Reset to factory settings"
2. Start the "Reset" function and confirm the follow-up dialog with "Yes".
3. Close the "Online & diagnostics" window.
om
4. Check the result of the reset in the Inspector window under "INFO > General". In addition,
after updating the accessible devices, you will find the ET 200SP in the list without an IP
address and without a device name.
.c

5. Leave all windows open for the next exercise.


an
r us
bo
@
sa
m
sa
ry

3-15 SITRAIN
SIMATIC Programming 2 in the TIA Portal

3.7.3 Exercise 3 (CLASSROOM): ET200SP Hardware Detection and Adopting

om
Exercise 3 (CLASSROOM): ET200SP hardware detection and adding it to the
it in the Project
project

.c
an
2

s
3

ru
bo
4

@ 1
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
ry

You are to insert the ET 200SP into the project as a distributed I/O.
In order to adopt the configuration in the project, it is read out with the help of the function
"Hardware detection > PROFINET devices from network…". The newly added ET 200SP is
stored in the Project tree in the "Ungrouped devices" folder, and since it initially is not assigned
to a controller, a link is entered in the "Unassigned devices" folder.

What to Do
m
1. In the Project tree, select the project name or a folder within your offline project.
2. Go into the menu ‘Online’ and select the function "Hardware detection > PROFINET
co

devices from network…"


3. Select the interface type and the interface and start the search.
n.

4. Select the device of the ET200SP Device series


sa

5. Start the determination of the configuration with the help of the "Add devices" button.
6. Save your project,
ru

Leave all windows open since they are still required in the next exercises!
bo
@
sa
m
sa
ry

3-16 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 4 (CLASSROOM): Networking the ET 200SP with the CPU

om
3.7.4 Exercise 4 (CLASSROOM): Networking the ET 200SP with the CPU

.c
s an
ru
bo
Open / Close
tabular area

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
Now that the configuration of the ET 200SP has been read-in, it must be connected to the
ry

already configured CPU and assigned to it.

What to Do
1. In the ‘Devices & networks’ editor, select the “Network view” and there press the "Network"
button (see picture).
2. Network the ET 200SP with the CPU by connecting the Ethernet interface of the ET 200SP
with the Ethernet interface of the CPU using drag & drop.
m
3. Select the newly created PROFINET IO-System and, in the "tabular area" under "I/O
communication", check the generated communication partners.
co

Result
n.

By assigning the ET 200SP as distributed I/O of the Controller "S7-1500", addresses can be
assigned to the modules of the ET 200SP. As well, the link in the Project tree is shifted from the
sa

"Unassigned devices" folder into the "Distributed I/O" folder of the "S7-1500" device.
ru
bo
@
sa
m
sa
ry

3-17 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 5 (CLASSROOM): Parameterizing the ET 200SP
3.7.5 Exercise 5 (CLASSROOM): Parameterizing the ET 200SP

.c
s an
ru
New potential group

bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

Task
The ET 200SP has digital and analog input and output modules which are to be connected to
the conveyor model in the following chapter. The I/O addresses used in the STEP 7 program
must match the addresses of the DI/DO modules parameterized here.
The address assignment can be made in the Properties of the individual module, or, as can be
seen in the picture, in the "tabular area" of the "Device view".

What to Do
1. In the ‘Devices & networks’ editor, select the "Device view" of the ET 200SP.
2. Configure the AI module in slot four in such a way that a new potential group is opened:
m
co
n.
sa
ru

3. Open the "tabular area" of the Device view (see picture) and enter the I/O addresses shown
bo

in the picture into the table.


4. Save your project.
@
sa
m
sa
ry

3-18 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal

3.7.6 Exercise 6 (CLASSROOM): Setting the Channel Parameters of the


Exercise 6 (CLASSROOM): Setting the Channel Parameters of the Distributed
Distributed Analog Modules

.c
Analog Modules

s an
ru
bo
channel 0

@ channel 1/2
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Unused
channels
ry

Task and What to Do:


1. Set the analog channels to the relevant parameters:
– Inputs
Channel 0 → Voltage 0..10 V
– Outputs
Channel 0 → Current 4..20 mA
Channel 1 → Voltage 0..10 V
Channel 2 → Voltage 0..10 V
2. Deactivate all unused analog inputs and outputs.
3. In addition, activate the Diagnostics for Overflow in the Settings of the analog input module
m
under "Input 0 – 3 > Inputs > Diagnostics".
co
n.
sa
ru
bo
@
sa
m
sa
ry

3-19 SITRAIN
SIMATIC Programming 2 in the TIA Portal

3.7.7 Exercise 7 (CLASSROOM): Assigning the IP Address / PROFINET Name

om
Exercise 7 (CLASSROOM): Assigning the IP Address / PROFINET Name
OFFLINE to the ET 200SP
OFFLINE to the ET 200SP

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
ry

The ET 200SP station isto be configured to work with the IP address, subnet mask, and the
PROFINET device name shown.

What to Do
1. In the ‘Devices & networks’ editor, select the "Device view" of the ET 200SP.
2. Select the IM module in Slot zero (0) and open the "Properties" tab in the Inspector window.
3. There, in the "General" tab, select the "General" menu and enter the device name under
m
"Name".
co

4. Then select the "Ethernet addresses" menu and under "IP protocol" enter the IP address
and subnet mask shown (see picture).
5. In the same menu you will also find the PROFINET device name. If the property "Generate
n.

PROFINET device name automatically" is activated, it cannot be changed here, but the
name that you previously edited in the "General" menu is automatically adopted.
sa

6. Change the device number as shown in the picture.


ru

7. Save your project.


bo
@
sa
m
sa
ry

3-20 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
3.7.8 Exercise 8 (CLASSROOM): ET 200SP: Assigning the device name ONLINE
Exercise 8 (CLASSROOM): ET 200SP: Assigning the Device Name ONLINE via
via the communication table
the Communication Table

.c
s an
ru
bo
1. Check devices

assignment
@
2. Select devices for
MAC address was already
sa
read-in
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

3. Assign name
m
sa

Task
ry

The PROFINET device name previously assigned offline must now be assigned to the
ET 200SP online, so that the IO-Controller or the CPU can assign the offline-configured IP
address during system startup of the ET 200SP. This name can be entered online, using the
function "Assign device name", for each distributed I/O individually, or, with the help of a
communication table, it can be carried out for all simultaneously. Here, however, the MAC
addresses of the devices must be known. Since the MAC address was also transferred when
the configuration of the ET 200SP was read-in, you can use this function here.
m
What to Do
1. In the ‘Devices & networks’ editor, switch to the Network view.
co

2. In the "tabular area", open the "I/O communication" tab.


3. Press the "Online assignment" button (see top picture).
n.

4. Start the checking of the network with the function "Check devices"
sa

Since the distributed I/O was read-in via the function "Hardware detection" in Exercise 3,
the MAC address of the ET 200SP is already entered and is therefore also found.
ru

Result: The ET 200SP is given the status "Ready for assignment" and is selected in the
column "Assign device".
bo

5. Start the assignment of the offline-name to the device existing online with the help of the
"Assign now" button.
@

Note:
If the device is selected in the column "LED flashes", then all LEDs (RUN/STOP, ERROR,
sa

MAINTENANCE as well as the interface LEDs) flash on the header module.


m
sa
ry

3-21 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Exercise 9 (CLASSROOM): Creating a new Device group and grouping devices
3.7.9 Exercise 9 (CLASSROOM): Creating a new device group and grouping devices

.c
s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

Task:
The devices (Controller and IO-Device) are to be stored in a common group.

What to Do
1. Right-click the Project name to open the contex menu. Create a new group.
2. Rename it "Area_1"
3. Move the Controller "S7-1500" and the IO-Device "ET200SP" into the folder "Area_1"
4. Save your project.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

3-22 SITRAIN
SIMATIC Programming 2 in the TIA Portal

3.7.10 Exercise 10 (CLASSROOM): Compiling the changes and loading them

om
Exercise 10 (CLASSROOM): Compiling the changes and loading them into the
into the CPU
CPU

.c
an
3. Download into CPU
1. Compile

s
ru
2. Save

bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
ry

Now that the PROFINET I/O system is completely configured and parameterized, the project
must be completely compiled, saved, and downloaded into the CPU.

What to Do
1. Compile the hardware configuration by selecting the S7-1500 station in the Project tree and
then clicking on the "Compile" button (see picture). In the Inspector window under "Info",
check whether the compilation was successful. Should errors have occurred, correct them.
om
2. Save your project.
3. Download the entire station into the CPU by clicking on the "Download" function (see
picture). In the Inspector window under "Info", check whether the download was successful.
c

4. Check the module LEDs of your training device: Only green LEDs should be lit and not
n.

flashing!!!
5. Save your project.
a
us

Result
r

Only green LEDs should be lit on the CPU as well as on all modules of the ET 200SP!
bo
@
sa
m
sa
ry

3-23 SITRAIN
SIMATIC Programming 2 in the TIA Portal

3.8 Task Description (ONLINE):

om
Task Description:
Commissioning the ET 200SP Distributed I/O
Commissioning the ET 200SP Distributed I/O

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

© Siemens 2022 SITRAIN


Task Description
sa

The ET 200SP distributed I/O station is to be commissioned


ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

3-24 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise
3.8.1 1 (ONLINE):
Exercise Offline Project:
1 (ONLINE): OfflineAdding theAdding
Project: ET 200SP
the ET 200SP

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

An ET 200SP is to be inserted into the project as a distributed I/O station.


PROFINET IO-Devices are added in the Network view. Here, you can insert the relevant
ry

devices into the project by dragging & dropping them from the Hardware catalog.
In the beginning, the newly added ET 200SP is not assigned to any controller and therefore
appears in the Project tree as an "Unassigned device" in the same level as the PLCs and HMIs.

What to Do
1. In the Project tree, open the Hardware and Network editor by double-clicking on it.
2. Open the Hardware catalog Task Card and there
Distributed I/O -> ET 200SP -> Interface modules -> PROFINET -> IM155-6PN ST
3. Select the IM module used in your training device, open the Information window and there
om
select the Firmware version of your IM module.
4. Using drag & drop, drag the IM module into the Hardware and Network editor (see picture)
c
n.
sa
ru
bo
@
sa
m
sa
ry

3-25 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
ExerciseExercise
3.8.2 2 (ONLINE): NetworkingNetworking
2 (ONLINE): the ET 200SP with
the ETthe CPU with the CPU
200SP

.c
s an
ru
bo
Open / Close
tabular area

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

Now that the configuration of the ET 200SP has been read-in, it must be connected to the
already configured CPU and assigned to it.
ry

What to Do
1. In the ‘Devices & networks’ editor, select the Network view and there select the "Network"
tab.
2. Network the ET 200SP with the CPU by connecting the Ethernet interface of the ET 200SP
with the Ethernet interface of the CPU using drag & drop.
3. Select the newly created PROFINET IO-System and, in the "tabular area" under "I/O
communication", check the generated communication partners.

Result
om
By assigning the ET 200SP as distributed I/O of the Controller "S7-1500", addresses can be
assigned to the modules of the ET 200SP. As well, the link in the Project tree is shifted from the
"Unassigned devices" folder into the "Distributed I/O" folder of the "S7-1500" device.
.c
an
r us
bo
@
sa
m
sa
ry

3-26 SITRAIN
SIMATIC Programming 2 in the TIA Portal
ExerciseExercise
3 (ONLINE): Parameterizing the ET 200SP

om
3.8.3 3 (ONLINE): Parameterizing the ET 200SP

.c
s an
New potential group

ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
The ET 200SP has digital and analog input and output modules which are to be connected to
sa

the conveyor model in the following chapter. The I/O addresses used in the STEP 7 program
must match the addresses of the DI/DO modules parameterized here.
ry

The address assignment can be made in the Properties of the individual module, or, as can be
seen in the picture, in the "tabular area" of the "Device view".

What to Do
1. In the ‘Devices & networks’ editor, select the "Device view" of the ET 200SP.
2. Configure the AI module in slot four in such a way that a new potential group is opened:
c om
a n.
us

3. Open the "tabular area" of the Device view (see picture) and enter the I/O addresses shown
r

in the picture into the table.


bo

4. Save your project.


@
sa
m
sa
ry

3-27 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
3.8.4 Exercise 4 (ONLINE): Setting the Channel Parameters of the Distributed
ExerciseAnalog
4 (ONLINE): Setting the Channel Parameters of the Distributed Analog
Modules
Modules

.c
s an
ru
channel 0

bo
@ channel 1/2
sa
Unused
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

channels
m
sa

Task and What to Do:


1. Set the analog channels to the relevant parameters:
ry

– Inputs
Channel 0 → Voltage 0..10 V
– Outputs
Channel 0 → Current 4..20 mA
Channel 1 → Voltage 0..10 V
Channel 2 → Voltage 0..10 V
2. Deactivate all unused analog inputs and outputs.
3. In addition, activate the Diagnostics for Overflow in the Settings of the analog input module
under "Input 0 – 3 > Inputs > Diagnostics".
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

3-28 SITRAIN
SIMATIC Programming 2 in the TIA Portal

3.8.5 Exercise 5 (ONLINE): Assigning the IP Address / PROFINET Name


ExerciseOFFLINE
5 (ONLINE):
to Assigning the IP Address / PROFINET Name OFFLINE to

om
the ET 200SP
the ET 200SP

.c
s an
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

Task
The ET 200SP station is later to work with the IP address, subnet mask and the PROFINET
sa

device name shown.


ry

What to Do
1. In the ‘Devices & networks’ editor, select the "Device view" of the ET 200SP.
2. Select the IM module in Slot zero (0) and open the "Properties" tab in the Inspector window.
3. There, in the "General" tab, select the "General" menu and under "Name" enter the device
name.
m
4. Then select the "Ethernet addresses" menu and under "IP protocol" enter the IP address
and subnet mask shown (see picture).
co

5. In the same menu you will also find the PROFINET device name. If the property "Generate
PROFINET device name automatically" is activated, it cannot be changed here, but the
n.

name that you previously edited in the "General" menu is automatically adopted.
6. Change the device number as shown in the picture.
sa

7. Save your project.


ru
bo
@
sa
m
sa
ry

3-29 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
ExerciseExercise
3.8.6 6 (ONLINE): Creating a Creating
6 (ONLINE): new Device group
a new and grouping
device devices
group and grouping devices

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task:
sa

The devices (Controller and IO-Device) are to be stored in a common group.


ry

What to Do
1. Right-click on the project name to open the context menu. Create a new group.
2. Rename it "Area_1"
3. Move the Controller "S7-1500" and the IO-Device "ET200SP" into the folder "Area_1"
4. Save your project.
om
.c
an
r us
bo
@
sa
m
sa
ry

3-30 SITRAIN
SIMATIC Programming 2 in the TIA Portal
ExerciseExercise
3.8.7 7 (ONLINE): Compiling Compiling
7 (ONLINE): the changesthe
andchanges
loading them into the CPU
and loading them into the CPU

om
.c
3. Download into CPU

an
1. Compile

2. Save

s
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
m

Now that the PROFINET I/O system is completely configured and parameterized, the project
sa

must be completely compiled, saved and downloaded into the CPU.

What to Do
ry

1. Compile the hardware configuration by selecting the S7-1500 station in the Project tree and
then clicking on the "Compile" function (see picture). In the Inspector window under "Info",
check whether the compilation was successful. Should errors have occurred, correct them.
2. Save your project.
3. Download the entire station into the CPU by clicking on the "Download" function (see
picture). In the Inspector window under "Info", check whether the download was successful.
om
4. Check the module LEDs of your training device: Only green LEDs should be lit and not
flashing!!!
5. Save your project.
c
a n.

Result
us

Only green LEDs should be lit on the CPU as well as on all modules of the ET 200SP!
r
bo
@
sa
m
sa
ry

3-31 SITRAIN
SIMATIC Programming 2 in the TIA Portal

3.9 Appendix

om
Installing Distributed Peripherals Later On with GSD
3.9.1 Installing Distributed Peripherals Later On with GSD

.c
s an
ru
bo
@
Find file
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

GSD (General Station Description) File


STEP 7 requires a GSD or a type file for every distributed IO slave so that the module can be
configured from the Hardware catalog.
GSD files contain all necessary communication properties of a distributed I/O module according
to the PROFIBUS/PROFINET standard.
A GSD file is normally supplied with distributed I/O modules or is available as a download from
the Internet.
m
Many SIEMENS modules are already generally a part of the Hardware catalog.
co

Modules Added to the Hardware Catalog


Following installation, these are entered in the "Other field devices" section and are available
n.

there for the configuration.


sa
ru
bo
@
sa
m
sa
ry

3-32 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Firmware Update
3.9.2 Firmware Update

.c
an
Firmware of the modules can be updated
→ Display and modules (CPU, TM, SM, CP, CM, distributed I/O)

s
Possibilities of a Firmware Update:

ru
• Offline, using SIMATIC Memory Card with the Windows Explorer
• Offline, using SIMATIC Memory Card by means of card creation in TIA Portal

bo
• Online, independent of the project in TIA Portal via Accessible devices (Life List)
• Online, project-dependent in TIA Portal via “Online & diagnostics” of the module
• Online, by means of the Web Server

@
→ the Firmware of the distributed I/Os can only be updated online

Approach:
sa
1 Download the new Firmware file via the Industry Online Support
or via the “TIA Portal Information Center” > Downloads > Firmware
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

2
...depending on selected possibility of an update
...depending on loaded Firmware files
sa
ry

Procuring the new Firmware is always the first step.


The next steps depend on the selected update possibility.

Firmware Update → Important Facts


During an update, the supply voltage must not fail or be removed.
Distributed I/Os without memory card can only be updated online using STEP 7 or Web Server.
After updating the CPU or the Display (only S7-1500), the CPU should be switched off, an
empty memory card inserted in the CPU and the CPU switched back on.
It is possible to do a simultaneous update of several modules offline using the memory card.
→ Respective Firmware update files are stored in the folder for the Firmware update.
m
The Sequence is Relevant if Several Module Types are Updated
1. Update of the Display Firmware (only S7-1500)
co

2. Update of the central I/O modules


n.

3. Update of the distributed I/O modules


4. Update of the Boot loader of the CPU
sa

5. Update of the CPU


ru
bo
@
sa
m
sa
ry

3-33 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Firmware Update → Offline, using SMC with the Windows Explorer
Firmware Update → Offline, using SMC with the Windows Explorer

om
3 After the SMC has been erased, copy the

.c
FWUPDATE.S7S folder with the actual Firmware
files as well as the S7_JOB.S7S file onto the SMC.

an
4 Switch off the power supply of the CPU
Insert the card into the card slot of the CPU

s
and then switch the power supply of the CPU back on

ru
5 During the update, the Display shows a progress
bar and the left LED of the CPU flashes orange

bo
6 After the update, the status is shown in the Display
update...
as a message and the left LED is orange
and the right LED flashes orange
7 Remove the card
@ ...%

8 Switch off the power supply of the CPU, erase data on the card, re-insert card, and
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

switch the power supply of the CPU back on


m

When the CPU or the Display is updated, Step 8 is necessary in any case. However, this is
sa

also recommended at the end of every module update.


ry

Status of the Update in the Display (only S7-1500)


Only the S7-1500 has a Display.

Status of the Update with LEDs


If the middle LED (red, error) lights up, the update was not successfully completed or it could
not be carried out.
om
Necessary Firmware Update Files
Directory with FW files (FWUPDATE.S7S) and data ID file (S7_JOB.S7S)
c

Empty Card (Windows Explorer)


a n.
us

Do NOT delete
hidden files!!!
r
bo
@
sa
m
sa
ry

3-34 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Firmware Update → Offline, using SMC by means of Card Creation in the TIA
Firmware Update → Offline, using SMC by means of Card Creation in the TIA Portal
Portal

om
3 Save the Firmware files “MLFB Version.upd” (e.g.: )

.c
Card does NOT have to be erased first if there is existing data on the card

an
4 Create

s
ru
bo
Select
Firmware files
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

5 Step 6 ... as8 as for “Offline using SIMATIC Memory Card with the Windows Explorer”
m
sa

Necessary Firmware Update File e.g.


FW file (MLFB Version.upd)
ry

Card Contents
The SMC for the update does not have to be erased first. During creation you are prompted as
to whether the card is to be erased or not:
m
co
n.
sa

• Yes
ru

Card is erased and update card is created



bo

No
The update is only added to the card contents and the card type is set to "Update firmware".
This can only be done for updating the Display since the program is active and CPU + I/O
modules cannot be updated in this state.
@

For updating the CPU or the Display, an empty card is necessary in order to conclude
the update (see Step 8).
sa

For that reason, it is generally recommended to erase the "Program" card or to use a
separate card for updates.
m


sa
ry

3-35 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Firmware Update → Online, Independent of the Project in TIA Portal (Life List)

om
Firmware Update: Online, Independent of the Project in TIA Portal (Life List)

.c
3 Save the Firmware files “MLFB Version.upd” on the computer

an
4 Update Accessible devices Open Online & diagnostics > Firmware update and select
relevant module as well as associated Firmware file.

s
ru
5
Select Firmware file

bo
@
sa
6
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

7 Restart CPU
sa

An update can also be carried out for all devices and modules with the help of the Life List, thus
independently of the project.
ry

You start the online diagnostics via the Accessible devices; select the relevant module and the
associated Firmware file on the computer

m
co
n.

and then start the update.


sa
ru
bo
@
sa
m
sa
ry

3-36 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Firmware Update → Online, Project-dependent in TIA Portal

om
Firmware Update: Online, dependent of the Project in TIA Portal

.c
3 Save the Firmware files “MLFB Version.upd” on the computer

an
4 Open project and establish an online connection with the CPU
CPU should be switched to STOP for updates of I/O modules

s
ru
5 Select Firmware
file

bo
@
sa
6
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

7 Restart CPU
m
sa

Before starting (running) the update, the appropriate *.upd must be selected.
ry

m
co

Before starting (running) an update of I/O modules, the CPU should be switched to
STOP, if the active user program uses this module.
n.

Waiting until update is completed...


sa
ru
bo
@
sa

CPU Update
Advantage: The current "Program" card is not changed.
m

Attention!
The retentiveness is however deleted, that is, the program is then reset to the loading state.
sa
ry

3-37 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Firmware Update:→
FirmwareUpdate Online
Online by by means
means ofWeb
of the the Server
Web Server

.c
3 Save the Firmware files “MLFB Version.upd” on the computer

an
4 Open Internet browser and open Web server by entering the IP address

s
5 In the menu “Module information” open the desired station and choose the module

ru
Authorization for Firmware Update must exist in the Web server’s settings

bo
@
sa
6
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Select Firmware file


7 Restart CPU
sa
ry

In order to be able to perform a firmware update by means of the Web server, the Web server
must be activated in the Properties of the CPU and a user must be authorized for performing
firmware updates.

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

3-38 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
NetworkNetwork
3.9.3 View - I/OView
Communication - Offline Configuration
- I/O Communication - Offline Configuration

.c
an
s
ru
Update time can be
Device must be changed

bo
activated from
within the program

@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Optional IO-Device:
Devices which are selected (highlighted) here do not exist as far as the CPU is concerned and
ry

must be explicitly made known in the user program.

Update Time:
The Update Time is the time interval in which an IO-Device/IO-Controller in the PROFINET IO-
System is supplied with new data by the IO-Controller/IO-Device.

Update Time Mode:


The update mode can be set to either ‘Automatic’ or ‘Can be set’.
For the ‘Can be set’ update mode, the update time must be set; for ‘Automatic’, the time is
calculated by the system.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

3-39 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Network View - I/O Communication - Online Assignment
Network View - I/O Communication - Online Assignment

om
.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Via the "Online assignment" tab, PROFINET device names assigned offline can be assigned to
the relevant IO-Devices online.
sa

With the help of the MAC addresses, several devices can be assigned the name simultaneously
(mass operation).
ry

What to Do:
1. Enter the MAC addresses. This can also be done with the Import function (CSV file). The
device is automatically selected (checked) in the "Assign devices” column.
2. Check whether the devices are available online via the "Check devices” button.
3. Via the "Assign now” button, assign the name online to all devices for which a MAC address
m
is entered, the checkbox in the column "Assign devices” is checked and which have the
Status "Ready for assignment" (green flag).
co
n.
sa
ru
bo
@
sa
m
sa
ry

3-40 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal

4 PLC Tags

.c
an
4.1LearningLearning
objectives objectives

s
ru
• You know the difference between local and global tags

bo
• You know the different data types

• You know the importance of the complex data types

@
• You know the data types ARRAY, STRUCT, and PLC data type

• You know how to declare a PLC tag table


sa
• You are familiar with user constants and system constants
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

• You are able to monitor and modify tags


sa
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

4-1 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Importance of Variables and Data Types
4.2 Meaning of Variables and Data Types

.c
an
Variables represent the abstraction of reality
and permit you to save and later continue to
process values.

s
By declaring a variable, the following

ru
properties are defined:
• Symbolic name

bo
Memory area
• Validity range
• Data type

The data type establishes:



@
The possible value range
(e.g. INT: -32 768 to +32 767)
Actual_speed: REAL

Set_speed: REAL
sa
• The permitted instructions
(e.g. math instructions: +I, -I) Fault: BOOL
Private copy for Recep Yigit Samsa, rysamsa@borusan.com


m

How the bits in the memory are to be interpreted


(integer; hexadecimal number; floating-point number; etc.) Enable: BOOL
sa

The Importance of Variables


ry

Next to instructions, variables are the most important elements of a programming system. Their
task is to save values in a program so that they can be further processed at a later time. The
value of a variable can be saved "anywhere" in the PLC memory.
The data represents an abstraction of reality in which irrelevant properties of objects are
ignored.

Data Types
It is often quite difficult to decide how data is to be represented and the available possibilities
quite often restrict the choice. On the one hand, the object properties described by the data
om
must be correctly reflected. On the other hand, it must also be possible to carry out the
instructions necessary for process with the data.
The data type determines which values are accepted by tags and which instructions can be
.c

carried out with these values. The data type uniquely defines
• the possible value range
an

• the permitted instructions


r us
bo
@
sa
m
sa
ry

4-2 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Global and Local Tags, Constants, and Parameters
4.2.1 Global and Local Tags, Constants, and Parameters

.c
an
Global Local

s
• Valid throughout the entire CPU, i.e. • Are only valid in the block in which they
Validity all blocks have access have been declared (defined)

ru
range • The name of the tag must be unique • The name of the tag must be unique within

bo
within the entire CPU the block

• Parameters (IN / OUT and INOUT)


• Inputs
(in function and function blocks)
• Outputs
Operands



Memory bits

@
Global constants
Tags in data blocks
• Temporary variables
(in all code (logic) blocks)
• Static variables / locale constants
sa
• SIMATIC Timers / Counters
(only in function blocks)

Location of • PLC tag table


Private copy for Recep Yigit Samsa, rysamsa@borusan.com

• Declaration part of the block


declaration • Global data blocks
sa

• Presented in quotation marks • Presented preceded by #


Presentation Example: "Max" Example: #Max
ry

Validity Range of Tags


Tags and constants that are declared in the PLC tag table or in a global data block can be
addressed by all CPU program blocks. For that reason, these tags are called global tags.
Tags and constants that are declared in the declaration part of a code (logic) block are local
tags. Local tags and parameters can only be used in the statement part of the same block.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

4-3 SITRAIN
SIMATIC Programming 2 in the TIA Portal

4.3 Overview Data Types

om
Overview Data Types Elementary Data Types (Bit and Numeric)
4.3.1 Elementary Data Types (Bit and Numeric)

.c
Description Size (Bit) S7-1200 S7-1500 Example

an
Bit BOOL 1 TRUE
BYTE 8 B#16#F5

s
Data Types WORD 16 W#16#F0F0

ru
DWORD 32 DW#16#F0F0FF0F

LWORD 64 LW#16#5F52DE8B

bo
Numeric Data SINT 50
8
USINT 20
Types @
INT -23
16
UINT 64530

DINT DINT# -2133548520


Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

UDINT 32 UDINT#435676
REAL 1.0
m

LREAL 64 LREAL#-1.0e-5
sa

LINT LINT#1543258759
64
ULINT ULINT#154316159
ry

BOOL, BYTE, WORD


Variables of the data type BOOL consist of one bit. Variables of the data types BYTE and
WORD are bit sequences of 8 or 16 bits, respectively. The individual bits are not evaluated in
these data types. Special forms of these data types are the BCD numbers and the count value
as it is used in conjunction with the count function.
m
INT, REAL
co

Variables of these data types represent numbers with which relevant arithmetical calculation
operations can be carried out. (INT –> integer, REAL -> floating point number)
n.

Extensions of INT, REAL and WORD


sa

U - Unsigned
Variables with the extension “U” represent a variable without sign of the relevant data type. Data
ru

types: USINT, UINT, UDINT, ULINT


bo

S - Short
Variables with the extension “S” represent a variable with a length of 8 bits of the relevant data
type. Data types: SINT, USINT
@

D - Double
sa

Variables with the extension “D” represent a variable with a length of 32 bits of the relevant data
type. Data types: DWORD, DINT, UDINT
m

L- Long
Variables with the extension “L” represent a variable with a length of 64 bits of the relevant data
sa

type. Data types: LWORD, LINT, ULINT, LREAL


ry

4-4 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Elementary
4.3.2
Data Types (time and character )
Elementary Data Types (time and chararcters)

.c
Description Size (Bit) S7-1200 S7-1500 Example

an
Time Types TIME 32 T#2h46m30s630ms
16

s
DATE D#1994-01-21

ru
TIME_OF_DAY 32 TOD#18:15:18:999

S5TIME 16 S5T#1h24m10s

bo
LTime LT#11350d20h25m14s830ms652µs315ns
LTIME_OF_DAY 64
LTOD#10:20:30.400_365_215

Character Type
LDT
(DATE_AND_LTIME)

CHAR
@ 8
LDT#2008-10-25-08:12:34.567

‘R’
sa
WCHAR 16
WCHAR#'w'
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

TIME, LTIME
ry

A variable of the data type TIME (duration in [ms]) occupies a double-word. This variable is
used, for example, for specifying time values in IEC timer functions. The contents of the
variable are interpreted as a DINT number in milliseconds and can be either positive or negative
(for example: T#5m1s43ms = L#301043). Like TIME, the LTIME data type represents a
duration. In LTIME, the duration is saved with nanosecond resolution in 64 bits. Longer
durations with greater resolution can be saved in variables of the data type LTIME.

DATE
A variable of the data type DATE is stored in a word in the form of an unsigned integer. The
contents of the variable represent the number of days since 01.01.1990.
om

TIME_OF_DAY, LTIME_OF_DAY
.c

The data type TOD (TIME_OF_DAY) occupies a double-word and stores the number of
milliseconds since the beginning of the day (0:00 o‘clock) as an unsigned integer. Variables of
an

the data type LTOD occupy two double-words and state the number of nanoseconds since the
beginning of the day.
us

LDT (Date_AND_LTIME)
The data type LDT (DATE_AND_LTIME) occupies 8 bytes and stores information on date and
r

time in nanoseconds since 01.01.1970 0:00.


bo

S5TIME
Variables of the data type S5TIME are required for specifying time values in timer functions (S5-
@

timing elements). You specify the time in hours, minutes, seconds or milliseconds. You can
enter the timer values with an underscore (1h_4m) or without an underscore (1h4m).
sa

CHAR, WCHAR
The data type CHAR (8 bits) represents a character in ASCII representation and WCHAR (16
m

bits) a character in Unicode format.


sa
ry

4-5 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Complex Data Types (Point in time and Strings)
4.3.3 Complex Data Types (Point in time and Strings)

.c
Data type Length (Bits) S7-1200 S7-1500 Example

s an
DT
64 DT#2008-10-25-08:12:34.567
(DATE_AND_TIME)

ru
bo
DTL 96 DTL#1976-12-16-20:30:20.250

8*
STRING

@
(Number of ´This is a String´
characters+2)
max. 254 characters in ASCII format
sa
16 * WSTRING#´STRING in UNICODE
WSTRING
(Number of format´
(Wide Character String) characters+2)
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Up to 16382 characters in Unicode format


sa

DT
ry

The data type DATE_AND_TIME represents a point in time consisting of the date and the time-
of-day. Instead of DATE_AND_TIME, the abbreviation DT can also be used. The information
about the date and the time-of-day is stored in 8 bytes.

Byte Contents Range of values


0 to 99 (Years 1990 to 2089)
BCD#90 = 1990
0 Year …
BCD#0 = 2000

om
BCD#89 = 2089
1 Month BCD#0 to BCD#12
2 Day BCD#0 to BCD#31
c
n.

3 Hour BCD#0 to BCD#23


4 Minute BCD#0 to BCD#59
sa

5 Second BCD#0 to BCD#59


ru

6 The two most significant digits of MSEC BCD#0 to BCD#999


7 (4MSB) The least significant digit of MSEC BCD#0 to BCD#9
bo

BCD#1 to BCD#7
BCD#1 = Sunday
7 (4LSB) Weekday

@

BCD#7 = Saturday
sa
m
sa
ry

4-6 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
DTL
The data type DTL has a length of 12 bytes and, like LDT, stores information on date and time-

.c
of-day precise to the nanosecond since 1.1.1970, only in a pre-defined structure.
Advantage: the individual values (day, hour, etc.) are easier to read out.

an
Byte Component Data type Range of values

s
0-1 Year UINT 1970 to 2554

ru
2 Month USINT 1 to 12

bo
3 Day USINT 1 to 31
1 (Sunday) to 7 (Saturday)
4 Weekday USINT
@ The weekday is not considered in the value entry.
5 Hour USINT 0 to 23
6 Minute USINT 0 to 59
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

7 Second USINT 0 to 59
8 -11 Nanosecond UDINT 0 to 999 999 999
m

STRING
sa

The data type STRING stores several ASCII characters of the data type CHAR in a character
string with a maximum of 254 characters. The current length and maximum length of the
ry

character string are also stored.

WSTRING
The data type WSTRING (Wide Character String) stores several Unicode characters of the data
type WCHAR in a character string with a maximum of 16382 characters. The information about
the current and maximum character string is also stored.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

4-7 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
ComplexComplex
4.3.4 Data Types (Arrays
Data Typesand(Arrays
Structures)
and Structures)

.c
an
Data type Length (Bits) S7-1200 S7-1500 Example

ARRAY User-defined Measured values: ARRAY[0..19] of INT;

s
ru
Motor: STRUCT
Act-Speed : REAL;
STRUCT User-defined Set-Speed : UINT;

bo
Fault : BOOL;
END_STRUCT
Use
Define
(in data blocks , interfaces

@
(in the PLC-data types
and
folder)
PLC- as PLC tags)
Data type User-defined PLC-DT1: STRUCT
(UDT) Motor1 : PLC-DT1;
Speed: REAL;
sa
Motor2 : PLC-DT1;
Enable: BOOL;
Motor3 : PLC-DT1;
Fault: BOOL;
:
END_STRUCT
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Arrays and Structures consist of groups of elementary or complex data types.


They enable you to create data types suitable for your task with which you can structure large
ry

quantities of data and process it symbolically.

ARRAY and STRUCT


ARRAYs and Structures can only be declared within global data blocks and as parameters or
local tags of code blocks.

PLC-Data Type (User-defined Data Type)


PLC data types are complex user-defined data types which can be used for the declaration of
variables/tags. They represent data structures made up of several components of different data
types. The components can be elementary or complex data types, other PLC data types, or
even Array tags.
The big advantage here is that structures that are used repeatedly only have to be declared
m
once. Adjustments and expansions of these structures only have to be done in one place.
co
n.
sa
ru
bo
@
sa
m
sa
ry

4-8 SITRAIN
SIMATIC Programming 2 in the TIA Portal

Importance
4.4 of Complex
Meaning ofData Types Data Types
Complex

om
.c
Motor: STRUCT /
"Better" structuring of data: PLC-data type
Set_speed: REAL

an
• Adapted to the task
Actual_speed: REAL
• With "correct" data type
Enable: BOOL

s
Fault: BOOL
END_STRUCT

ru
Compact form of data passing in a
block call:

bo
• "Many" data items can be in … … In …... …
passed in one parameter out ... ... Out ....... …
INOUT … … INOUT Motor STRUCT /
• Makes structured programming stat Controller FBX
PLC-data type
possible
• Easy implementation of
communication between the
blocks via the parameters
@ Controller
5
Motor.
Enable
&

• Re-usable software
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

"Hall_1".M[5] Motor
m

Complex Data Types


sa

Complex data types (arrays, structures, PLC-data types) result from the grouping of elementary
or complex data types.
ry

Complex data types are useful for organizing complex data. In this way, the programmer can
define data structures according to his task. He can combine elementary, logically-related
information units to a new "unit" with its own name.
A typical example for a structure is the data record (data set) for a drive. The drive is described
as a record of attributes (properties, states), such as, #Set_speed, #Actual_speed, #Enable,
and #Fault. Some of these attributes could in turn be structures.
om
Structured Programming
Complex data, in particular, can be passed in a block call as a unit. That is, in one parameter to
c

the called block.


n.

In this way, a multitude of elementary information units can be transferred between the calling
and the called block in an elegant and compact manner.
a

Advantage
us

This type of data transfer makes a practical structured programming possible and guarantees a
high degree of re-usability of structures created once.
r
bo
@
sa
m
sa
ry

4-9 SITRAIN
SIMATIC Programming 2 in the TIA Portal
ARRAY Data Structure

om
4.4.1 ARRAY Data Structure

.c
Array [0..9] of LREAL with the name "Value"
(10 elements of the data type LREAL)

s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Array
An array consists of several elements of the same data type. In the picture above, you can see
ry

the array "Value" with 10 elements of the data type LREAL. Later, various measured values are
to be stored in this array.

Declaring an Array in the DB


The data type of an array is called "ARRAY[n..m]". The first element (n) and the last element
(m) are specified in the square brackets. In the example, [0..9] means 10 elements, whereby the
first element is addressed with the index [0] and the last with the index [9]. Instead of [0..9] you
could, for example, define [20..29]. This only influences the access to the elements.
c om
a n.
r us
bo
@
sa
m
sa
ry

4-10 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
STRUCT Data Structure
4.4.2 STRUCT Data Structure

.c
an
Structure with the name "Motor":
(several elements with different data types)

s
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Structure
ry

The picture shows an example of a structure named "Motor". The structure consists of several
elements of different data types. The individual elements of a structure can be elementary or
complex data types.
The access to the individual elements of a structure contains the structure name and the name
of the element. This makes the program easier to read.
Example: accessing individual elements of a structure:
• "Test-DB".Motor.Status
• "Test-DB".Motor.Drive
"Test-DB" is the symbol name of the data block which contains the structure. After the symbol
m
name (separated by a dot), the structure name is specified. After the structure name (separated
by a dot), an element name of the structure follows.
co

Declaring a Structure in the DB


As a keyword for a structure, "STRUCT" is used. The end of the structure is automatically
n.

identified with "END_STRUCT". A name is defined for the structure (in the example: "Motor").
sa
ru
bo
@
sa
m
sa
ry

4-11 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
PLC Data Type
4.4.3 PLC Data Type

.c
s an
ru
bo
The structure can always be re-used in the program,
in data blocks, as a parameter, as a static or temporary variable, or as a PLC tag

@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

PLC Data Types


PLC data types are data types defined by you that are used as templates for declaring
parameters and variables of complex data types (e.g. structure variables). PLC data types are
created and stored in the PLC data types folder, and contain a data structure that is made up of
elementary and/or complex data types. In the declaration of a variable according to PLC data
type, a structure variable is created whose inner data structure is defined by the PLC data type.
PLC data types can be used for the declaration of PLC tags, variables in global data blocks, and
within blocks for the declaration of local variables (TEMP, STAT) as well as parameters (IN,
OUT and INOUT).

Access with PLC data types on I/O areas


m
PLC data types can be used to declare input and output area in a fast and easy way and
additionally to access these areas symbolically and structured.
co

LPD - Libraries with PLC data types for S7-1200 / S7-1500


n.

From the Online Support (Entry ID: 109482396) you can download the library “LPD (Library of
PLC Data types)". The library contains PLC data types which describe the data structure of the
sa

address spaces and the data records of peripheral and technology modules.
With the PLC data types for the address spaces, you can create PLC tags and with them
ru

symbolically and structurally access the input and output area in the user program.
With the PLC data types for parameter data records, you can create data records to
bo

parameterize modules which can then be transferred to the modules via the WRREC
instruction.
@
sa
m
sa
ry

4-12 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
PLC Tags andPLC
4.5 PLC tags
Constants
and PLC constants

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

PLC tags and constants


ry

...have a symbolic name with a maximum of 128 characters.


The PLC tag table contains the declaration (definition) of CPU-wide valid and thus global tags
and constants. For each CPU added in the project, a PLC tag table is automatically created.
The PLC tag table contains one tab each for Tags, User constants, and System constants.
Tags are operands with changeable content used in the user program. Constants are operands
with content that cannot be changed. When a tag or constant is declared in the PLC tag table,
the symbolic name (for example, "S_Right"), the data type (for example, Bool), and the absolute
address (for example, %I 0.2) are defined. No absolute address is required for constants.
om
Creating Tags with group function
By clicking on the "Fill" symbol in the lower right corner of the cell and then dragging it down,
tags can be automatically created (comparable to Excel).
c
n.

It is possible to automatically create tags through the "Name" and "Address" columns. New tags
are created with the name of the current tag appended by a consecutive number. From a tag
with the name "S_Station", new tags are then created with the names "S_Station (1)",
a

"S_Station (2)" etc.


us

User Constants
r

A constant defines an unchangeable data value. During program execution, constants can be
bo

read by various program elements, but they cannot be overwritten. Changing the value while the
program is running is not possible.
In TIA Portal, it is possible to declare symbolic names for constants so as to make static values
@

available in the program under one name. These symbolic constants are valid throughout the
CPU. The declaration of the constants is made in the "User constants" tab of the PLC tag table.
sa
m
sa
ry

4-13 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal

System Constants

.c
Every hardware and software object, for example, a module, transfer areas of I-Devices, or
even process image partitions, have a hardware ID which is automatically assigned by STEP 7

an
during the configuration of a hardware component.
In S7-1500 and S7-1200, these hardware IDs have the same function as the diagnostic

s
addresses of hardware components in the S7-300/400. Even when the I/O addresses of
modules are changed, their hardware ID remains the same. When I/O addresses are changed,

ru
the instructions that were addressed through a hardware ID do not have to be adjusted.

bo
Rules
System constants are automatically assigned in the Device view or Network view when
components are inserted and are entered in the Default tag table ("System constants" tab). A

@
system constant is created for each module but also for each submodule. In that way, for
example, an integrated counter is also given a system constant. System constants consist of a
symbolic name as well as a numeric HW-ID and cannot be changed.
sa
System Constant Names
The names of system constants are hierarchically structured. They consist of a maximum of four
hierarchy levels which in each case is separated by a tilde "∼". In this way, you can recognize
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

the "path" to the relevant hardware module based on the name.


sa
ry

m
co

Example
A system constant with the name "Local~PROFINET_Interface_1~Port_1" denotes Port 1 of the
n.

PROFINET interface 1 of the local CPU.


sa
ru
bo
@
sa
m
sa
ry

4-14 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
PLC Tags
4.5.1 in the
PLC device
Tags view
in the Device View

.c
s an
ru
System constants

bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

The PLC tags of inputs and outputs can also be declared and changed in the Device view.
ry

In addition, the hardware system constants can be displayed which are necessary for various
diagnostics.

Software system constants can also be displayed. For example, every CPU has software
system constants of the type PIP (Process Image Partition) for the process image partitions.
With the help of these constants and the instruction "UPDAT_PI", certain process image
partitions can be updatedat will in the program.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

4-15 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Details
4.6 view of global tags
Details view of global tags

.c
s an
ru
Select the Select the Select the
Tag table Data block Hardware module

bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

The Details view shows


ry

• the tags and constants of the selected tag table


• the tags of the selected data block or PLC data type.
• the channels of the selected local modules and their tags

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

4-16 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Using a tag and constants as an operand

om
4.6.1 Using a Tag and Constants as an Operand

.c
s an
ru
bo
@
sa
Automatic
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

symbol selection
m
sa

Using a Tag and Constants as Operand


During programming, the name of the tag/constant or the address can be entered. When the
ry

symbolic name or the address is input, the Autocompletion automatically appears from which
you can select the tag or the constant. Furthermore, you can use the Details view to adopt the
tags and constants using drag & drop.

Autocompletion
When operands are selected, after the first letter of the symbolic operand name has been
entered, a selection of all the tags and constants whose name start with the entered letter and
are of the corresponding data type is displayed. All the tags and constants that are valid for this
om
block are displayed. These are all global tags (also those that are declared in data blocks),
global constants, local variables (temporary and static), as well as the parameters and local
constants of the block.
c

You can also filter directly according to the type of tag, as required:
n.

• Begin with # to only select from parameters, local tags, and constants of the current block
a

interface
us

• Begin with " to only have global tags and constants displayed
• Begin with % to have all tags filtered according to absolute addresses displayed
r
bo
@
sa
m
sa
ry

4-17 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Monitoring
4.7 PLC tags
Monitoring PLC tags

om
Monitoring On / Off

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Monitoring PLC tags


PLC tags can be monitored directly through the PLC tag table. In so doing, the "Monitor value"
ry

column shows the current value of the tags in the CPU.

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

4-18 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Monitor
4.8 and Modify
Monitor and modify

om
.c
Modify values Monitor all On / Off

an
Comment line Tag comment (for watch
table and tag table)

s
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Activate/Deactivate
m

values to be modified
sa

Application
The test function "Monitor/Modify Variable" is used to monitor and / or modify variables in any
ry

format you choose. For this, the desired variables are entered into a Watch table. With the
exception of block-local, temporary variables, all variables or operands can be monitored and/or
modified.
The displayed columns of the Watch table can be chosen via the View menu and have the
following meanings:
• Name: Symbolic name of the variable
• Address: Absolute address of the variable.
om
• Comment: Comment on the displayed variable (can be edited)
• Tag comment: Comment on the displayed variable (cannot be edited, corresponds to the
c

comment in the DB or in the tag table)



n.

Display format: Data format (for example, binary, decimal...) which can be chosen by
mouse-click in which the variable’s content is displayed
a

• Monitor value: Variable value in the selected status format


us

• Modify value: Value which is to be assigned to the variable


r

Watch Table
bo

You can choose any name for the Watch table. Saved Watch tables can be re-used to monitor
and modify so that it is not necessary to re-enter the variables to be monitored.
@
sa
m
sa
ry

4-19 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 1:Exercise
4.9 Inserting a PLC Tag Table and
1: Inserting PLC Data
a PLC tag Types
table and PLC data types

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

You are to copy the prepared PLC tag table "My Tags" and the PLC data types
"type_ConveyorInput" and "type_ConveyorOutput" from the "Pro2_LIB_Vxx" library into your
ry

own project.

What to Do
1. In the Task Card "Libraries > Global libraries", open the "Pro2_LIB_Vxx" library.
2. Using drag & drop, copy the PLC tag table "My Tags" out of the library folder Master
copies\Chapter 04 into the PLC tags folder of your project.
3. Then, copy the PLC data types "type_ConveyorInput" and "type_ConveyorOutput" into the
m
PLC data types folder of your project.
4. Save your project.
co
n.
sa
ru
bo
@
sa
m
sa
ry

4-20 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 2: Creating the PLC Tag Table "Conveyor"
4.9.1 Exercise 2: Creating the PLC tag table "Conveyor"

om
.c
san
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

You are to add a new PLC tag table with the name "Conveyor" and generate two tags, one of
the data type "type_ConveyorInput" and one of the data type "type_ConveyorOutput".
ry

What to Do
1. Using "Add new tag table", create the new PLC tag table "Conveyor".
2. Add a new tag with the name "conveyorIn", the data type "type_ConveyorInput", and the
address %I4.0. (see picture)
3. Add a further tag with the name "conveyorOut", the data type "type_ConveyorOutput", and
om
the address %Q4.0. (see picture)
4. Compile and save your project.
c

5. Download the change into the CPU.


a n.
r us
bo
@
sa
m
sa
ry

4-21 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 3: Wiring Test of the Conveyor Model’s Sensors/Actuators
4.9.2 Exercise 3: Wiring Test of the conveyor Model’s Sensors/Actuators

om
.c
s an
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Example: %Q 4.5
sa

(Conveyor right)
m

Task
sa

You are to check if the wiring is correct with the help of a Watch table.
ry

What to Do
1. Add a new Watch table with the name "Conveyor".
2. Insert a Comment line and write the comment ‘Inputs’.
3. Add the elements of the structure of the PLC tag "conveyorIn".
4. Insert a further Comment line and write the comment ‘Outputs’.
m
5. Add the elements of the structure of the PLC tag "conveyorOut", up to the tag
"conveyorOut".res0.
co

6. Activate the "Monitor" function.


7. On the conveyor model, press the Bay buttons and check whether Status '1' or "TRUE" is
n.

displayed at the corresponding inputs.


sa

8. Check the sensors by placing one of the metal parts at the sensors.
9. Interrupt the light barrier and check whether the status switches from '1' to '0'.
ru

10. Specify some modify values for the outputs.


11. Activate the outputs that are to be modified and deactivate the outputs that are not to be
bo

modified.
12. Modify all activated variables and check the behavior on the conveyor model.
13. Save your project.
@
sa
m
sa
ry

4-22 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
5 Commissioning HMI

.c
Learning
5.1 objectives
Learning objectives

an
• You know how to set up the interface of an HMI device

s
ru
• You know how to network and connect an HMI device with a controller

bo
• You know the difference between absolute and symbolic tag / variable access

• You can commission a touch panel via PROFINET


@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

5-1 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
5.2Task Description: Commissioning Commissioning
Task Description: the Touchpanel the Touchpanel

.c
s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Task Description
The touchpanel project is to be commissioned. Later it will be used to operate the ‘Plant’. The
ry

"InterfaceTP" data block is used as the interface for the buttons on the "11_Conveyor" screen.
After the touchpanel is commissioned, you are to check whether the corresponding data block
variables are set and reset when the buttons are pressed.

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

5-2 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Adding anAdding
5.3 HMI Device
an HMI Device

.c
an
Portal view

s
ru
bo
Project view
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Adding an HMI Device


sa

New HMI devices can be added from both the Portal view and the Project view. More than
anything else, attention has to be paid to the device data such as Article number (order number)
ry

and Version number.

c om
a n.
r us
bo
@
sa
m
sa
ry

5-3 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Networking an HMI Device
5.3.1 Networking an HMI device

om
.c
s an
ru
bo
Show / Hide
address labels

@ During networking, the device is automatically


assigned an IP address which can be changed in the
screen area of the Network view
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

Networking an HMI device


sa

During networking, devices are connected to a subnet. The device interface must be compatible
with the type of network.
ry

The devices are networked in the Network view of the Hardware and Network editor under
"Network" by connecting the device interfaces using drag & drop.
c om
a n.
r us
bo
@
sa
m
sa
ry

5-4 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Configuring an HMI connection

om
5.3.2 Configuring an HMI connection

.c
1. Select HMI connection(s)

s an
ru
3. Check connection

bo
2. Use drag & drop
to drag a connection

@ The connection configuration automatically


sa
networks the devices!
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Configuring HMI Connections


In configuring HMI connection(s), the communications partners are defined with which the HMI
ry

device will later exchange data in the process control phase. The HMI device can also be
connected to or exchange data with several controllers.
There can also be controllers in the same network with which the HMI device does not
exchange data. Then, the HMI device is "networked" with these controllers but it is not
"connected".
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

5-5 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Creating HMI Tags and Connecting them with PLC Tags
5.3.3 Creating HMI tags and connecting them with PLC tags

om
.c
an
The connection of tags automatically networks the
devices and configures a connection!

s
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

In the HMI tags folder, the HMI tags can be created and they can be connected with the
associated tags/variables of the CPU via an existing connection. The properties, such as
Access mode, Acquisition cycle, etc., can be defined.
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

5-6 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Absolute or Symbolic Tag Access

om
Absolute or symbolic Tag Access

.c
s an
Absolute access with PLC tag name:

ru
☺ Address changes in the CPU program are synchronized
 Address access is only current again after the panel is reloaded

bo
Absolute access without PLC tag name:

@  Manually update address changes in the CPU program


 Address access is only current again after the panel is reloaded
sa
Symbolic access with PLC tag:
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

☺ Access to PLC tag via name (no address in the panel)


m

☺ Address changes in the CPU program are synchronized


☺ Access protection in effect ☺ Address access current - without reloading the panel
sa

Different access modes can be selected for HMI tags:


ry

Symbolic Access (Default Setting)


Here, an identification is generated for every PLC tag name during compilation of the S7
program. This identification is then used address-independent in the HMI device for the access.
With address or name changes in the S7 program, this identification of the PLC tag remains
unchanged. That is, the access is made via the PLC tag identification and the CPU then
determines the current address.

Absolute Access
m
Here, the configured address or the current address of the PLC tag is generated for the access
during compilation of the HMI configuration.
co
n.
sa
ru
bo
@
sa
m
sa
ry

5-7 SITRAIN
SIMATIC Programming 2 in the TIA Portal
I/O Field for Inputting and Outputting Values
5.3.4 I/O Field for Inputting and Outputting Values

om
.c
s an
ru
bo
HMI tag PLC tag
@
sa
Mode
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Input/output
m
sa

I/O Fields
The values of tags are displayed via output fields; the values of tags can also be preset via input
ry

fields. The mode can be set in the Properties window.

Mode
Output
The value of the tags is only displayed. The tag is read and updated in the interval of the
configured acquisition cycle.
A value change (input) on the operator panel is not possible.
om
Input/Output
The value of the tags is displayed. The tag is read and updated in the interval of the configured
acquisition cycle.
A value change (input) on the operator panel is possible – on touch displays, using the
c

automatically displayed Display (screen) keyboard, and, with key devices, using the device
n.

keyboard.
a
r us
bo
@
sa
m
sa
ry

5-8 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Buttons Buttons
5.3.5 for executing events
for Executing Functions

om
.c
s an
ru
bo
Operating events of the button
HMI tag

Actions when operating the button


@
The selection of a PLC tag in properties creates the necessary HMI tag,
automatically networks the devices and configures a connection!
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Buttons
m

System functions can be initiated by the operator via buttons, such as the selection of a screen,
or the setting and resetting of a tag shown in the screen. The "Events" of a button are used to
sa

specify for which event which system function is to be executed.


ry

c om
a n.
r us
bo
@
sa
m
sa
ry

5-9 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Compiling the configuration
5.3.6 Compiling the Configuration

.c
s an
Compile
(Delta generation)

ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

Compile (only changes)


• Here, all changes since the last generation are regenerated.
• → Delta generation

Software/Hardware (rebuild all)


• Regenerates the entire operator panel

When is a ‘Rebuild all’ necessary?


• When correctly configured functions are not correctly executed or are not executed at all.
When error messages occur during compiling that are not "correct".
om
.c
an
r us
bo
@
sa
m
sa
ry

5-10 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Downloading
5.3.7 the projectthe
Downloading intoProject
the HMIinto
Device
the HMI Device

.c
s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Downloading the Project into the HMI Device


ry

When you transfer an HMI project to one or more operator panels, the part of the project that
has been changed since the last transfer is automatically compiled before downloading. This
ensures that the current project status is always transferred. Beyond that, it is also possible to
activate the option "Overwrite all" before loading starts.
For commissioning, the project should be completely compiled using the command "Compile >
Software (rebuild all)" in the context menu of the operator panel. If HMI tags that are connected
to PLC tags are also used in the project, all modified STEP 7 blocks should also be compiled
using the command "Compile > Software" in the context menu and then be downloaded into the
CPU.
In order to reduce the time required for compiling delta data in current engineering sessions, it is
also recommended that you occasionally use the "Compile > Software (rebuild all)" command.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

5-11 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Simulation
5.3.8 of the Touchpanel
Simulation of the Touchpanel

.c
s an
Start Simulation

ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Starting the Simulation

The simulation of an HMI device ist started with the button


ry

Note
The Simultaion of an HMI device can be active parallel to a real device
c om
n.
sa
ru
bo
@
sa
m
sa
ry

5-12 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Settings Settings
5.3.9 for Simulating an HMI Device
for Simulating an HMI Device

.c
s an
ru
bo
@
sa
Example of Interface Parameter Assignment Used:
Access via given network card (on real CPU)
Access to simulated CPU in PLCSIM S7-1200/1500
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

HMI devices (the touchpanel) can be simulated as well. For this, however, you must set which
ry

interface the simulation Portal uses to access the controller beforehand.


The correct access point must be specified (default setting is "S7ONLINE") in the Connections
of the HMI device and, in turn, the correct PG/PC interface (see "Set PG/PC Interface" in the
picture) must be assigned to the access point.
You have the option of selecting a real network card if communication to a controller connected
via this network card is to be established (select the relevant network card). Furthermore, you
can specify that communication to a simulated CPU, which is simulated with the PLCSIM S7-
1200/1500 software, takes place. (Select PLCSIM.xxx, whereby xxx corresponds to the type of
interface, for example, PROFIBUS or TCPIP).
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

5-13 SITRAIN
SIMATIC Programming 2 in the TIA Portal

5.4 Task Description: Commissioning


Task Description: the Touchpanelthe
Commissioning Touchpanel

om
.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

© Siemens 2022 SITRAIN


Task Description
m

The touchpanel project is to be commissioned. Later it will be used to operate the ‘Plant’. The
sa

"InterfaceTP" data block is used as the interface for the buttons on the "11_Conveyor" screen.
After the touchpanel is commissioned, you are to check whether the corresponding data block
ry

variables are set and reset when the buttons are pressed.

c om
a n.
r us
bo
@
sa
m
sa
ry

5-14 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
5.4.11: Copying
Exercise Exercise
the1:touch
Copying the and
panel touchDB_OP
panel and thethe
from interface
libraryDB
from the library

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

Task
Up until now, your project doesn’t contain an HMI device. Instead of a completely new
configuration, you are to copy a prepared panel project and the "InterfaceTP" and
"ConveyorData" data blocks that are in part to serve as the interface between the controller and
the touchpanel, from the global library "Pro2_Vxx" into your project.

What to Do
1. Open the global library "Pro2_LIB_Vxx". Your instructor will provide the file path.
m
2. Using drag & drop, copy the object "touchpanel" into the "Area_1" folder and the DB
"DB_OP" into the "Program blocks" folder of the S7-1500 from the "Master copies\Chapter
co

05" folder.
3. Save your project.
n.
sa
ru
bo
@
sa
m
sa
ry

5-15 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
ExerciseExercise
5.4.2 2: Networking the Touchpanel
2: Networking the touch panel

.c
s an
Show address
label(s)

ru
bo
@ Set IP address
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

The added touch panel is to be networked offline with the Ethernet network.
ry

What to Do
In the Project tree, start the Hardware and Network editor, switch to the "Network view" and
there select "Network".
Position the mouse pointer on the small green square of the HMI device and, while keeping the
left mouse button pressed down, drag a connection to the CPU. The network is created; the
associated subnet and the parameters appropriate for the network (IP address and subnet
mask) are automatically created.
With the help of the "Show Address label(s)" button, show the IP addresses and set the address
192.168.111.121.
m
This can also be set via the Properties in the Inspector window.
co
n.
sa
ru
bo
@
sa
m
sa
ry

5-16 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
ExerciseExercise
5.4.3 3: Configuring the HMI Connection
3: Configuring the HMI connection

.c
an
1. Select HMI connection(s)

s
ru
bo
2. Use drag & drop
to drag a connection

@ 3. Check connection
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

After the touch panel is networked with the Ethernet network, an HMI connection between TP
and CPU must be created.
ry

What to Do
1. In the "Network view" switch from "Network" to "Connections" and select "HMI connection".
1. Position the mouse pointer on the small green square of the HMI device and, while keeping
the left mouse button pressed down, drag a connection to the CPU. The connection is
created.
2. In the details window in the "Connections" tab, check whether the HMI connection was
correctly created and, if necessary, change the name to "HMI_Connection". (see picture)
3. In order to graphically display the connection between the S7-CPU and HMI device, position
om
the mouse pointer on the network and in the dialog window that appears select
"HMI_Connection".
c
a n.
r us
bo
@
sa
m
sa
ry

5-17 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
ExerciseExercise
5.4.4 4: Checking the HMI tags
4: Checking the HMI tags

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

You are to check the HMI tags and, if necessary, correct them.
ry

What to Do
1. Open the HMI tag table "Default tag table" of the touch panel.
1. If necessary, correct faulty tags until no red entries exist.
2. Save your project.

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

5-18 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
ExerciseExercise
5.4.5 5: Compiling and Savingand
5: Compiling the saving
Project the project

.c
an
2. Save

s
project 1. Compile
HMI project

ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Task
You are to compile and save the now complete HMI project.
ry

What to Do
1. Compile the HMI project by selecting the touchpanel in the Project tree and then clicking on
the "Compile" button (see picture).
1. In the Inspector window under "Info", read the results of the compilation and eliminate any
errors which may have occurred.
2. Save your project. m
co
n.
sa
ru
bo
@
sa
m
sa
ry

5-19 SITRAIN
SIMATIC Programming 2 in the TIA Portal

5.4.6 Exercise 6: Downloading the S7 Program into the CPU and


Exercisedownloading
6: Downloading
orthe S7 program
simulating theinto the panel
touch CPU and simulate/download the touch

om
panel

.c
s an
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

Task
From the now complete project, all S7 blocks are now to be transferred into the CPU and the
sa

entire Panel project is to be transferred into the touch panel.


ry

What to Do
1. Download the S7-1500 project into the CPU.

2. Download the panel project into the touchpanel.

2. Simulate the touchpanel project.


m
3. Save your project.
co
n.
sa
ru
bo
@
sa
m
sa
ry

5-20 SITRAIN
SIMATIC Programming 2 in the TIA Portal
ExerciseExercise
5.4.7 7: Carrying
7: out a test of
Carrying outthea communication
test of the communication

om
.c
s an
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Task
m

You are to check the connection of the touch panel to the S7-1500 by pressing the panel
buttons and monitoring the connected data block variables.
sa

What to Do
ry

1. Open the "InterfaceTP" data block and activate the function "Monitor".
1. One after the other, press the buttons on the touchpanel and observe how the touchpanel
overwrites the statuses of the Boolean data block variables with '0' or '1'.
2. Save your project.
c om
a n.
r us
bo
@
sa
m
sa
ry

5-21 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
5.5 Appendix

.c
HMI/OPC UA Access to PLC Tags and DB Variables
5.5.1 HMI/OPC UA Access to PLC Tags and DB Variables

an
s
ru
PLC tags or DB variables

bo
@
HMI tags
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

All tags/variables are displayed


Regardless of Accessible, Writable or Visible
ry

HMI Tag Access


In the PLC tag tables and data blocks, protective mechanisms can be declared with whose help
unwanted accesses to PLC tags and DB variables from HMI devices or OPC UA-Clients can be
prevented:
• "Visible in HMI Engineering":
During HMI configuration, only tags/variables with the attribute "Visible in HMI Engineering"
can be selected. This filter function can, however, be disabled in the selection dialog shown
by activating "Show all".
• "Writable from HMI/OPC UA" (only S7-1200 and S7-1500):
m
This indicates whether the tag/variable can be written from HMI / OPC UA at runtime. This
protective function integrated in the S7-1200/1500 operating system ensures that the HMI
co

device or OPC UA-Client does not overwrite certain tags/variables.


• "Accessible from HMI/OPC UA" (only S7-1200 and S7-1500):
n.

The HMI device can only access online the tags/variables which have the attribute
"Accessible from HMI/OPC UA". This protective function integrated in the S7-1200/1500
operating system ensures that the HMI device or OPC UA-Client can neither read-access
sa

nor write-access certain tags/variables. Tags/variables which are not "Accessible from
HMI/OPC UA", accordingly are also not "Visible in HMI Engineering".
ru

Note
bo

OPC UA is a standard which enables an operating system and platform-independent data


exchange.
@
sa
m
sa
ry

5-22 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Requirements for Downloading
5.5.2 Requirements for Downloading

.c
an
Device version

• Configured device type is identical to

s
the type of the target device

ru
• Connection to the target device exists

bo
• Target device is ready to load
(Transfer mode active)

@
• Project is compiled without errors To download, “Transfer” must
→ can contain warnings
be activated in the Start Center
sa
• Online settings in TIA Portal Runtime is automatically
match the connection
stopped during loading
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Device Type and Device Version on the Operator Panel


ry

The device type can be found on the nameplate on the operator panel.
The image version is displayed in the Start Center during device startup.
Caution: An update of the device version or image version can lead to the loss of recipe data,
user data and some system settings.

Connection to the Target Device


A direct connection can be tested via ‘Update accessible devices’ in the ‘Online access’.
A direct connection via Ethernet can also be checked via the network connection test "ping
xxx.xxx.xxx.xxx" (xxx.xxx.xxx.xxx = IP address).
om
Transfer Readiness
For the transfer to panels, two conditions must be fulfilled on the operator panel:
• The connection is activated for the transfer (Settings for the transfer)
c


n.

The operator panel is in "Transfer mode":


▪ Transfer mode "Automatic" and Runtime is started or
sa

▪ Transfer mode "Manual" and Transfer is activated in the Start Center


ru

Generate Project without Errors


During generation, problems can result in two categories.
bo

• Warning - Project can be used but is incomplete (!!!)


• Error - Generation is aborted.
@

Online Settings
Depending on the device connection, the settings must also match the current connection and
sa

transfer readiness of the operator panel in the dialog "Extended download to device".
m
sa
ry

5-23 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Manually Setting the Transfer Mode, Transfer Channel, and IP Address

om
Manually Setting the Transfer Mode, Transfer Channel, and IP Address

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Manually Setting the Transfer Mode, the Transfer Channel, and the IP Address of a Panel
The mode of the interface as well as the IP address of the panel can be manually set via the
ry

Start Center > Settings.

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

5-24 SITRAIN
SIMATIC Programming 2 in the TIA Portal

6 Program – Design Methods

om
.c
6.1LearningLearning
objectives objectives

an
• You know the different organization blocks and when to use them

s
• You are familiar with elements of structured programming

ru
• You are able to create simple structograms

bo
• You are able to use the start information of a non-optimized organization block

• You are able to convert structograms into S7 program code


@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

6-1 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
6.2 Plant Description:
Plant Description: The Conveyor
The Conveyor Model
Model as asDistribution
Distribution Conveyor
Conveyor

.c
s an
Stop positions Start position

ru
bo
@
P_operation %Q0.1 Status leds of the bays Start button
sa
Enabling buttons of the bay
P_restartMan
%Q0.5
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

P_restartAuto
m

%Q0.6
%I0.7 S_acknowledge P_fault %Q0.7
sa

Restart (Addition)
ry

A manual restart (CPU STOP->RUN) and an automatic restart (power restoration) is indicated
on the simulator-LEDs "P_restartMan" and "P_restartAuto".

Conveyor Model as Distribution Conveyor


You can switch between Automatic and Manual mode using the buttons "Automatic" and
"Manual".
• Manual Mode
In Manual mode, you can jog the conveyor in the relevant direction using the buttons "Jog right"
and "Jog left". The operating mode is indicated on the touchpanel.
• Automatic Mode
m
Automatic mode is also indicated via the touchpanel and additionally through the LED
co

"P_ operation" on the operator panel (simulator).


The indicator light at the light barrier bay shows with a continuous light that a new part may be
placed in the light barrier (Start position) if…
n.

– ... at least one of the bays 1 to 3 (STOP positions) is free (= at least one of the bay
indicator lights is dark),
sa

– … no part is being transported to the bays,


– … no conveyor fault exists (no indication at LED "P_fault" or on the touch panel)
ru

Transport is started by pressing the pushbutton at the light barrier bay. As soon as the part
bo

reaches a free bay, the conveyor motor is stopped.


A 2Hz flashing light from the bay indicator light indicates that the part can be removed from the
conveyor. The bay is still considered to be occupied even though the part has been removed,
@

which is indicated by a continuous light on the bay indicator light and on the panel. Only after
acknowledging with the bay pushbutton, is the bay "enabled" once more.
Every transport sequence is monitored for time. If it takes longer than 6 seconds, there is a fault
sa

and the conveyor motor is automatically switched off. Only after the fault is acknowledged via
the "S_acknowledge" button or the "Error Acknowledge" button on the touchpanel, can a new
transport sequence be started.
m
sa
ry

6-2 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Types
6.3 of Program
TypesBlocks
of Program Blocks

om
.c
Operating System
DB DB

an
Cycle

s
Time OB FC FB

ru
Organization
Process blocks

bo
FB FC
Error

Legend:
@
The maximum nesting depth
OB = Organization block
FB depends on the CPU!
sa
FB = Function block
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

FC = Function FB with
DB = Data block Instance DB
m
sa

Blocks
The automation system (PLC) provides various types of blocks in which the user program and
ry

the related data can be stored. Depending on the requirements of the process, the program can
be structured in different blocks. You can use the entire operation set in all blocks (FB, FC, and
OB).

Organization Blocks (OBs)


Organization blocks (OBs) form the interface between the operating system and the user
program. The entire program can be stored in an Organization block which is called cyclically by
om
the operating system (linear program) or the program can be divided and stored in several
blocks (structured program).
c

Functions (FCs)
n.

A function (FC) contains a partial functionality of the program. It is possible to program functions
as parameter-assignable so that when the function is called it can be assigned parameters. As a
a

result, functions are also suited for programming frequently recurring, complex partial
functionalities such as calculations.
us

Function Blocks (FBs)


r

Basically, function blocks offer the same possibilities as functions. In addition, function blocks
bo

have their own memory area in the form of instance data blocks. As a result, function blocks are
suited for programming frequently recurring, complex functionalities such as closed-loop control
tasks.
@
sa
m
sa
ry

6-3 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Organization
6.4 Blocks of the S7-1500
Organization Blocks of the S7-1500

.c
an
Startup program execution Periodic
Cyclic program execution
program execution

s
Startup Program Cycle Time of day Interrupt

ru
(OB100, >=123) (OB1, >=123) (OB10...17, >=123)

Cyclic Interrupt

bo
(OB30...38, >=123)

Event-driven program execution


Interrupt Acyclic error Cyclic error

@
Time delay Interrupt Time error Interrupt Programming error
(OB20…23, >=123) (OB80) (OB121)
sa
Hardware Interrupt Diagnostic error Interrupt IO access error
(OB40...47, >=123) (OB82) (OB122)

Synchronous Cycle Pull or plug of modules


m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

(OB61…64, >=123) (OB83)


sa

Motion Control Interrupt Rack or station failure


(OB91, 92) (OB86)
ry

Startup Program
After voltage recovery, or a change of operating mode (through the CPU‘s mode selector or
through PG operation), a startup program is carried out before the cyclic program execution. In
the Startup OBs you can, for example, carry out a pre-assignment of communication
connections.

Cyclic Program Execution


The program stored in a "Program Cycle" OB is executed in a continuous loop. The reaction
time, that is, how fast an output can be switched in relation to an input signal, amounts to a
minimum of one time and a maximum of two times the cycle time. With this cyclic program
execution, the reaction time results from the execution time for the CPU’s operating system and
the sum of the command runtimes of all executed instructions.
m
Periodic Program Execution
co

This makes the execution of program parts at fixed intervals possible.


A Time-of-day Interrupt is executed at a specific time and on a specific day once or at an
n.

interval which can be set (every minute, every hour, daily, weekly, monthly, yearly, at the end of
the month). The OB could carry out a data backup, for example.
sa

With the Cyclic Interrupts, the respective Cyclic Interrupt OB is executed after an adjustable
time base has expired (for example, every 100ms). In these blocks, for example, closed-loop
ru

control blocks with their sampling time are called.


bo

Event-driven Program Execution


With Time-delay Interrupts a freely definable event can be reacted to with a time-delay.
Hardware Interrupts are used to quickly react to process events. After an event occurs, the
@

cycle is interrupted and an interrupt program is executed.


With the Error OBs, the user can influence the behavior of the controller in case there is an
error. Errors could be: an overrun of the cycle time, diagnostic messages from modules, the
sa

pulling or plugging of modules, the failure of a distributed rack or station, a programming error or
an access error.
m
sa
ry

6-4 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Cyclic Program Execution
6.4.1 Cyclic Program Execution

.c
• Startup program: Call and execute the

an
Startup OBs (once, after PowerON, for example)

s
Reset the cycle time

ru
Output
module
Write the process image for outputs

bo
(PIQ) into the output modules
CPU Cycle

@
Read the status of input modules
and save in the process image for inputs (PII)
sa
Call and execute the Program cycle OBs Input
module
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

(possible interruption by the call of other OBs for events,


m

such as, time-of-day interrupt, hardware interrupts, errors etc.)


sa

Restart
ry

When you switch on or switch from STOP --> RUN, the CPU carries out a complete restart (with
OB “Startup”). During restart, the operating system deletes all non-retentive memory bits and
starts the cycle monitoring time.

Cyclic Program Execution


Cyclic program execution occurs in an endless loop. After the execution of a program cycle is
completed, the execution of the next cycle occurs automatically. In every program cycle, the
CPU carries out the following steps.
• The CPU transfers the output statuses from the process image for outputs to the output
m
modules.
• The CPU scans the statuses of the input signals and updates the process image for inputs.
co

• The CPU sequentially processes the instructions of the user program and so works directly
with the process images, not with the inputs and outputs of the input / output modules.
n.

Cycle and Cycle Monitoring Time


sa

The time that the CPU requires for the execution of the complete program cycle is the Cycle
Time, which is monitored for time by the CPU operating system. If the cycle time exceeds the
ru

cycle monitoring time defined in the CPU properties by more than double, the CPU goes into the
STOP state.
bo
@
sa
m
sa
ry

6-5 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Interrupting
6.5 the Cyclic Program
Interrupting the Cyclic Program

.c
Write PIQ
Read PII

an
Hardware OpSys Begin
"OB_ProgCycle"
interruption
Begin
"OB_Diag_Int"

s
End

ru
Resume

Interrupt processing
"OB_ProgCycle"
. interruption
Begin

bo
"OB_Cyclic_Int"
Begin
"OB_Diag_Int"
End

.
Resume
"OB_Cyclic_Int"

@ Resume
End
Begin
"OB_Cyclic_Int"
End
sa
"OB_ProgCycle"
End
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Priority "OB_ProgCycle" <Priority "OB_Cyclic_Int" < Priority "OB_Diag_Int"


m

OB Calls
sa

Organization blocks (OBs) form the interface between the CPU’s operating system and the user
program.
ry

Organization blocks are called exclusively by the operating system. There are various start
events (time-of-day interrupts, hardware interrupts - see picture) that each lead to the start of
their associated organization block.

Interrupting the Cyclic Program


When the operating system calls another OB, it interrupts the cyclic program execution because
the "OB_ProgramCycle" OB has the lowest priority by default. Any other OB can therefore
interrupt the main program and execute its own program. Afterwards, the "OB_ProgramCycle"
OB resumes execution at the point of interruption.
m
Priorities
co

The S7-1500 CPUs support the priorities 1 (lowest priority) to 26 (highest priority).
The OBs are executed on a purely priority-driven basis. This means that when several OB
n.

requests exist at the same time, the OB with the highest priority is executed first. When an event
occurs that has a higher priority than the currently active OB, this OB is interrupted. Events of
sa

the same priority are executed in the order that they occur.
The priority can be controlled in the OB’s Properties > Attributes dialog.
ru

Queue
bo

If, during the execution of an interrupt OB, a further event with the same priority occurs, this
event is placed in a queue according to its priority. The start events of a queue are processed at
a later time in the order in which they occur. The number of pending events can be limited in
@

order to keep temporary overload situations under control.


When, for example, the maximum number of start events for a cyclic interrupt OB is reached in
the queue, every further start event is discarded.
The number of discarded start events is made available at the input parameter "Event_Count".
sa
m
sa
ry

6-6 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Start information
6.5.1 Startup-OBStartup-OB
Start information (not optimized)
(not optimized)

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

For the precise meaning of the start information of individual organization blocks, please see the Help
m
sa

Start Information
When the operating system calls organization blocks, the user is provided with system start
ry

information in the local data stack.


For standard OBs (non-optimized), the start information has a length of 20 bytes and is
available after the start of the OB execution.
For optimized OBs, the start information is reduced to the essentials for runtime reasons. It can
however, also be completely read out with the instruction "RD_SINFO".
Note: The function "RD_SINFO" is dealt with in more detail in the "Optimized Blocks" chapter.

Variables
An explanation of the meaning of the variables can be found in the online help.
m
Note
In order to avoid errors, the structure of the standard declaration section must not be changed
co

by the user. The user may declare further temporary variables after the standard declaration
section.
n.

The switch-over from non-optimized block to optimized block is done via Properties -> Attributes
-> Optimized block access.
sa
ru
bo
@
sa
m
sa
ry

6-7 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Parameter Declaration in Functions and Function Blocks
6.5.2 Parameter Declaration in Functions and Function Blocks

om
Motor
Parameters are the channels Declaration Name Type Initial value

.c
for transferring information: Input Start BOOL FALSE
• Input parameters: Caller -> Block Stop BOOL TRUE

an
Setpoint INT 0
• Output parameters: Block -> Caller Output MotorON BOOL FALSE
• IN/OUT parameters: Caller <-> Block Speed INT 0
InOut E_OFF BOOL FALSE
• Return Value of an FC: Block -> Caller

s
Stat ... ... ...
Temp … Static variables
... - only
... FB

ru
Parameters form the "shell“ of a block: Constant … … ...
Return Motor WORD
• Parameters are used in the code section like

bo
"local" variables Return Value – only FC
• Parameters can have any data type (when data type is not VOID)

• Data type check during call


"Motor"
(exception: POINTER, ANY, Variant) @
• Call interface is language-independent
Enable In EN

Start Ret_Val
Return value
• PLC languages can be mixed Input
of a function
Stop
sa
parameters MotorON Output
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Setpoint Speed parameters


InOut
parameter E_OFF ENO Enable Out
m
sa

Overview
Parameters are used as channels for transferring information between the calling block and the
ry

called block. Local tags/variables are used as storage within the current block as temporary and
static memories. The symbolic names, data types and, if necessary, initial values of parameters
and local tags/variables are established in the declaration table.

Parameter Type/Variable Type


The type indicates the direction of the data transfer and the usage:
• IN Input parameters (FB, FC): They are used to transfer information from the calling
m
block to the called block. Only a read-only access to the input parameters is possible within
the called block.
co

• OUT Output parameters (FB, FC) as well as RETURN (FC): They are used to transfer
information (results) from the called block back to the calling block.
n.

• INOUT In/Out parameters (FB, FC): In/Out parameters are used to transfer information in
both directions. A read and write access is possible to in/out parameters.
sa

• Stat Static variables (FB): Store values that are to be retained beyond the block call and
consequently may be used in the next cycle or in the next call.
ru

• Temp Temporary variables (OB, FB, FC): Store values that are only retained as long as the
block is open.
bo

• Const Constants: Fixed values that are provided with comments.

Assignment of Actual Parameters during a Block Call


@

When a block is called, relevant actual parameters are assigned to the formal parameters. All
parameters of FCs as well as the in/out parameters of FBs with a structured data type (not
elementary data type) must be provided with actual parameters. The compiler checks that the
sa

created actual parameter has the correct type (Exception: VARIANT, POINTER, and ANY). The
type check and the parameter passing mechanisms are language-independent. Consequently,
m

blocks with different programming languages can be used in one and the same program.
sa
ry

6-8 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Block Programming
6.6 Block programming

om
.c
Insert Network

an
Display Favorites

s
On / Off

ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Block Programming
ry

The instructions within a block can be programmed as follows:


• using drag & drop from the Favorites or the Instructions catalog to anywhere in the program
• by first selecting the location in the program and then double-clicking on the desired
instruction in the Favorites or the Instructions catalog
Operands can be entered with an absolute or a symbolic address. If the tag table is highlighted
(not opened!) in the Project tree, tags (variables) can also be pulled from the Details view to the
om
appropriate location in the program using drag & drop.

Favorites
c

Frequently used elements are available in the toolbar which can be expanded individually from
n.

the Instructions catalog using drag & drop.


a
r us
bo
@
sa
m
sa
ry

6-9 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Using Constants in FCs/FBs/OBs/DBs
6.7 Using Constants in FCs/FBs/OBs/DBs

.c
Global and local constants may

an
be used as Array limits

s
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

Global and Local Constants in FCs, FBs and OBs


Constants can be created in the PLC tag tables that are used in the entire program. In addition
to the global constants, local constants can also be declared within the code blocks. These
local constants are only valid within the block.

Application of Local and Global Constants:


If the same constant value is required for several instructions within a block, it can be passed in
the form of a local constant which is created in the declaration section of the block and is preset
with a constant value.
m
If the same value is required in several blocks, a global constant can be used.
If it becomes necessary to change the constant value, it only has to be adjusted once in the
co

declaration section of the block or in the tag table and not in each individual instruction.
As shown in the picture, constants can and should also be used to define the limits of the data
n.

type Array in the declaration of tag variables and parameters.


sa
ru
bo
@
sa
m
sa
ry

6-10 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Edge Evaluations (1)
6.8 Edge Evaluations (1)

.c
"Scan operand for positive signal edge" "Scan RLO for positive signal edge"

s an
ru
bo
Edge memory bit: Must only be used once and can be a memory bit, DB variable, STAT variable, or INOUT variable .

#Operand_1

#Operand_2
@
sa
#Edge_Operand
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

OB1 OB1 OB1


cycle
m

cycle cycle

#RLO_Memory
sa

OB1 OB1 OB1


cycle cycle cycle
ry

Edge Memory Bit


The instructions compare the current status or the result of the logic operation with the status or
the RLO in the previous program cycle. This is stored in a so-called edge memory bit (in the
example, #Op_Ed_Memory and #RLO_Ed_Memory).
It must be ensured that the status of this edge memory bit is not overwritten elsewhere in the
program. For each RLO edge evaluation, a separate edge memory bit must be used, even
when the same operand (in the example, AND operation) is evaluated again, for example, in
another block!
The edge memory bit can be, but doesn’t have to be, a memory bit. You should use a static
om
variable, the variable(s) of a global data block, or an INOUT variable. If you should use an
INOUT variable as an edge memory bit, you must ensure that it is supplied with an actual
parameter of the type BOOL(static variable, data block variable, memory bit, or once again with
an INOUT variable) during the call.
c
n.

CAUTION
sa

IN parameters, OUT parameters, and temporary variables must not be used as edge memory
bits.
ru

Scan Operand for Positive (–|P|–) or Negative (–|N|–) Signal Edge


If, for a positive signal edge scan (see picture), the state of the given operand changes above
bo

the box from '0' to '1' ("rising edge") or for a negative signal edge scan from '1' to '0' ("falling
edge"), RLO '1' is output at the output to the box for the duration of one program cycle.
@

Signal Edge Evaluation (P_TRIG, N_TRIG)


With an RLO edge evaluation, it is possible to detect whether the status of a logic operation (in
the example an AND operation) has changed from '0' to '1' (rising or positive edge) or from '1' to
sa

'0' (falling or negative edge). If this is the case the instruction supplies, for the duration of one
cycle, RLO '1' as the result, which can be further logically linked or can be assigned to another
m

operand (in the example, the variable #RLO_Memory) as status. In the following cycle, the
instruction then once again supplies '0' as the result even if the AND operation still is status '1'.
sa
ry

6-11 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Edge Evaluations (2)
6.8.1 Edge Evaluations (2)

.c
an
"Set operand on positive signal edge" "Detect positive signal edge" (FB evaluation)

s
ru
bo
Edge memory bit Edge memory bit in the iDB

#Operand_1

@
#Operand_2

#Op_Set_Memory
OB1 OB1 OB1
sa
cycle cycle cycle

#Signal_Operand
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

#Edge_FB
OB1 OB1 OB1
sa

cycle cycle cycle


ry

Set Operand on Positive (–[P]–) or Negative (–[N]–) Signal Edge


If, with the function "Set operand on positive signal edge", the result of the logic operation at the
input to the instruction changes from '0' to '1' ("rising edge"), the operand above the instruction
is assigned ‘True’ for one cycle.
If, with the function "Set operand on negative signal edge", the result of the logic operation at
the input to the instruction changes from '1' to '0' ("falling edge"), the operand above the
instruction is assigned ‘True’ for one cycle.
In addition, the value of the input signal (result of the AND operation) is output at the output of
the box and is available for further logic operations.

Detect Positive (R_TRIG) or Negative (F_TRIG) Signal Edge


m
This has the same behavior as with "Signal edge evaluation" whereby, however, the evaluation
occurs via a standard instruction which is passed an instance data block, or which can also be
created as a multiple instance within another FB. An edge memory bit is no longer necessary
co

and, in addition, the input EN can be used and the output ENO can be evaluated.
n.

In the SCL programming language, this is the only way to do an edge evaluation without having
to program the functionality manually.
sa
ru
bo
@
sa
m
sa
ry

6-12 SITRAIN
SIMATIC Programming 2 in the TIA Portal
DB6.9
and StaticDB
Variables insteadVariables
and Static of Memoryinstead
Bits of Memory Bits

om
.c
s an
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

DB Variables instead of Memory Bits


sa

In the traditional programming style memory bits, among other things, were used to pass
information within a block or to pass information from block to block. The disadvantage of using
ry

memory bits is that the user has to organize the management of the memory bits himself and
the overlapping of bit, byte, and word accesses frequently leads to errors. In addition, the
memory area of memory bits is non-optimized so that the access to memory bits is less efficient.
If, on the other hand, variables in optimized data blocks are used instead of memory bits, this
has the following advantages:

m
The access to variables in optimized data blocks is more efficient than that to memory bits.
• Through consequent symbolic programming, overlapping accesses are avoided.
co

• Adding variables later on (see picture) is not a problem since the entire program is
automatically adjusted during compiling.
n.
sa
ru
bo
@
sa
m
sa
ry

6-13 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Procedure
6.10 forProcedure
Creating a Program
for Creating a Program

.c
an
Task definition

s
ru
Define program structure

Create program (LAD, FBD, SCL, GRAPH, STL)

bo
Commissioning (Debugging):
Documentation
Repeat until program is error-free

@
Program test

Errors?
sa
YES
Ja NO
nein

Debug
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

Procedure
When complex correlations are to be implemented in functions and function blocks, the
following steps are necessary:
1. Task definition
For tasks such as data management, measuring functions etc., you have to define which
information has to be processed and which results have to be supplied.
2. Program structure
Here you define which steps are necessary to achieve the goal (result) and in which
sequence these individual steps have to be processed. The structogram can help you here.
3. Program creation
Creation of a symbol table. Decision, whether the block is to be parameter-assignable or
om
not.
Possibly: creation of the declaration table for the block parameters and the local
tags/variables.
.c

4. Commissioning, Program test and Debugging


You can check the function of a block using "Program status". With "Monitor/Modify
an

Variable", you can monitor or modify variables. The test function "Breakpoint" is suitable for
blocks with jumps and loops so that you can check the program step by step. You can
eliminate formal errors by checking the cross reference list for double assignment or the
us

program structure for program loops, for example.


5. Documentation
r

An accompanying document is necessary for every phase of the program creation.


bo
@
sa
m
sa
ry

6-14 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Structure Elements of Structograms (1)
6.10.1 Structure Elements of Structograms (1)

om
.c
Assignment
Result or Target  Operation or Source

an
Iteration block

s
Instruction block (with subsequent condition check)

ru
Instruction
Instruction block

bo
Condition

Sequence

Instruction 1
@ Iteration block
(with preceding condition check)

Condition
Instruction 2
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

:
Instruction block
Instruction n
m
sa

Area of Use
When configuring programs or complex blocks without graphic help, the difficulty exists in
ry

simultaneously developing the solution algorithm in the mind and converting this directly into
program code at one go.

Structograms help here. They consist of structure elements which are used by the user in any
order and are provided with task-specific texts.

Structograms according to Nassi - Shneiderman


Structograms provide a sensible alternative here. The programming person first of all plans the
m
procedure (algorithm) or the function using graphic means and in a second step, codes the
structogram, that is, converts it into a program. The diagrams are standardized according to DIN
co

66261. They are well known and wide-spread both nationally and internationally and can
therefore also be used as a meaningful documentation means.
n.

• Instruction block
The instruction block is the simplest structure element. It contains a freely definable
sa

instruction that proceeds linearly and doesn‘t contain any branches or similar.
• Sequence
ru

The sequence is a linear sequence of instructions that are executed one after the other. The
direction of execution is always from top to bottom.
bo

Iterations
With iterations, individual instructions or whole sequences, for example, are repeated until the
@

repetition condition is no longer fulfilled. Iterations are also referred to as loops. Differentiation is
made between two types of iterations: start-controlled and end-controlled iterations.
• Start-controlled: Here the loop is only executed when the repetition condition is already
sa

fulfilled at the beginning.


End-controlled: The loop is executed at least once. Repetition then depends on the fulfillment of
m

the repetition condition.


sa
ry

6-15 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Structure Elements of Structograms (2)
6.10.2 Structure Elements of Structograms (2)

om
Alternative Condition
(simple) (special form)

.c
Condition Condition
y n y n

an
Instruction block 1 Instruction block 2 Instruction block %

s
ru
Alternative Alternative
(simple, special display format) (multiple, also known as multiple choice)

bo
IF Condition fulfilled then Condition

Instruction block 1
@ Cond. 1 Cond. 2 Cond. 3 Cond. 4 Nothing
fulfilled fulfilled fulfilled fulfilled fulfilled
Else (if not fulfilled)
Inst. Inst. Inst. Inst. Inst.
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
Instruction block 2 block 1 block 2 block 3 block 4 block 5
m

Alternative (Simple and Special Display Format)


sa

The simple alternation gives only one condition. If the condition is fulfilled, the "yes" branch is
executed, otherwise the alternative "no" branch. An alternative can, of course, contain an
ry

underlying alternative.

Condition
The condition is a special form of alternative. The sequence or instruction block is only executed
if the condition is fulfilled. It has no alternative.
m
Multiple Alternative
The multiple alternative is also known as the multiple choice block. For the given condition,
co

there is not only one but several "yes" branches. An example would be the query of a selected
recipe number, whereby several different numbers are allowed. The possible values are each
n.

displayed in the header over the branch that they represent.


sa

Note
Structograms have a strict processing sequence, from top to bottom.
ru
bo
@
sa
m
sa
ry

6-16 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Task description
6.11 Task description

.c
s an
ru
bo
"OB_Startup"

"OB_Cycle"(cyclic program)

"FC_Mode"
@
sa
"FB_Conveyor"
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

The previously described entire task is broken down into partial tasks. In the picture you can see
sa

the first part of the subdivision of the entire task into partial tasks. In this rough structure, every
partial task can - depending on the complexity - be divided into further subordinate partial tasks
ry

or sub-functions.
(From a program perspective) the individual partial functions are then programmed in separate
blocks that implement their partial tasks as independently as possible from other blocks.

Touchpanel Program
The program for the touchpanel is already created and only has to be commissioned by you. In
the creation of the CPU program, you must, however, take into consideration the interface, that
is, the interface in the "DB_OP" data block, between the touchpanel and the CPU (see picture).
m
CPU Program
co

1. "OB_Startup_1": Display of the type of the last restart:


"P_RestartMan" (Q0.5) = manual restart, "P_RestartAuto" (Q0.6) = automatic restart
n.

2. "OB_Cycle" Call of the individual blocks which each realize the partial tasks and transfer of
the actual parameters.
sa

3. "FC_Mode": "P_Operation" (Q0.1), Acknowledgement of the restart indicator


4. "FB_Conveyor": Control of the conveyor motor:
ru

– Manual mode: Jog right / left


– Automatic mode: Transports from light barrier bay to Bay 1/2/3
bo
@
sa
m
sa
ry

6-17 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 1:
6.11.1 Copy "DB_Conveyor"
Exercise from
1: Copy blocks thethe
from library
library

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

"DB_Conveyor"
ry

For the reasons described previously, only data block variables are to be used in the S7
program instead of memory bits. If it should come to be, during the course of programming, that
further "memory bits" or data block variables than those shown in the picture are required, the
data block can be expanded at any time.
The "DB_Conveyor" data block has already been created and can be copied from the global
library "PRO2_LIB_Vxx" into your own project.

What to Do
1. In the "Global libraries", open the "PRO2_LIB_Vxx" library.
m
2. Using drag & drop, copy the object "DB_Conveyor" from the global library "PRO2_LIB_Vxx"
into your own project in the container "Program blocks".
co

3. Save your project.


n.
sa
ru
bo
@
sa
m
sa
ry

6-18 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 2:
6.11.2 Startup 2:
Exercise program "OB_Startup_1"
Startup and mode control
program "OB_Startup_1" by "FC_Mode"
and mode control by "FC_Mode"

om
"OB_Startup_1"

.c
"P_RestartMan"  StartInfo = man. restart

an
"P_RestartAuto"  StartInfo = auto. restart

s
ru
"OB_Cycle"

bo
"FC_Mode"
P_Operation %Q0.1
@ "P_Operation" Set and Reset

P_ResartMan %Q0.5 Acknowl. restart indicators with "P_Operation"


P_RestartAuto %Q0.6
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

Task
A manual restart (CPU STOP->RUN) is indicated on the simulator LED "P_RestartMan" (Q0.5);
sa

an automatic restart (power recovery) on the simulator LED "P_RestartAuto" (Q0.6).


"P_Operation" (Q0.1) is switched on via the touchpanel button "Plant ON" (DB_OP.
ry

Operation_ON) and is switched off via the button "Plant OFF" ("DB_OP". Operation_OFF).
When "P_Operation" (Q0.1) is switched on, the restart indicators "P_RestartMan" (Q0.5) and
"P_RestartAuto" (Q0.6) are automatically acknowledged or switched off.

What to Do
1. Program the "OB_Startup_1" block with the required functions.
m
2. Program the "FC_Mode" block with the required functions and, in the process, only use
local variables and the following parameters.
co

INPUT: ON BOOL
n.

OFF BOOL
sa

INOUT: Operation BOOL


RestartMan BOOL
RestartAuto BOOL
ru

3. Change the name of the organization block from "Main" to "OB_Cycle".


bo

4. Call the function "FC_Mode" in "OB_Cycle" and interconnect the parameters.


5. Check whether the operating modes can be activated via the touchpanel as required and
whether they are displayed on the touchpanel as well as indicated on the simulator.
@

6. Save your project.


sa
m
sa
ry

6-19 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 3:Exercise
6.11.3 Controlling the conveyor
3: Controlling byconmveryor
the "FB_Conveyor"
by “FB_Conveyor"

om
"OB_Cycle"

.c
"FB_Conveyor"; "iDB_FB_Conveyor"

an
"ConveyorOutput.K_Right"  Jog Right
#JogLeft  Condition Jog Left
#AutoLeft  Condition Auto Left

s
#JogLeft

ru
"ConveyorOutput.K_Left" (Q4.6)  OR
#AutoLeft

bo
Start position
"B_BayLB“
Bay 3
"B_bay3"
@ Start button
"S_BayLB"
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

"FB_Conveyor"
ry

The control of the conveyor motor is to be programmed in "FB_Conveyor" and is to function as


follows:
• "P_Operation" (Q0.1) switched off: When "P_Operation" (Q0.1) is switched off, the
conveyor motor can be moved in the relevant direction using the buttons "Jog right"
("DB_OP".Jog_Right) and "Jog left" ("DB_OP".Jog_Left).
• "P_Operation" (Q0.1) switched on: An automatic transport sequence works as follows:
A transport sequence is started by placing a part in the light barrier and pressing the Start
pushbutton "ConveyorInput".S_BayLB (I 4.4). The transport sequence is stopped as soon
m
as the part reaches the first free bay (in the current program status, always Bay 3, see
Note).
co

What to Do
n.

1. Using drag & drop, copy the object "FB_Conveyor" from the global library "PRO2_LIB_Vxx"
and in it program the required functions.
sa

2. Call the function "FB_ Conveyor" in "OB_Cycle" and provide the formal parameters.
3. Check:
ru

– Whether the conveyor motor can be moved to the right and to the left via the touchpanel
while in Manual mode
bo

– and whether parts are automatically transported from the light barrier bay to Bay 3 while
in Automatic mode.
@

Note
An automatic transport sequence ends when a part reaches the first "free" bay. The conveyor is
stopped, the bay‘s indicator light is switched on and the bay is marked as "occupied". Only after
sa

the part has been removed and it is acknowledged by pressing the associated bay pushbutton,
is the indicator light switched off and the bay is "enabled" once again.
m

Since the "FC_Signal" block for controlling the indicator lights and for "occupying" and
"enabling" the bays has not yet been programmed, the first free bay is currently always Bay 3,
sa

so that every transport sequence ends at this Bay 3.


ry

6-20 SITRAIN
SIMATIC Programming 2 in the TIA Portal

IEC-TimerIEC-Timer
6.12

om
.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Data Block
sa

In addition to internally required variables, the timer function also stores the current already
expired time in a data block which must be specified when programming the timer function. The
specified data block is automatically generated by the Editor with exactly the internal structure
ry

that the timer function requires. The user has no further programming effort with this data block
other than having to download it into the CPU.

Variables "PT" and "ET"


The variable PT of the time function can be of the type Time or LTime.

Data Type TIME


om
The contents of a variable or constant of the data type TIME is interpreted as an integer number
in milliseconds and stored in the memory as a 32-bit integer with sign. The representation
contains information for days (d), hours (h), minutes (m), seconds (s) and milliseconds (ms).
c
n.

Value range: T#-24d20h31m23s648ms to T#+24d20h31m23s647ms


a

Data Type LTIME


us

The contents of an operand of the data type LTIME is interpreted as nanoseconds. The
representation contains information for days (d), hours (h), minutes (m), seconds (s),
milliseconds (ms), microseconds (us) and nanoseconds (ns).
r
bo

Value range: -106751d 23h 47m 16s 854ms 775us 808ns


to
@

+106751d 23h 47m 16s 854ms 775us 807ns


sa
m
sa
ry

6-21 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Making
6.13 Use ofMaking
the Library
Use"LGF" (General
of the LibraryFunctions)
"LGF" (General Functions)

.c
an
Download library from
Siemens Online Support

s
Entry ID: 109479728

ru
Documentation

bo
for the Library
Use block in project

@ Call time minimum with


double frequency
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

The TIA Portal offers an extensive number of "ready-to-use" instructions (mathematical


ry

functions, timers, counters, etc.). Beyond that there are even further useful basic functions.
These functions are provided in the form of a library, "LGF" (Library of general functions). They
can be used freely, can be adjusted in any way, and so can be used universally.
The library can be downloaded free-of-charge via the Online Support under the Entry ID:
109479728.

The following types of functions can be found in the LGF:


• Bit logic operations
• Date and timer operations
om
• Counter operations
• Comparator operations
• Math operations
c


n.

Data handling
• Converter operations
sa

• Signal generators
• Technology operations
ru

Generating a Pulse
bo

In order to generate a pulse, there are several possibilities.


1. Clock memory bit (disadvantage: use of memory bits)
@

2. Program it yourself (disadvantage: effort)


3. Using the Signal generator "LGF_Frequency"
sa
m
sa
ry

6-22 SITRAIN
SIMATIC Programming 2 in the TIA Portal

Task description
6.14 Task description

om
"OB_Startup_1"

.c
"OB_Cycle"(cyclic program)
"FC_Mode"

an
"FB_Conveyor"
"FC_Fault"

s
"FC_Signal"

ru
"LGF_Frequency"

bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

In addition to the already implemented functions, the described new functions are to be
implemented in the following exercises:
sa

"FC_Fault"
Every transport sequence is monitored for time. If it takes longer than 6 seconds, there is a fault
ry

and the conveyor motor is automatically switched off. Only after the fault is acknowledged via
"S_Acknowledge" (I 0.7) or the touchpanel button can a new transport sequence be started.

"FC_Signal"
When "P_Operation" (Q0.1) is switched on, the indicator light at the light barrier bay shows with
om
a continuous light that a new part may be placed in the light barrier (Start Position), if …
– at least one of the bays 1 to 3 (STOP positions) is free (= at least one of the bay
indicator lights is dark)
c

– no conveyor fault exists (no indication at LED "P_Fault" or on the TP)


n.

Transport is started by pressing the pushbutton at the light barrier bay. As soon as the part
reaches a free bay, the conveyor motor is stopped.
a

A 2Hz flashing light from the bay indicator light indicates that the part can be removed from the
us

conveyor. The bay is still considered to be occupied even though the part has been removed,
which is indicated by a continuous light on the bay indicator light. Only after acknowledging with
r

the bay pushbutton, is the bay "enabled" once more.


bo
@
sa
m
sa
ry

6-23 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Exercise 4: Monitoring the time for the transport by "FC_Fault"
6.14.1 Exercise 4: Monitoring the time for the transport by "FC_Fault"

.c
an
"OB_Cycle"
"FC_Fault"

"DB_Conveyor".ConveyorFault  Time AutoLeft = 9s

s
ru
"DB_Conveyor".ConveyorFault Acknowledgement via
“S_Acknowledge” or on the touchpanel

bo
Bay 3
"B_bay3"

@ Start position
"B_BayLB“
sa
%I0.7 S_Acknowledge P_Fault %Q 0.7
Start button
"S_BayLB"
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Task
ry

When "P_Operation" (Q0.1) is switched on, the transport sequences are monitored. If a
transport sequence takes longer than 9 seconds, a variable ("DB_Conveyor".ConveyorFault) is
set and the conveyor motor is switched off.
Only after the fault has been acknowledged via the touchpanel button "Error acknowledge"
("DB_OP".Ack_Fault) or on the simulator via the switch "S_Acknowledge" (I 0.7) can a new
transport sequence be started.

What to Do
1. Using drag & drop, copy the "FC_Fault" block from the global library "PRO2_LIB_Vxx" into
your own project in the "Program blocks" container and open it. The block already has the
required parameters.
m
2. Program the following functions in the block:
If the IN-Parameter #AutoLeft is longer than #MaxTime = "TRUE", then the INOUT-
co

Parameter #Fault is set "TRUE". (Use an IEC Timer for this.)


The IN-Parameter #Ackn sets #Fault back to "False".
3. In the PLC tag table "My Tags", create the user constant "const_MaxTime" = 9s [data type
n.

TIME].
sa

4. Call the function in "OB_Cycle" and provide the formal parameters as follows:

INPUT: AutoLeft  "P_Operation" & "ConveyorOutput".K_Left


ru

MaxTime  "const_MaxTime"
Ackn  "S_Acknowledge" OR "DB_OP".Ack_Fault
bo

INOUT: Fault → "DB_Conveyor".ConveyorFault


@

5. Assign the LED P-fault the tag "DB_Conveyor". ConveyorFault.


6. Compile, download, and check the function.
sa

7. Save your project.


m
sa
ry

6-24 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 5:Exercise
6.14.2 Generating 2Hz frequency
5: Generating 2 Hz frequency

om
.c
"FC_Signal"
#temp_Frequ2Hz  "LGF_Frequency" with 2Hz

s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

A 2Hz pulse is to be generated in a new block ("FC_Signal") with the help of the
"LGF_Frequency" function block. This will be used in the next exercise to make the indicator
lights flash.
ry

What to Do
1. Using drag & drop, copy the "FC_Signal" block from the global library "PRO2_LIB_Vxx" into
your own project in the "Program blocks" container and open it. The block already has the
required parameters.
2. Using drag & drop, copy the "LGF_Frequency" block from the global library
om
"PRO2_LIB_Vxx" (Types > 7 Signal generators) into your own project and call the block in
Network 1 of the function "FC_Signal".
Note: You can also drag the block directly into the network in which it is to be called using
drag & drop.
c

3. As Instance, generate a data block with the symbolic name "iDB_LGF_Frequency_2Hz".


n.

4. Provide the formal parameters as shown in the picture, whereby the actually generated
a

‘Pulse’ is stored in the temporary variable #temp_Frequ2Hz.


us

Note:
Since the "LGF_Frequency" block is stored in the library as Type (Types folder), it is
r

automatically copied into the Types folder of the Project library during copying. In the Program
bo

blocks folder, itself, an instance of the block is stored and the block can be downloaded into the
CPU as usual. (see Additional Information: "Standardizing with Libraries in the TIA Portal")
If the block is to be changed, a new version is created which can be rejected or released after
@

testing.
The connection of the instance can also be separated from the type in the Project tree via the
context menu (right mouse button>Terminate connection to type). Editing is then possible as
sa

usual.
m
sa
ry

6-25 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 6:Exercise
Indicator6:
lights "FC_Signal"

om
6.14.3 Indicator lights "FC_Signal"

"OB_Cycle"

.c
"FC_Signal" Bay 1 / 2 / 3 Start position
"B_Bay1 / 2 / 3" "B_BayLB"
Generate 2 HZ frequency

an
Occupy and enable Bay 1:
"DB_Conveyor".Occupied.Bay1

s
Status display at "…P_Bay1"

ru
Occupy and enable Bay 2:
"DB_Conveyor".Occupied.Bay2 "S_Bay1 / 2 / 3" Start button
Acknowledge button "S_BayLB"
Status display at "…P_Bay2"

bo
Occupy and enable Bay 3:
"DB_Conveyor".Occupied.Bay3 "P_Bay1 / 2 / 3" "P_BayLB":
Status display at "…P_Bay3" Dark: Bay free Dark: All bays occupied

Status display at "P_BayLB"


Flashing light at "P_Fault" when
@Continuous light: Bay occupied
Flash. light: Remove part
Continuous light: Place new part
Flash. light: Press Start pushbutton
"DB_Conveyor".ConveyorFault S_Acknowledge %Q 0.7
sa
%I0.7 P_Fault 2 Hz flashing
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

conveyor fault
m

Task
sa

When "P_Operation" (Q0.1) is switched on, the parts are transported from the light barrier bay
to the first free bay. The bay indicator lights are controlled as follows:
ry

• "ConveyorOutput".P_Bay1 / 2 / 3" (Q4.1 / 2 / 3)


When the part reaches the first free bay ("DB_Conveyor".Occupied.BayX = 0), the conveyor
is stopped, "DB_Conveyor".Occupied.BayX is set to 1, and the indicator light of the
associated bay indicates with a 2Hz flashing light that the part can be removed from the
conveyor. After the part has been removed, the bay is still considered to be "occupied"
which is indicated by a continuous light on the bay indicator light. Only after acknowledging
with the associated bay pushbutton, is the bay "enabled" once again
("DB_Conveyor".Occupied.BayX is set to 0).
om
• "ConveyorOutput"."P_BayLB" (Q4.4)
A continuous light on the indicator light "P_BayLB" indicates that a new part can be placed
in the light barrier if there is no longer a part on the conveyor and at least one of the Bays 1
c

to 3 is free ("DB_Conveyor".Occupied.Bay1, 2, or 3 = 0). If a part is placed in the light


barrier and the conveyor has not yet been started, the indicator light flashes with 2Hz
n.

flashing light indicating that the conveyor can be started. If all bays are occupied, the
indicator light "ConveyorOutput".P_BayLB (Q4.4) remains dark and no further transport
a

sequence can be started.


us

If a conveyor fault was detected ("DB_Conveyor". Conveyor_Fault = 1) with the help of the
function "FC_Fault", then the error is indicated on the simulator LED "P_Fault" (Q0.7) with a
r

2Hz flashing light and displayed on the touchpanel in the "Conveyor" screen with a text
bo

message.

Solution Hints
@

On the conveyor model as well as on the touch panel, occupied bays are indicated by a
switched-on bay indicator light. Within the program, each bay is assigned a data block variable
"DB_Conveyor".Occupied.Bay1, 2, or 3 that is assigned the status '1' when the bay is occupied.
sa

These tags (variables) must be managed by the "FC_Signal" block now to be programmed (bit
is set at conveyor stop and reset when acknowledged) and accordingly interlocked in "FB_
Conveyor".
m
sa

Continued on the next page


ry

6-26 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
What to Do
1. Copy the "FC_Signal" block from the library "Pro2_LIB_Vxx" into the Blocks folder. The
updated interface already exists on this block.

.c
2. Program the required functions in the "FC_Signal" block. To avoid the use of global

an
operands within the block, use the already existing parameters which you will later assign
as follows (see picture below) when "FC_Signal" is called in "OB_Cycle":
– For the required flashing of the indicator light, use the 2Hz pulse #temp_ Frequ2Hz

s
generated in the previous exercise.

ru
– So that no edge evaluation has to be programmed within the block for the Belt-Stop-
edge required for the program, program this in "OB_Cycle" and pass its result to the

bo
temporary variable #tempAutoLeftStop (this variable must be declared and will be
required later on) and the IN-Parameter #AutoConveyorStop.
As an edge memory bit, create a new Boolean variable with the name

– @
"AuxAutoLeftStop" in "DB_Conveyor".
The text message which is to be displayed in the "Conveyor" screen of the touchpanel
is already implemented and is displayed when simulator LED "P_Fault" has the signal
sa
state "TRUE".
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

3. Expand the "FB_Conveyor" block in such a way that the conveyor can only be started when
m

at least one of the bays 1 to 3 is "free".


4. Check the required functions.
sa

5. Save your project.


ry

Call of "FC_Signal" in organization block "OB_Cycle"

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

6-27 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
6.15 Appendix
Standardizing with Libraries in TIA Portal (1)

.c
6.15.1 Standardizing with Libraries in TIA Portal (1)

an
Develop Standardize Reuse

s
ru
Read only

bo
Main
Library

Function type Version 1.0

@
Read only

Main
Main
Version 1.0
Version 1.0
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Save function in Use write-protected


the library as Type instance of the Type
in the projects
sa

and version
ry

With the help of the Project library, objects can very easily be versioned / standardized and by
means of the Global libraries, the different versions are updated across multiple projects.

Develop
During development, objects (for example, blocks) are created in the usual manner and saved
in the project.

Standardize
Then, the object is moved into the Project library folder using drag and drop. An instance to the
m
stored object in the Project library is generated in the device (original storage location).
Other objects that the object refers to are also automatically moved and an instance is also
co

created for these.


n.

Reuse
This instance is write-protected. Now, further instances of the created type in the library can be
sa

generated in other devices. Since the instances are write-protected, they all remain identical.
ru
bo
@
sa
m
sa
ry

6-28 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Standardizing with Libraries in TIA Portal (2)

om
Standardizing with Libraries in TIA Portal (2)

.c
Expand Standard Update Instances

an
Library
Read only

Function type Main

s
Version 2.0

ru
Read only

bo
Version 1.0
Main
Version 2.0

Expand/change
function and assign
new version
@
Update instances
sa
Version 2.0
per mass operation
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Expand Standard
When the object is changed, a new version is created, whereas the old version is retained. This
new version can be tested in a device (an instance) and subsequently saved or discarded. In
ry

the latter case, the instance once again refers to the initial version. If the new version is saved,
the instance in the device refers to this one.

Update Instances
As required, the instances in the other devices can be updated and versions in Global libraries
can be saved or updated as well.
With the help of Global libraries, the objects in the Project library can be updated and saved in
m
further projects. Instances in these projects also refer to the newest version after updating or
generation.
co

Each instance must refer to a version in the Project library.


In this way, you have a tool which automatically takes care of a versioning and standardization
n.

across multiple projects.


sa
ru
bo
@
sa
m
sa
ry

6-29 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
7 Analog Process & Arithmetic

.c
an
Learning
7.1 objectives
Learning objectives

s
ru
• You know the principle of analog value processing

• You can assign parameters to an analog module

bo
• You can address an analog module

@
• You can interpret the resolution of a module

• You are familiar with arithmetic functions and be able to use them
sa
• You are familiar with a "Cyclic interrupt" - OB and be able to use them
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

• You are familiar with process images and process image partitions
sa
ry

c om
n.
sa
ru
bo
@
sa
m
sa
ry

7-1 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal

Task
7.2Description:
TaskChecking the Weight
Description: and Statistic
Checking the Values
Weight and Statistic Values

.c
s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

Checking the Weight:


The parts to be transported are weighed in the Start Position (light barrier) before the conveyor
is started. The part weight (0 to 500 kg) is simulated via the operator panel (simulator)
potentiometer "S_slider1" (%IW10) and displayed on the touchpanel screen "11_Conveyor".
The permitted range of the part weight is 100kg <= Weight <= 400kg
As long as a part is in the light barrier and an invalid weight (weight < 100kg or weight > 400kg)
is set…
... the operator panel indicator light "P_weightFault" (%Q0.0) shows a 2Hz flashing light.
... the indicator light at the light barrier bay is dark because no part with an invalid
weight may be transported
... no transport sequence can be started
m
The weights of the parts that are at the light barrier, on the conveyor, and at the individual bays
co

are also displayed on the "12_Bay" screen.

Statistic Values
n.

All transported parts are counted when they reach the next free bay. Both the number of parts of
sa

the individual bays and the total number of parts that were transported are recorded. In addition,
the utilization of the individual bays is determined, that is, the percentage of parts transported to
each Bay is calculated.
ru

All statistic values are displayed on the touch panel on the "Statistic" screen.
bo
@
sa
m
sa
ry

7-2 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Principle of Analog Value Processing
7.3 Principle of Analog Value Processing

.c
Process Analog input module User program

an
Physical Standard Read in the result memory or
Result the digitalized input signals …
quantity analog signal memory
… through direct … in the PII through the
%IW…..:P

s
Sensor Transducer I/O access CPU operating system
%IW…..:P in the program at cycle start
ADC

ru
%IW…..:P

bo
• Pressure ± 500mV 0 0
• Temperature ± 1V %IW64:P #temp %IW64 #temp
• Flow ± 5V 27648 27648
• Speed ± 10V
• pH value ± 20mA


Viscosity
etc.
4 to 20mA
etc. @
Analog output module

0
#temp %QW80:P
0
#temp %QW80
sa
27648 27648

Conversion
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

memory
Through direct From the PIQ through the
m

%QW…..:P I/O access CPU operating system


Physical Analog %QW…..:P in the program … at cycle end …
DAC
quantity actuator
sa

%QW…..:P … output digital output signals


ry

Principle of Analog Value Processing


In a production process, there are a variety of physical quantities (such as pressure,
temperature, speed, rotational speed, pH value, viscosity, etc.) that need to be processed in the
PLC to solve the automation task.

Sensor
Measuring sensors respond to changes in the quantity to be measured by such things as linear
expansion, angular strain, and alteration of electrical conductivity.
om
Transducer
Measuring transducers convert these above-mentioned changes into standard analog signals,
c

such as: ± 500mV, ± 10V, ± 20mA, 4 to 20mA.


These signals are supplied to the analog input modules.
n.

ADC
a

Before these analog values can be processed in the CPU, they must be converted to digital
us

form. The ADC (Analog-to-Digital Converter) on the analog input module handles this
conversion. The analog-to-digital conversion is performed sequentially. This means the signals
r

are converted for each analog input channel in turn.


bo

Result Memory
The result of the conversion is stored in the so-called result memory and is retained there until it
@

is overwritten by a new value. With the expansion ":P" in conjunction with the absolute address
or the symbolic name of the analog channel, the converted analog value can be read directly
from the module.
sa

Analog Output
m

The analog values calculated by the user program are written to an analog output module via
the transfer operation (MOVE), where a DAC (Digital-to-Analog Converter) converts them to
sa

standard analog signals.

Analog Actuators
ry

You can connect standard actuators directly to the analog output modules.

7-3 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Analog
7.4 Input Analog
Modules Input Modules

om
.c
an
Activated
Diagnostics

s
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Hardware
interrupt call
m
sa

Measurement Type
The type of measurement, such as voltage, is set with this parameter. An unused channel
should be deactivated since it is otherwise also converted resulting in a longer total conversion
ry

time of the module.

Measuring Range
Click the field to display the available measuring ranges for the corresponding measurement
type.
m
Interference Frequency Suppression
co
This suppresses the interferences which are caused by the frequency of the AC mains. The
higher the interference frequency suppression, the shorter the conversion time is.
n.

Smoothing
sa

By specifying the smoothing, you define how many measurements have to be made in order to
form an average value, which leads to the reduction of the influence of interference signals. A
smoothing makes sense for slow measured value changes. The higher the smoothing, the more
ru

stable the analog signal is and the longer it takes until the smoothed analog value is applied
after a signal change.
bo

Diagnostic Interrupt
The module triggers a diagnostic interrupt on the CPU when an error occurs. Then, error
@

information is entered in the diagnostic buffer and the CPU processes the program in the
Diagnostic interrupt OB (Event class: Diagnostic error interrupt). In this OB, the user can
program the necessary response to the error that occurred. Which errors an analog module can
sa

recognize depends on the module type.

Hardware Interrupt
m

The module triggers a hardware interrupt when a particular event occurs (such as exceeding a
sa

voltage limit on a channel of an analog input module). Then the CPU processes a so-called
hardware interrupt program that the user stores in one of the “Hardware interrupt” OBs (Event
class: Hardware interrupt) to determine the response to the event.
ry

7-4 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Analog Output Modules
7.4.1 Analog Output Modules

om
.c
s an
ru
Activated
Diagnostics

bo
@
Output value
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
for CPU STOP
m

General
sa

Depending on the type of analog output module, voltages and/or currents can be output
(see picture).
ry

Output Type
The type of output, such as voltage, is set with this parameter. Unused outputs must be
deactivated since these are otherwise also converted thus increasing the total conversion time
of the module.
m
Output Range
co
The output range of the respectively selected type of output is set with this parameter.

Reaction to CPU STOP


n.

Here, you can parameterize how the output channel is to behave in the event that the CPU
sa

switches into the STOP state:


• Shutdown (Output has no current or voltage)
ru

• Keep last value


• Output substitute value (substitute a value)
bo

Diagnostic Interrupt
The module triggers a diagnostic interrupt on the CPU when an error occurs. Then, error
@

information is entered in the diagnostic buffer and the CPU processes the program in the
Diagnostic interrupt OB (Event class: Diagnostic error interrupt). In this OB, the user can
program the necessary response to the error that occurred. Which errors an analog module can
sa

recognize depends on the module type.


m
sa
ry

7-5 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Analog
7.5 ValueAnalog
Representation
Value and Measured Valueand
Representation Resolution
Measured Value Resolution

.c
an
Bit no. min. units 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Bit value Dec. Hex. Sign 214 213 212 211 210 29 28 27 26 25 24 23 22 21 20

s
8 128 80 * * * * * * * * * 0 0 0 0 0 0 0

ru
9 64 40 * * * * * * * * * * 0 0 0 0 0 0

bo
10 32 20 * * * * * * * * * * * 0 0 0 0 0
Resol-
ution
11 16 10 * * * * * * * * * * * * 0 0 0 0
in bits
12 8 8 * * * * * * * * * * * * * 0 0 0
+ sign
13 4 4
@
* * * * * * * * * * * * * * 0 0

14 2 2 * * * * * * * * * * * * * * * 0
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

15 1 1 * * * * * * * * * * * * * * * *
m

* = 0 or 1
sa

Representation
ry

Negative analog values are represented as the two's complement.


The value is positive if bit No. 15=’FALSE’ and negative if bit No.15=’TRUE’.

Resolution
If the resolution of an analog module is less than 16 bits, the analog value is written into the
accumulator (module result memory) left-justified. The unused less significant bit positions are
filled with ‘FALSE’.

Accuracy
om
Resolutions of between 8 and 16 bits are possible, depending on the type of module (S7-
300/400/1200)
c

S7-1500 modules all have a resolution of 16 bits.


a n.
r us
bo
@
sa
m
sa
ry

7-6 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Analog Value Representation for Different Measuring Ranges
7.5.1 Analog Value Representation for Different Measuring Ranges

.c
an
Voltage Current Resistance Temperature
such as: such as: such as: e.g. Pt100 (Standard)
Range

s
Meas.range Meas.range Meas.range Meas.range
± 10V Units 4 to 20mA Units 0to300Ohm Units -200to+850ºC Units

ru
Overflow >= 11.759 32767 >= 22.815 32767 >=352.778 32767 >= 1000.1 32767

bo
11.7589 32511 22.810 32511 352.767 32511 1000.0 10000
Over range : : : : : : : :
10.0004 27649 20.0005 27649 300.011 27649 850.1 8501

10.00 27648 20.000 27648 300.000 27648 850.0 8500


Rated range
7.50
:
-7.5
-10.00
:
@
20736

-20736
-27648
16.000
:
:
4.000
20736

0
:
:
225.000
:
:
0.000
20736

0
:
:
:
:
:
-200.0
:
:
:
-2000
sa
- 10.0004 - 27649 3.9995 -1 -1 - 200.1 - 2001
Under range negative
: : : : : : :
values
- 11.759 - 32512 1.1852 - 4864 - 4864 - 243.0 - 2430
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

not
m

<= - 11.76 - 32768 <= 1.1845 - 32768 possible - 32768 <= - 243.1 - 32768
Underflow
sa

Voltage, Current (Symmetrical)


ry

Converting the symmetrical voltage or current ranges


• ± 80mV • ± 2.5 V • ± 3.2 mA
• ± 250 mV • ± 5V • ± 10 mA
• ± 500 mV • ± 10V • ± 20 mA
• ±1V
results in a rated range of -27648 to +27648.

Voltage, Current (Asymmetrical)


Converting the asymmetrical voltage or current ranges
om
• 0 to 2 V • 0 to 20 mA
• 1 to 5 V • 4 to 20 mA
results in a rated range of 0 to +27648.
c
n.

Resistance
Converting the resistance ranges
sa

• 0 to 150 Ohm
• 0 to 300 Ohm
ru

• 0 to 600 Ohm
results in a rated range of 0 to +27648.
bo

Temperature
Temperatures are measured with resistance thermometers or thermocouples. Converting
@

results in a rated range of ten times the temperature range.


sa
m
sa
ry

7-7 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Analog Value Representation for the analog Outputs
7.5.2 Analog Value Representation for the Analog Outputs

om
Voltage Current

.c
Range Units
Output ranges: Output ranges:

an
0 to 10V 1 to 5V ± 10V 0 to 20mA 4 to 20mA ± 20mA

Overflow >=32767 0 0 0 0 0 0

s
32511 11.7589 5.8794 11.7589 23.515 22.81 23.515
Over range : : : : : : :

ru
27649 10.0004 5.0002 10.0004 20.0007 20.005 20.0007

27648 10.0000 5.0000 10.0000 20.000 20.000 20.000


: : :

bo
: : : :
0 0 1.0000 0 0 4.000 0
: : :
0 0.9999 0 3.9995
Rated range - 6912 : :
: :
- 6913 0 : 0 :
:
:
:
- 27648
@ 0
:
:
:
-10.0000
0
:
:
:
-20.000
sa
- 10.0004 - 20.007
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

- 27649
Under range : : :
- 32512 - 11.7589 - 23.515
m

Underflow <=- 32513 0 0


sa

Voltage, Current (Symmetrical)


For symmetrical voltage or current ranges, a rated range of -27648 to +27648 is converted to:
ry

• ± 10V
• ± 20mA

Voltage, Current (Asymmetrical)


For asymmetrical voltage or current ranges, a rated range of 0 to +27648 is converted to:
• 0 to 10V
om
• 1 to 5V
• 0 to 20mA
• 4 to 20mA.
c
n.

Overflow
If the value to be converted reaches the overflow range, the analog output module is disabled
a

(0V, 0mA).
r us
bo
@
sa
m
sa
ry

7-8 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Process
7.6 image
Process image

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Module Parameter Assignment


ry

After the hardware components have been inserted in your rack, the preset properties can be
edited, such as the names, parameters, or addresses.
The settings, that is, parameters of all modules are downloaded into the CPU which must be in
the STOP state for this. With a subsequent restart, the CPU independently distributes the
parameters to the relevant modules via the backplane bus.

I/O Address (Peripheral address)


I/O addresses (input/output addresses) are needed to read inputs and set outputs in the user
program.
m
Input and output addresses are automatically assigned when modules are inserted in the rack.
The address of the first channel is the start address of a module. The addresses of the
co

remaining channels results from this start address. The end address results from the module-
specific address length.
n.

Organization Block and Process Image


sa

The values of input and output modules can automatically be read-into the process image for
inputs (PII) and written from the process image for outputs (PIQ). The general PII and PIQ
(called "Automatic update" in the screen/picture) is not assigned to any OB as process image
ru

partition and is read-in or written in the peripherals cyclically at the cycle control point.
bo

If the address is assigned to a process image partition (PIP), which in turn is assigned to a
specific OB, then the process image is updated at the beginning as well as the peripherals
(updated) at the end of the OB.
@

If the PIP is not assigned to any OB, then it must be updated in the user program with the
functions "UPDAT_PI" and "UPDAT_PO".
sa
m
sa
ry

7-9 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Process Image Partitions
7.6.1 Process Image Partitions

.c
an
Cycle OB

s
Process image for inputs and outputs

ru
Program execution

Process image for inputs and outputs

bo
Program execution OB “Cyclic interrupt”
Process image partition 1 for inputs

Addresses with setting Program execution OB “Hardware interrupt”

@
Process image partition 2 for inputs
Adressen mit Einstellung Program execution
Process image partition 2 for outputs
sa
Resume program execution
Process image partition 1 for outputs
Resume program execution
Addresses with setting
m

Process image for inputs and outputs


Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Program execution Cycle OB


sa

Adressen mit Einstellung


ry

Process Image for Inputs and Outputs


For reasons of access speed and the consistency of the status of individual inputs throughout
the entire cycle, a copy is stored in the process image for inputs (PII) which is accessed during
program execution. The writing of outputs occurs in the process image for outputs (PIQ). The
statuses of outputs stored here are written into the actual outputs at the beginning of every
cycle.
The inputs and outputs of an S7-1500 are automatically made available in the process image
for inputs and outputs as long as this is not changed in the settings of the individual blocks.
Under the Properties of the module > General > Input…/Output… > I/O addresses, “Automatic
update” (“Automatische Aktualisierung”) is set in Organization block and Process image.

Process Image Partition (PIP)


m
Inputs and outputs which are not used in the cyclic program, that is, not in every cycle, do not
have to be updated with the process image at the beginning of every cycle. For that reason,
co

there are the process image partitions which in turn can be assigned to individual organization
blocks. If an OB is executed which has a PIP assigned to it, then the inputs of the associated
n.

PIP are read-in at the beginning, and the statuses of the outputs of the PIP are written in the
relevant peripherals at the end. If a process image partition is not assigned to any organization
sa

block, then the update of this PIP must be done with the help of instructions.

Updating a Process Image Partition in the User Program


ru

Each PIP can be updated in the user program with special instructions. For this, the instructions
bo

"UPDAT_PI" for updating inputs and "UPDAT_PO" for updating outputs is used.
@
sa
m
sa
ry

7-10 SITRAIN
SIMATIC Programming 2 in the TIA Portal

Direct
7.7 I/O Access withI/O
Direct ":P"
Access with ":P"

om
Parameterization of the AI module

.c
s an
ru
bo
Direct I/O
access @
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Direct I/O Access


Direct I/O accesses are identified with the addition ":P". This addition is programmed in
ry

conjunction with the absolute address or the symbolic name.


Direct I/O accesses are particularly necessary when the addresses of the module (as shown in
the picture) are not assigned to any process image or this is not updated. The converted
channel values must then be read-out directly from the module.
The direct access to the I/O has the advantage that the current value is directly read-in (that is,
the output is directly updated) and not at the beginning of the cycle or when the process
partition is updated.
om
The disadvantage of the direct access to the I/O is that this requires more time than the access
to the process image. In addition, it has to be taken into account that the values can change
during the course of the cycle, that is, the value of an input can be different when it is read
c

several times per cycle (not consistent).


a n.
r us
bo
@
sa
m
sa
ry

7-11 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Scaling
7.8 with NORM_X
Scaling and
withSCALE_X
NORM_X and SCALE_X

om
.c
OUT

an
1.0

s
e.g. Nominal range of the
AI module

ru
0.0
IN

bo
MIN: 0 MAX: 27648

Can be parameterized!
OUT

@ MAX
500.0

Measuring range
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

MIN
m

0.0
IN
0.0 1.0
sa

NORM_X
NORM_X scales the input signal "Value" with parameter-assignable data type and value range
ry

(through values of the input parameters "MIN" and "MAX") to the norm signal 0.0 to 1.0
(0% to 100%) that is output at output OUT.

SCALE_X
SCALE_X maps the norm signal with value range 0.0 to 1.0 (0% to 100%) at input "Value" to
the value range that can be parameterized via the inputs MIN and MAX. The value scaled in
such a way is output at output OUT (MIN <= OUT <= MAX).
om
Through the combination of these instructions, any value ranges can be mapped or scaled on
other value ranges.
c
a n.
r us
bo
@
sa
m
sa
ry

7-12 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Math
7.9Functions: MIN, MAX, LIMIT MIN,

om
Math Functions: MAX, LIMIT

.c
s an
ru
More than 2
inputs possible!

bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

MIN / MAX
The "Get minimum" ("Get maximum") instruction compares the values of the inputs IN1 to INx
ry

and outputs the smallest (largest) input value at output OUT. The error-free processing of the
instruction (ENO = 'TRUE') presumes that the values at all inputs are valid.

LIMIT
The "Limit" instruction limits the value at input IN to the values at the inputs MN and MX. When
the value at input IN satisfies the condition MN <= IN <= MX, it is output at the output OUT.
• If the input value IN falls below the lower limit MN, the value of MN is output at the output
m
OUT.
• If the input value IN exceeds the upper limit MX, the value of MX is output at the output
co

OUT.
• If the value at input MN is greater than the value at input MX, the result is undefined and the
n.

enable output ENO supplies the value "TRUE".


The error-free processing of the instruction (ENO = 'TRUE') presumes that the values at all
sa

inputs are valid, and that MX > MN.


ru
bo
@
sa
m
sa
ry

7-13 SITRAIN
SIMATIC Programming 2 in the TIA Portal

7.9.1 Verification with IN_RANGE, OUT_RANGE and checking Real Value with OK,

om
Verification with IN_RANGE, OUT_RANGE and Checking Real Value with OK,
NOT_OK
NOT_OK

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

IN_RANGE / OUT_RANGE
ry

The "IN_RANGE" ("OUT_RANGE") instruction checks whether the value at input VAL lies within
(outside of) the value range defined through the inputs MIN and MAX. If this condition is
satisfied, the output supplies the value 'TRUE'.
The error-free processing of the instruction presumes that the values at both inputs are valid
and are of the same (parameter-assignable) data type.

OK / NOT_OK
m
The OK (NOT_OK) instruction checks whether the value of the variable specified through the
box corresponds to a valid (invalid) REAL or LREAL. If this is the case, the box supplies the
co

value 'TRUE' at its output.


n.
sa
ru
bo
@
sa
m
sa
ry

7-14 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Task Description:
7.10 Checking the Weight
Task Description: and Displaying
Checking it
the Weight and Displaying It

.c
an
%Q0.0 P_weightFault %A0.0
%AW32

s
ru
0..12V
0..12V

bo
0..12V

@
%IW10
%EW10
P_weightFault
%A0.0
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task Description: Checking the Weight


ry

The parts to be transported are weighed in the Start Position (light barrier) before the conveyor
is started. Since there is no real weighing scale on the training area, the scaled analog signal (0
to 10 V) is simulated with the operator panel (simulator) potentiometer "S_slider1" (%IW10). In
the program, the signal generated and scaled by the Analog-to-Digital Converter is then
converted into the weight value (0 to 500 kg) and displayed on the touchpanel screen
"11_Conveyor" as soon as the light barrier is occupied.
In addition, the voltage that is set is also displayed in the display field "P_voltageDisplay1".
The permitted weight is 100kg to 400kg.
As long as an invalid weight (weight < 100kg or weight > 400kg) is set and the light barrier is
occupied…
• the indicator light "P_weightFault" (%Q0.0) on the operator panel (simulator) shows a 2Hz
om
flashing light.
• the indicator light on the light barrier bay is dark because no part with an invalid weight may
be transported
c

• no transport sequence can be started


n.
sa
ru
bo
@
sa
m
sa
ry

7-15 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 1: "UnitWeight" - OB "CyclicInterruptWeight": Simulating and Checking the Weight
7.10.1 Exercise 1: Checking the weight with OB "CyclicInterrupt

.c
P_VoltageDisplay1 (QW32)
“OB_Cyclic interrupt_1“

an
0 ... 10V
Visualize the value of S_Slider1
at P_VoltageDisplay1

s
10V
Calculate the value of S_Slider1 into Kg

ru
using "NORM_X" and „SCALE_X“
0V and store it in
the tag "DB_Conveyor".Weight

bo
"DB_Conveyor".Weight
S_Slider1 (IW10)
"DB_Conveyor".WeightOK = '1' Weight > 400 kg
Poti to simulate the weight
100kg <= "DB_Conveyor".Weight <= 400kg No yes
0 … 10V = 0 … 500kg

0V 10V
@ N0
Weight < 100 kg
yes
%
sa
0 ... 10V "DB_Conveyor". "DB_Conveyor".
WeightOK ← TRUE WeightOK ← FALSE
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Checking the Weight


sa

The weight simulated via the potentiometer is acquired and stored in the variable
"DB_Conveyor".Weight and checked whether it lies within the specified limits of 100 to 400kg.
ry

Furthermore, the voltage set with the potentiometer "S_Slider1" is displayed in the display field
"P_VoltageDisplay1".

What to Do
1. Expand "DB_Conveyor" by adding the variables "Weight" (data type UINT) and "WeightOK"
(data type BOOL) as shown in the picture.
2. Insert a new "Cyclic Interrupt" OB. Rename it "OB_ Cyclic Interrupt_1" and set the call
interval to 250 ms in its Block Properties.
3. In this OB, write logic so that the voltage set at "S_Slider1" (IW10) is displayed in the upper
om
display "P_VoltageDisplay1" (QW32).
4. Furthermore, with the help of the instructions "NORM_X" and "SCALE_X", program the
required function of weight acquisition and store the value in the variable
.c

"DB_Conveyor".Weight.
an

5. Program the function of weight evaluation and assign the relevant value to the variable
"DB_Conveyor".WeightOK.
6. Check all functions and save your project.
r us
bo
@
sa
m
sa
ry

7-16 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
ExerciseExercise
7.10.2 2: Expanding “FC_Signal"
2: Expanding and “FB_Conveyor"
“FC_Signal" and “FB_Conveyor”

.c
s an
P_WeightFault %Q0.0

ru
P_Operation %Q0.1

bo
S_Acknowledge P_Fault %Q0.7

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
As long as an invalid weight is set,
ry

• The conveyor model indicator light "ConveyorOutput".P_BayLB (Q4.4) is dark since a part
with an invalid weight must not be transported.
• No transport sequence can be started.
• The indicator light "P_WeightFault" (Q0.0) on the simulator shows a 2Hz flashing light.

What to Do
1. In the blocks "FC_Signal" and "FB_Conveyor", declare a new Input parameter with the
name "WeightOK" (data type Bool).
2. In the “FC_Signal” block, declare an Output parameter with the name "LEDWeightFault"
(data type Bool).
om
3. Update the calls of the two blocks.
4. Pass the variable "DB_Conveyor".WeightOK to the blocks "FC_Signal" and "FB_Conveyor"
with the help of the new Input parameter as shown in the picture for "FC_Signal".
c

5. In addition, assign the variable "P_WeightFault" to the formal parameter "LEDWeightFault"


n.

(see picture).
6. In both blocks, program the above-mentioned interlocks as well as the display.
sa

7. Compile and download the modified program into the CPU.


8. Save your project.
ru

Note
bo

Since the visibility of the display "invalid!" is already programmed in the touchpanel (when
"P_WeightFault" = "TRUE"), it must flash when there is a faulty weight!
@
sa
m
sa
ry

7-17 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 3: Displaying the Current Weights on the Touchpanel
7.10.3 Exercise 3: Displaying the Current Weights on the Touchpanel

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

Task
The current part weight set on the simulator and saved in the variable "DB_Conveyor".Weight is
to be displayed on the touchpanel. For this, an output field must be created in the "Conveyor"
screen.

What to Do
1. Close all objects that are open in the Editor.
2. Open the "DP_Conveyor" data block in which the weight is saved.
om
3. In addition, open the touchpanel screen "Conveyor".
4. Split the editor area into two areas (see picture).
5. Configure the output field for displaying the weight by dragging the variable "Weight" from
c

the data block into the touchpanel screen using drag & drop.
n.

6. Select the newly created input/output field and, in the Inspector window under "Properties->
sa

General", set "Output" as the Mode for "Type" and adjust the display.
ru
bo
@
sa
m

7. Compile, save, download, and test the changes.


sa
ry

7-18 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
IEC7.11
Counters:IEC
CTU, CTD, CTUDCTU,
Counters: CTD, CTUD

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Counters
ry

Counters are used to count events, record quantities, or similar. There are up counters and
down counters as well as counters that can count in both directions.

Value Range of a Counter


The count or value range of a counter depends on its data type (see picture) which is always an
integer. The various selectable Integer data types merely differentiate themselves in their value
range and thus determine the count range of the counter.

Instance Data Block


om
In addition to internally required variables, the counter also stores its current counter value in an
instance data block which must be specified when programming a counter. The specified
instance data block is automatically generated by the Editor with exactly the internal structure
that the counter requires. The user has no further programming effort with this data block other
.c

than having to download it into the CPU.


an
r us
bo
@
sa
m
sa
ry

7-19 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Meaning
7.12 of EN and ENO of
Meaning EN and ENO

om
.c
an
Block call

s
ru
bo
Arithmetic instructions
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

EN = Enable Input
You can modify a call with the help of the enable input EN. It exists at every box for the call of a
ry

block or a complex function in Ladder Diagram.


• If no condition preceeds EN, the function in the box is always executed
• If a condition is present at EN, the function in the box is only executed if the condition is
fulfilled (signal state 'TRUE'). If the condition is not fulfilled (signal state 'FALSE'), the
function in the box is not executed.

ENO = Enable Output


m
With the help of the enable output ENO, the called block or the function signals whether the
co

execution took place and whether it was executed error-free.


With the function "RETURN", you can end the current execution of the block and in doing so set
the output parameter "ENO" = 'TRUE' or in case of error equal to 'FALSE'.
n.

A uniform mechanism for passing the error status is thus available in STEP 7. In this way, for
sa

example, a block that is called can inform the calling block whether the processing was
executed error-free or not.
ru
bo
@
sa
m
sa
ry

7-20 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Activating/Deactivating the ENO Generation
7.12.1 Activating/Deactivating the ENO Generation

om
The setting applies for this

.c
and all instructions that
are subsequently inserted

an
ENO deactivated

s
ru
bo
ENO activated

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

ENO can be deactivated


All math operations as well as the MOVE box have an ENO output in LAD and FBD through
which the result can be checked for validity.
ry

This ENO output can be deactivated for the purposes of runtime optimization through the menu
item "Do not generate ENO", so that the internal result check for validity does not take place.

Note
For each instruction, you can individually activate or deactivate the ENO mechanism. If you
activate or deactivate the EN/ENO mechanism for an instruction, further instructions which you
m
drag into your program after that are also inserted with an activated or deactivated EN/ENO
mechanism.
co

Caution
n.

With a math operation, the ENO output should only be deactivated if type conversions or
overflow results can be ruled out.
sa
ru
bo
@
sa
m
sa
ry

7-21 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Conversion Operations: Data Type Conversion
7.12.2 Conversion Operations: Data Type Conversion

om
.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Conversion Operations
Conversion operations are used to convert variables of different arithmetic data types to the
ry

same type since only variables of the same data type can be calculated.
Converting data from one data type to a data type with a larger value range is unproblematic
(for example, from INT to REAL). Here, no overflow can result and thus no error.
Problematic, on the other hand, can be data type conversions into another data type with a
smaller value range (for example, from REAL to INT). An overflow can result (when the current
value of the REAL variables is 35000, for example), so that an incorrect value is then output at
the output OUT. Through the output ENO you can query whether the data type conversion
m
occurred without an error (= 'TRUE' when error-free).
co
n.
sa
ru
bo
@
sa
m
sa
ry

7-22 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Implicit Data Type Conversion

om
7.12.3 Implicit Data Type Conversion

.c
Unproblematic type conversion (gr/gr)

an
SInt More than for example, INT -> DINT
2 inputs!

s
ru
Int Type conversions and
calculation (e.g. no

bo
overflow) OK?

? Risky type conversion (gr/w)


for example, REAL -> INT
DInt
@
? Display in the online status
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Real
m
sa

Implicit Type Conversion


Basically, math operations are only possible with operands of the same data type. If two
ry

variables of different data types are to be processed mathematically (e.g. addition,


multiplication...), the data types of the two variables must be adapted to one another with explicit
data type conversions.
In S7-1200/1500, with the math instructions in LAD and FBD, data type conversions are implicit,
that is, necessary data type conversions are integrated in the math instruction.
The programming editor identifies operands which are implicitly converted with a grey square. A
dark grey square signals that an implicit conversion without loss of accuracy is possible, for
example, when you convert the data type SINT to INT. A light-grey square signals that an
om
implicit conversion is possible but during runtime errors could occur (no IEC check set). If, for
example, you convert the data type DINT to INT and there is an overflow, the enable output
ENO is set to 'FALSE'.
c

The example shows an integer addition of "INT_Value1", "INT_Value2", and "REAL_Value3".


n.

For this, "REAL_Value3" is implicitly converted from REAL to INT and then added to
"INT_Value1" and "INT_Value2". The integer result of the addition is converted in an implicit
a

type conversion from INT to DINT and assigned to "DINT_SUM".


us

Attention
For data type conversions into a data type with a smaller value range – in the example the
r

conversion of the value of the variable "REAL_Value3" from REAL to INT – is in this respect
bo

risky, in that an overflow leads to an invalid conversion result. Accordingly, the result of the
integer addition would then also be invalid. This kind of error can be discovered by evaluating
the ENO.
@

Note
If you monitor such a risky data type conversion online, then you can see by way of color
sa

whether the current conversion of data occurs without error or not.


Red indicates that the data type conversion in the current cycle is faulty, and green indicates
m

that the conversion is error-free.


sa
ry

7-23 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
7.13 Task Description: Calculating and Displaying the Statistical
Task Description:
ValuesCalculating and Displaying the Statistical Values

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task Description: Statistical Values


ry

All transported parts are counted when they reach a free bay. Both the number of parts of the
individual bays and the total number of parts are recorded. In addition, the utilization of the bays
is determined, that is, which percentage of parts transported to each Bay is calculated.
All statistical values are displayed on the touch panel screen “statistic".
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

7-24 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
7.13.1 Exercise 4: Creating the PLC data Type "type_statistics" and expanding
Exercise 4: Creating the PLC data type "type_statistics" and expanding
"DB_OP"
“DB_OP"

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

Task
The values to be calculated are to be stored in the data block "DB_OP" in order to transfer them
to the touch panel. Since the values have to be calculated in the next exercise and have to be
transferred to the data block using block parameters, the structure of the data is used several
times. For that reason it makes sense to create the structure once in a PLC data type in order to
be able to use it repeatedly.

What to Do
1. In the project navigation create a PLC data type with the name "type_Statistics" that has the
following structure
om

: Name Data Type


Number per Bay: QuantBay ARRAY[1..3] of UINT
c

Sum of all numbers: totalQuant UINT


n.

Utilization per Bay: UtilizBay ARRAY[1..3] of REAL


sa

2. For "typeStatistics", activate the property "Published"


3. In data block "DB_OP", create a new variable with the name "statistics" of the data type
ru

"type_Statistics".
4. Save, compile, and download your program.
bo
@
sa
m
sa
ry

7-25 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
7.13.2 Exercise 5: FB "BaysStatistic": Calculating the Statistical Data of the
Exercise 5: “FB_Statistic": calculating the statistical data of the transported
Transported Parts
parts

.c
an
"FB_Statistic"

Initialize utilization of Bay 1, 2, 3

s
with pos. edge of #Operation

ru
Record quantities Bay 1, 2, 3 with IEC counters
and reset with pos. edge of #Operation

bo
Calculate total quantity
Yes Total quantity <= 0 No
Calculate utilization Bay 1, 2 and 3

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Calculating the Statistical Data "FB_Statistic"


ry

When the operation is switched on ("P_Operation" = TRUE), the transported parts are counted
for each bay. The total quantity and the number of parts of the individual bays as well as their
utilization in percent are stored in the data block "DB_OP" in order to then be able to pass these
to the touch panel. All values mentioned are initialized or overwritten with 0 with every switch-on
("P_Operation" positive edge).

What to Do
1. Insert the new block "FB_Statistic" and provide it with the following parameters:
m
INPUT: Operation Bool
Occupied STRUCT
co

Bay1 Bool
Bay2 Bool
n.

Bay3 Bool
INOUT: Statistic type_statistics
sa

Note
ru

The parameter "Statistic" can also be declared as an OUTPUT parameter since the calculated
values are passed to the calling block. An INOUT parameter of the type complex data type has
the advantage, however, that it doesn’t occupy any memory in the instance data block.
bo

Furthermore, the parameters can be read-accessed within the block without warning, which will
be necessary for the calculation.
@
sa

Continued on the next page


m
sa
ry

7-26 SITRAIN
SIMATIC Programming 2 in the TIA Portal

2. Scan the IN-Parameter #Operation for a positive edge. Use this positive edge to initialize
the utilization values of all Bays (#Statistic.UtilizBay[1] / [2] / [3]). To accomplish this, use

om
the positive edge evaluation result to writ to a temporary variable (#temp_OnEdge).
3. For each Bay, program the counting of the arrived parts. For this, use IEC counters with
different instance data blocks (iDB_IEC_Counter_1, 2, and 3) as instances. The count

.c
occurs when the relevant bay becomes occupied. To reset the counters, the temporary
variable #temp_OnEdge is used. Pass the values to the parameters #Statistic.QuantBay[1],

an
[2], and [3].
4. Calculate the total quantity (#Statistic.TotalQuant) with the help of the individual quantities.

s
5. Check the total quantity for less than or equal to zero. Since division by zero goes to infinity,

ru
end the block with the instruction "RETURN", when this is the case.
6. For each bay calculate the current utilization, proportional to the total quantity.

bo
7. In "OB_Cycle", call the "FB_Statistic" block and supply the parameters as shown in the
picture.
@
8. Compile, save, download and check the functioning.
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m
sa
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

7-27 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 6: Creating the HMI Tag “DB_OP_statistics"

om
7.13.3 Exercise 6: Creating the HMI Tag DB_OP_statistics

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task:
Since the calculated values are passed to the Panel as structure, an HMI tag for passing the
ry

calculated values is created.

What to Do
1. Open the HMI tag table in which the HMI tag is to be created.
2. Display the Details view in the project tree.
3. Select the data block "DB_OP".
4. Using drag & drop, drag the variable "Statistics" from the Details view into the HMI tag table.
om
5. Save your project.

Result
c

An HMI tag "DB_OP_Statistics" of the data type "type_statistics" is created.


n.

Caution
a

Array elements of HMI tags always begin with the Index 0, regardless with which Index the
us

elements of the PLC tags begin.


r
bo
@
sa
m
sa
ry

7-28 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 7: Displaying the statistical values on the touch panel
7.13.4 Exercise 7: Displaying the statistical Values on the touch panel

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
ry

The calculated values are to be visualized in the the screen “statistic”.

What to Do
1. Split the working area vertically and open the screen “statistic” on one side and the HMI
tags of the “DB_OP_statistics” on the other.
2. Copy the tags using drag & drop from the tag table to the desired place on the screen.
3. Connect the output field “current weight” with the tag “DB_Conveyor_weight”.
4. Change the type of the new field to “output”.
5. Drop the tag “DB_OP_statistics.totalquant” in the screen “conveyor” and change the mode
om
to “output”.
6. Load the data of the project to the CPU and the touch panel.
.c

7. Save your project.


an
r us
bo
@
sa
m
sa
ry

7-29 SITRAIN
SIMATIC Programming 2 in the TIA Portal

7.14 Appendix

om
Polyline
7.14.1 Polyline

.c
an
7
x1

6
5

s
4
Output=3.5

ru
3
2
1

bo
0
0 1 2 3 4 5 6 7
Input=5.5

@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m
sa

The instruction Polyline maps the input value Input to the output value Output via a
ry

characteristic curve. The curve is defined as a polygon curve with a maximum 50 interpolation
points. Between the interpolation points is linearly interpolated. Through the number and the
configuration of the interpolation points, you can adjust the polygon curve to the desired
characteristic curve.

Polygon Curve Data


m
The value pairs for the polygon curve are contained in the Static area of the instruction.
In order to be able to change the polygon curve data without the changes taking effect
co

immediately, the value pairs of the polygon curve are duplicated and included in the following
structures:
n.

UserData
The polygon curve data in this structure can be edited.
sa

Use this structure to define or to change the polygon curve data. Changes in this structure only
have an impact on the interpolation calculation when the verification and the copying of data in
ru

the structure WorkingData is triggered. This is done by setting the Validate = TRUE or
automatically during the first processing of Polyline after the CPU operating status change from
bo

STOP to RUN.
Pre-assigning the values in this structure does not represent a valid configuration. To use the
values for the interpolation calculation, change the variables to valid values.
@

WorkingData
The polygon curve data in this structure cannot be edited. This data is used for the interpolation
calculation. Do not manually change the data in this structure.
sa

Note
m

The minimum number of value pairs to be configured is 2, the maximum number 50, and for a
valid configuration, the x-values must be specified in ascending order.
sa
ry

7-30 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Scaling Analog Input Values with SCALE
7.14.2 Scaling Analog Input Values with SCALE

.c
s an
ru
BIPOLAR := false BIPOLAR := true

bo
(Sensor supplies only (Sensor also supplies
positive voltages) negative voltage)

OUT OUT
HI_LIM = 500.0

@ HI_LIM = 500.0

Δ
sa
A B
Δ
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

LO_LIM = 0.0 LO_LIM = 0.0


sa

IN IN
0 x x+1 0 x x+1
27648 -27648 27648
ry

fixed, not parameter-assignable! fixed, not parameter-assignable!

With the instruction "Scale", you convert the integer at parameter IN from a raw value (in the
range of 0 to +27648, or -27648 to +27648) into the physical unit as floating-point number
between a given lower and upper limit.

Examples
The level of a 500 liter tank is to be measured in liters.
Example A shows the scaling when a sensor is used that supplies a measured voltage of 0V
m
when the tank is empty and a measured voltage of +10V when the tank is full. Example B
shows the scaling when a sensor is used that supplies a measured voltage of -10V when the
co

tank is empty and a measured voltage of +10V when the tank is full.
n.

Resolution
In example B, the level is measured with twice the resolution or with twice the measuring
sa

tolerance Δ, since the volume of the tank is scaled to the greater unit range of -27648 to
+27648.
ru

The instruction SCALE (FC105) is used for scaling the analog value:
bo

IN: The analog value at input IN can be read in from the module directly or can be passed from
a data interface in INT format.
LO_LIM, HI_LIM: Inputs LO_LIM (low limit) and HI_LIM (high limit) are used for specifying the
@

limits of the basic physical quantity.


OUT: scaled value (physical quantity) as Real number (LO_LIM <= OUT <= HI_LIM).
sa

BIPOLAR: 'FALSE' (unipolar), scaling for the range 0 to 27648,


'TRUE' (bipolar), scaling for the range -27648 ... +27648.
m

RET_VAL: The output RET_VAL supplies the value 0 when execution is error-free.
sa
ry

7-31 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Unscaling Analog Output Values with UNSCALE
Unscaling Analog Output Values with UNSCALE

om
BIPOLAR := true
B (Actuator is energized with positive

.c
and negative values)

OUT

an
27648

s
ru
OUT

bo
A 27648 0
IN
0.0 500.0
(LO_LIM) (HI_LIM)
BIPOLAR := false @
(Actuator is only energized
with positive values)
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

0
IN
0.0 500.0
(LO_LIM) (HI_LIM) -27648
m

With the instruction "Unscale", you descale the floating-point number at parameter IN into
sa

physical units between a lower and an upper limit and convert it into an integer.

Examples
ry

An analog value in the range 0.0 to 100.0% that is calculated by the user program is converted
(unscaled) with the instruction UNSCALE (FC106) to the range 0 to +27648 (unipolar) or -27648
to +27648 (bipolar). When the unscaled value is output to an analog output module, this module
will energize the analog actuator (such as a servo valve) with a value such as 0V to +10V
(unipolar) or -10V to +10V (bipolar).
Example A shows the scaling when an actuator is used that is to be energized with the value 0
om
(0V or 0mA) when the program value is 0% and is to be energized with maximum value (such
as +10V or 20mA) when the program value is 100%.
Example B shows the scaling when an actuator is used that is to be energized with minimum
c

value (such as -10V or -20mA) when the program value is 0% and is to be energized with
n.

maximum value (such as +10V or 20mA) when the program value is 100%.
• IN The value calculated by the program must be passed in the REAL format.
a

• LO_LIM, HI_LIM Inputs LO_LIM (low limit) and HI_LIM (high limit) specify the limits for
us

the program value. In the example, this is the range 0.0% to 100.0%.
• OUT The unscaled value is output in the INT format at the output OUT.
r

• BIPOLAR At input BIPOLAR you can specify (parameterize) whether only positive or also
bo

negative values are to be converted. If an operand with the state 'FALSE' (unipolar) is
passed to the parameter, unscaling is made for the range 0 to +27648. If the operand state
is 'TRUE' (bipolar), unscaling is made for the range -27648 to +27648.
@

• RET_VAL The output RET_VAL supplies the value 0 when execution is error-free.
sa
m
sa
ry

7-32 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
8 Functions, Function Blocks and Multiple
Instances

.c
an
8.1LearningLearning
objectives objectives

s
ru
• You have an overview of global and local operands

bo
• You know the properties of functions and function blocks

• You know the properties of block parameters and are able to apply them

@
• You understand the term "re-usability" and are able to implement it

• You know the concept of multiple instances and are able to use them
sa
• You can program re-usable blocks
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

om
.c
an
r us
bo
@
sa
m
sa
ry

8-1 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Task
8.2Description:
TaskProgramming Re-usable
Description: Blocks
Programming Re-usable Blocks

.c
s an
ru
bo
Properties

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task Description
ry

According to the IEC61131-3 standard, global operands must not be used within FCs and FBs,
that is, no inputs, outputs, memory bits, data block variables, SIMATIC timers / counters. Only
local operatnsa are allowed. That is, only parameters and local variables (tags).
The communication of the block with its "outside world" occurs exclusively through the interface
of the block or only through the input, output, and in/out parameters. This also means that the
block works with no other operands than with those which are passed as formal operands
during the block call.
This ensures that a block is "re-usable", that is, can also be integrated in other programs
unchanged.
m
Note
co

In the current project, several blocks contain variables of the type ARRAY which use global
constants for the Array limits. As a result, although there is no library conformity for these
n.

blocks, re-usability is possible within the program.


In order to achieve library conformity with these blocks, all global constants must be replaced
sa

with local constants.


The objective of this chapter is to program the blocks as re-usable. Library conformity is not
ru

required for all blocks.


bo
@
sa
m
sa
ry

8-2 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Local and Global Operands
8.3 Local and Global Operands

.c
Global Operands Local Operands
(valid in the entire program) (only valid in one block)

an
Formal Parameters (Input, Output, InOut, Return value of the FC)

• Process image for • interface for data exchange between calling and called block

s
inputs and outputs • temporary storage in the L-stack for FCs or storage in the IDB for FBs
• can be used in FCs / FBs

ru
• I / O peripherals

bo
Temporary Variables (Temp)
• are overwritten after the block is executed
• Memory bits • temporary storage in the local data stack (L-stack)
• can be used in OBs / FCs / FBs


Variables in global DBs

S5-Timers and Counters


@
Static Variables (Static)
• retain their value after the block is executed
• permanent storage in instance data block (IDB)
sa
(not for S7-1200)
• can only be declared in FBs
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Constants (Constant)
m

• Global constants • read-only as well as only symbolic access


• no memory usage
sa

• can be used in OBs / FCs / FBs


ry

Global Operands
Global operands are valid throughout the entire S7 program. Accordingly, every code (logic)
block (OB, FC, FB) can access these operands.
Global operands include inputs, outputs, memory bits, SIMATIC timers, SIMATIC counters,
constants, and variables declared in tag tables which are declared in global data blocks.

Local Operands
Local operands are only valid in the block in which they were declared in the declaration part.
Accordingly, only this block can access them.
om
• Formal Parameters
Formal parameters form the interface between the calling and the called block (FC, FB).
They are used to realize a data exchange between the calling and the called block.
c


n.

Temporary Variables
Temporary variables can be declared in every code (logic) block (OB, FC, FB) and are
sa

managed in the local data stack of the CPU. Accordingly, they only retain their values while
the block is being executed. It is important that in the current cycle, a write access must
have taken place on the temporary variable before a read access can take place. They are,
ru

for this reason, unsuitable as auxiliary variables for edge evaluations or to store quantities.
They are well suited to store intermediate results, such as for complex calculations or format
bo

conversions.
• Static Variables
Static variables can only be declared in FBs and are stored in the associated instance data
@

block. Accordingly, these variables retain their value even after the FB is executed.
• Constants
sa

• Constants are fixed values which have a read-only access and which do not take up any
memory space. A local constant can only be used in the block in which it was declared.
m
sa
ry

8-3 SITRAIN
SIMATIC Programming 2 in the TIA Portal

Structured Programming
Structuredand Re-usable Blocks

om
8.4 Programming and Re-usable Blocks

.c
"InstMotor" "InstController" "InstTON"
Modularization of the entire task:

an
• Partial tasks are solved in separate programs or blocks "Motor" "Control" "TON"

• Parameter assignment enables flexible usage "CyclicA"

− Example: Drilling cycle with changeable depth "InstValves"

s
ru
"Valves" "Limit" "BLKMOV"

bo
Re-usability of blocks:
"CyclicB" "InstMotor"
• Blocks can be called as often as is required "Motor"
• Restrictions:
@
− No access to global operands or global constants
"InstMotor"
"Motor"

Start MotorOn
Decl.
in
in
out
Name
Start
Stop
MotorOn
Type
BOOL
BOOL
BOOL
out Speed INT
− Communication only via the parameter list
sa
Stop Speed stat SpeedOld INT
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

temp Calc1 INT


:
:
m
sa

Modularization of the Entire Task


Abstraction is the basis for solving complex problems, in which we concentrate on the
ry

fundamental aspects of a program in every abstraction level and ignore all the details that are
not essential. Abstraction helps us to divide complex tasks into partial tasks which can then be
solved on their own.

Parameter-assignable (Re-usable) Blocks


STEP 7 supports this concept of modularization with its block model. The partial tasks that
result from the division of the entire task are assigned to blocks in which the necessary
algorithms and data for solving the partial problems are stored. STEP 7 blocks such as
om
functions (FC) and function blocks (FB) can be assigned parameters so that the concepts of
structured programming can be implemented with them. This means:
• Blocks for solving partial tasks implement their own data management with the help of local
c

variables.
n.

• Blocks communicate with the "outside world", that is, with the sensors and actuators of the
process control or with other blocks, exclusively through their block parameters. No access
a

to global operands such as inputs, outputs, memory bits, or variables in DBs can be made
us

from within the statement section of blocks.

Advantages
r
bo

• The blocks for the partial tasks can be created and tested independent of one another.
• With the help of parameters, blocks can be designed so that they are flexible. That way, for
example, a drilling cycle can be created that has the coordinates and the depth of the
@

drilling hole passed on to it by means of parameters.


• Blocks can be called as often as is required in different locations with different parameter
sets, that is, they can be reused.
sa

• "Re-usable" blocks for special tasks can be delivered in pre-designed libraries.


m
sa
ry

8-4 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Block Properties: Compilation
8.4.1 Block Properties: Compilation

om
.c
an
s
ru
bo
Re-usable and
library conformant
@
Can be called several times
in the current program
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Cannot
nicht be re-used
Wiederverwendbar
m

In the Properties of FCs and FBs, you can check whether the block was programmed as re-
sa

usable.
ry

Object is Library-conformant
The block is re-usable and so can be called several times without a problem. It can also be used
in other projects/devices without adjustments and can be implemented with the help of libraries.

Warning
The use of the block in other devices or projects can lead to problems or requires adjustments
m
in the new project or in the block itself. Calling the block several times in the same program may
not be possible.
co
n.
sa
ru
bo
@
sa
m
sa
ry

8-5 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Properties
8.5 ofProperties
Functions of Functions

om
Parameter-assignable blocks:

.c
• As many input, output, and Function "Cal_1"
in/out parameters as required

an
in On1 BOOL
• Without memory, that is, only in On2 BOOL
temporary variables out OK BOOL

s
• Constants temp …
Program

ru
const …
execution
Return Cal_1 INT

bo
IEC 61131-3-conforming: Cal_1 ...
• As many input parameters as required %I 0.0 On1 RET_VAL %QW10
• Only one output parameter, RET_VAL %I 0.1 On2

• No access to global variables, global


@ OK %Q8.4 &
#On1 IN2 OUT #Cal_1
constants, or absolute operands #On2 IN1
• Deliver the identical result for the ENO #OK
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

same input parameters ...


sa
m

Overview
sa

Functions represent parameter-assignable blocks without memory. In STEP 7 they can have as
many input parameters, output parameters, and in/out parameters as are required. Additionally,
ry

constants that are local in the block can be created for S7-1200/1500.
Functions have no memory; no separate, permanent data area for storing results exists.
Temporary results that occur during function execution can only be stored in the temporary
variables of the respective local data stack. m
Application
Functions are primarily used when function values are to be returned to the calling blocks (for
co
example, mathematical functions, single control with binary logic operation).
Caution: Output parameters of functions must be written in the program execution for every
n.

call of the function.


sa

IEC-61131-Conforming Functions
If IEC 61131-3-conforming functions are to be created, then the following rules must be
ru

observed:
• Functions can have as many input parameters as is required. They can, however, only
bo

return one result to the output parameter RET_VAL.


• Global operands can neither be read nor written within functions.
• No instances of function blocks can be called within functions.
@

• Because of the missing "memory", the returned result of a norm-conforming function is


solely dependent on the values of the input parameter. For identical values of the input
parameter, a function always returns the identical result.
sa
m
sa
ry

8-6 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
8.5.1
Properties ofProperties of Function Blocks
Function Blocks

.c
iDB
Parameter-assignable blocks: "InstDrive"

an
• IEC 61131-3-conforming 0.0 Start BOOL
0.1 Stop BOOL
• As many input, output, and
FB 2.0 MotorON BOOL
in/out parameters as required

s
4.0 Speed INT
• With memory, that is, not only Program
"Drive" 6.0 statON BOOL

ru
temporary but also static variables execution in Start BOOL
• Constants in Stop BOOL

bo
• Call with own data area "InstDrive" out MotorON BOOL
"Drive" out Speed INT
(instantiating)
%I 0.0 Start MotorON %Q8.0 stat statON BOOL
• "Data encapsulation" %I 0.1 Stop Speed %QW6

Application:
• Timer and counter functions
@ temp
const
...

#statON
sa
• Controlling process units with SR
internal states #Start S
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

#Stop R
− boilers
m

OUT #MotorON

− drives, valves, etc.


sa
ry

Overview
Function blocks (FB) are blocks of the user program and represent code blocks with memory
according to the IEC Standard 61131-3. They can be called by OBs, FBs, and FCs.
In function blocks, as many input, output, and in/out parameters, static and temporary variables,
and constants as are required can be declared in the local memory.
Unlike FCs, FBs are instantiated, that is, an FB is assigned its own private data area in which
the FB can "remember" process states from call to call. In the simplest form, this private data
area is its own DB, the so-called instance DB.

"Memory"
m
The programming person has the opportunity to declare static variables in the declaration
co

section of a function block. The function block can "remember" information from call to call in
these variables.
n.

The ability of a function block to "remember" information over several calls is the essential
difference to functions.
sa

Application
With the help of this "memory", a function block can implement counter and timer functions or
ru

control process units, such as processing stations, drives, boilers, etc.


bo

In particular, function blocks are well suited for controlling all those process units whose
performance depends not only on outside influences but also on internal states, such as
processing step, speed, temperature, etc.
@

When controlling such units, the internal status data of the process unit is then copied to the
static variables of the function block.
sa
m
sa
ry

8-7 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Parameter Properties: Predefining Visibility and Actual Parameters (1)
8.5.2 Parameter Properties: Predefining Visibility and Actual Parameters (1)

.c
s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

Visibility in block Calls in LAD/FBD


When a block is called, the block parameters can be hidden. Here, there are several
possibilities: ‘Show’, ‘Hide’, or ‘Hide if no parameter is assigned’.
In a block call, hidden parameters can be indicated through a small icon in the form of a triangle
(see next page).

Predefined Actual Parameter


If it is already clear during block creation with which actual parameter the formal parameter is to
be supplied, then you can store this information as a property of the parameter. When the block
is called, this parameter is then automatically supplied with the actual parameter. However, it
can be changed at any time.
In addition, you can also store the property “Show if parameter assigned on block call is not
m
identical to the predefined actual parameter” for the parameter (only to be displayed when the
actual parameter does not match the predefined actual parameter).
co
n.
sa
ru
bo
@
sa
m
sa
ry

8-8 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Parameter Properties: Predefining Visibility and Actual Parameters (2)
Parameter Properties: Predefining Visibility and Actual Parameters (2)

om
1 2

.c
s an
ru
4 3

bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

• In the example you can see that the formal parameters "sensor_1" and "sensor_2" have the
sa

property “Hide”. For that reason, they are not displayed during the call Picture (1).
• In addition, the formal parameter "sensor_1" was preassigned with the actual parameter
"Bay1" [Picture (2)] and given the property “Show if parameter assigned on block call is not
ry

identical to the predefined actual parameter”.


• Since the actual parameter of "sensor_1" is changed in Picture (3) vis-à-vis Picture (2), it is
no longer hidden in Picture (4).
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

8-9 SITRAIN
SIMATIC Programming 2 in the TIA Portal

Instance
8.6 Formation of Function
Instance Blocksof
Formation Function Blocks

om
OB, FB, or FC FBx "instance" Single instance (DB),

.c
Instance in Global DB,
Algorithm Count or Parameter instance
CALL FBx, "instance"

an
for + values for
counting Bay 1
Instance FBy

s
Multiple instances

ru
FBy
Bay_1_count
stat Bay_1_count FBx

bo
OB, FB, or FC
stat Bay_2_count FBx
stat Bay_3_count FBx
CALL FBy, "instance"
@ Bay_2_count
CALL #Bay_1_count
CALL #Bay_2_count
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

CALL #Bay_3_count
sa

Bay_3_count
m

What is an Instance?
sa

The concept of the instantiation of function blocks has importance and forms the fundamental
difference to functions. The creation of tags within a high-level language, such as "C", specifying
the tag name and the data type is called "instantiation" or "instance formation".
ry

Just like tags, function blocks are also "instantiated". Only through the assignment of its own
data area in which the values of the block parameter as well as the static variables are stored
does a function block become an executable unit (FB instance).
The control of a physical process unit, such as a drive or a boiler, then takes place with the help
of an FB instance, that is, a function block with associated data area. The relevant data for this
m
process unit is then stored in this data area.
Instance Formation
co

The assignment of its own memory area during an FB call can occur in several ways in STEP 7:

n.

by explicitly specifying a so-called instance data block.


– by explicitly declaring instances of an IEC function within a global data block
sa

– by explicitly declaring an instance parameter which is assigned the actual instance


during the call of the higher-level block
ru

– by explicitly declaring instances of a function block within a higher-level function block


(multiple instance model).
bo

Advantages
• In the call of FBs, no measures for saving and administrating local data are necessary
@

except for the assignment of instance DBs.


• A function block can be used several times due to the instance concept. If, for example,
several drives of the same type are to be controlled, the same FB is called once for each
sa

drive, with separate instances for each call. The status data of the individual drives is stored
in the static variables of the FB.
m
sa
ry

8-10 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Creating Instances of IEC-Functions in a global Data Block
8.6.1 Creating Instances of IEC-Functions in a Global Data Block

om
.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Application
With this, the instance data of IEC counters and timers that are used can be gathered in a
ry

global data block (see picture).


However, it must be noted that the calling Block (in the example "FC_Counter") is not IEC-
conforming and cannot be re-used since the access to the IEC counter instances represents the
use of global operands. om
c
a n.
r us
bo
@
sa
m
sa
ry

8-11 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Passing an Instance as a Parameter
8.6.2 Passing an Instance as a Parameter

.c
s an
ru
bo
@
sa
Single instance,
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Instance in Global DB,


Multiple instance,
sa

or Parameter instance
ry

The passing of an instance by means of an IN-OUT parameter offers a further possibility of


instantiation. This has the advantage that the actual instance which is required within a block is
specified during the block call. This way you have the opportunity to program blocks as re-
usable when they utilize function blocks or instatiated instructions.

Supplying the formal Parameter


In turn, you can specify an instance data block, a DB-variable, a multiple instance, or a
parameter instance of the type IEC-Function as the actual parameter.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

8-12 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Task Description: Programming Re-usable Blocks
8.7 Task Description: Programming Re-usable Blocks

.c
s an
ru
bo
Properties

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task Description
ry

According to the IEC61131-3 standard, global operands must not be used within FCs and FBs,
that is, no inputs, outputs, memory bits, data block variables, or SIMATIC timers / counters.
Allowed are only local operands, that is, only parameters and local variables (tags).
The communication of the block with its "outside world" occurs exclusively through the interface
of the block or only through the input, output, and in/out parameters. This also means that the
block works with no other operands than with those that are passed as formal operands during
the block call.
This ensures that a block is "re-usable", that is, can also be integrated in other programs
unchanged.
om
.c
an
r us
bo
@
sa
m
sa
ry

8-13 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 1: FC "Fault": Using a Global-DB Variable for the IEC-Timer-Instance

om
8.7.1 Exercise 1: FC "Fault": Using a Global-DB Variable for the IEC-Timer-Instance

.c
s an
ru
Horizontally
split editor area

bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
Using drag & drop, you are to replace the separate single instance in "FC_Fault" with an
ry

instance which was previously declared in the global "DB_Conveyor".


Note:
With this change, the block is not yet re-usable. This will be realized in the next exercise.

What to Do:
1. In "DB_Conveyor", create the variable "instance_IECTimer" shown in the picture.
2. Horizontally split the editor area (see picture) so that the two blocks "DB_Conveyor" and
m
"FC_Fault" are displayed simultaneously.
3. In "FC_Fault", using drag & drop, replace the separate single instance-DB with the Global-
co

DB-Instance which you previously declared in "DB_Conveyor".


4. Transfer all modified blocks into the CPU and test the program.
n.

5. Save your project.


sa
ru
bo
@
sa
m
sa
ry

8-14 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 2: Using a Parameter Instance for FC "Fault" and FC "Signal"
Exercise 2: Using a Parameter Instance for FC "Fault" and FC “Signal"

om
8.7.2

.c
an
s
Change single instance into

ru
a parameter instance

bo
Update FC call

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
In "FC_Fault", you are to replace the global DB Instance with a Parameter instance which then
ry

is once again assigned with the global DB-Instance during the call of "FC_Fault".
Realize an automatic parameter assignment of the parameter instance by setting the Properties
of the parameter.
Note:
With this change, the block is re-usable.

What to Do:
m
1. Open the "FC_Fault" block.
2. Through the context menu of the ON-Delay, open the "Call options" function via the
co

"Change instance…" function.


3. Change the single instance into a parameter instance with the name "instance_IECTimer".
n.

4. Select the parameter instance in the interface of the block and open the Properties in the
Inspector window.
sa

5. As predefined "Actual Parameter", specify the variable "DB_Conveyor".instance_IECTimer.


ru

6. Update the call of the function in "OB_Cycle".


Note: The new parameter is automatically linked to the variable
bo

"DB_Conveyor".instance_IECTimer.
7. Transfer all modified blocks into the CPU and test the program.
8. Save your project.
@
sa
m
sa
ry

8-15 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Structure of the Multiple Instance Model
8.8 Structure of the Multiple Instance Model

om
.c
FBx FBy
...
OB, FB, or FC Algorithms "Instance-x"

an
stat Drill FBy
for drilling Data for
stat Motor_1 FBz Drill

s
stat Motor_2 FBz

ru
.
CALL FBx, CALL Drill

bo
"instance-x" .
Data
CALL Motor_1 FBz
.
for
. Control of Motor_1
@
CALL Motor_2 a motor

Data
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

for
Single instance (DB) Motor_2
m

Instance in Global–DB
Parameter instance Instance of FBx
sa

Multiple instance also possible


ry

Multiple Instance Model


In addition to instantiation of function blocks when you specify an instance DB in an FB call,
STEP 7 also supports the explicit declaration of FB instances within a higher-level function
block. For this purpose, instances of the called function blocks are declared with data type FBy
or FBz using symbolic identifiers (Drill, Motor_1 and Motor_2). This takes place in the
declaration section of the calling function block, FBx, in the section "static variable". Within the
m
higher-level function block, the individual instances are then called using their symbolic
identifier. The higher-level FBx function block must, however, be called with its own instance DB
co

("instance-x").
In the creation of the higher-level instance DB, STEP 7 makes sure that the data areas required
for the individual instances are set up in the data area of the higher-level FBx.
n.

Advantages
sa

The use of the multiple instance model has the following advantages:

ru

The individual instances do not require their own data block every time. Within a call
hierarchy of function blocks, only one instance DB is used in the call of the "outer" function
block.
bo

• The multiple instance model "welds" a function block and an instance data area into one
object (FB instance), that can also be handled as one unit. The programming person does
not have to take care of the management (creation, addressing) of the individual instance
@

data areas. He must simply provide an instance DB for the "outer" FB.
• The multiple instance model supports an object-oriented programming style.
sa
m
sa
ry

8-16 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Changing the Block Call
8.8.1 Changing the Block Call

om
.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

In order to replace the call of a block with another block call, you can open a selection list of all
FCs and FBs at the calling point by double-clicking on the name of the already called block.
ry

Advantage
If the newly called block has the same formal parameters, they retain their actual parameters
and don’t have to be resupplied.

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

8-17 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise
8.9 3: Programming
Exercise 3:FBs "BaysStatistic",
Programming "Conveyor," and
FB_Statistic as "LifeBitControl"
re-usable as
Re-usable

.c
s an
ru
Change to Multi-Instance

bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
ry

In "FB_Statistic", the counting of the parts transported to Bay 1, 2 or, 3 is implemented with IEC
counters whose data is stored in individual instances.
As previously with the "FC_Fault" block, "FB_Statistic" is now also to be modified in such a way
that it fulfills the requirements of IEC 61131-3, making it "re-usable".
For this, the instances used so far in the program, which were used to store the instance data of
the IEC-COUNTER, must be replaced with multiple instances.

What to Do
1. Open "FB_Statistic", right-click on the first IEC-Counter and select the function "Change
m
instance…" (see picture).
co

2. In the dialog that appears, select "Multi-Instance" and give it the name
instance_IECCounter_1.
n.

3. Repeat this with the two other IEC-Counters and give them the names
instance_IECCounter_2 and instance_IECCounter_3
sa

4. After you have changed all instances into multi-instances, compile the entire S7 program,
so that the call of "FB_Statistic" in "OB_Cycle" and the instance-DB passed there to the FB
are thereby also updated.
ru

5. Delete the old instance-DBs of the IEC-Counters since they are now no longer required.
bo

6. Download the entire S7 program into the CPU and check all program functions.
7. Save your project.
@
sa
m
sa
ry

8-18 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
ExerciseExercise
8.9.1 4: Programming "FB_Signal"
4: Programming as Library-conformant
"FB_Signal" as Re-usable

.c
s an
1

ru
bo
3

@ 2
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Task
Up until now, "FC_Signal" has been responsible for energizing the indicator lights.
ry

The new "FB_Signal" block is to replace the previous "FC_Signal" and is to be created in such a
way that it fulfills the requirements of IEC61131-3, making it "re-usable".

What to Do
1. Create a new "FB_Signal" block and open it.
2. Split the working area and open the "FC_Signal" block in the second half.
3. Copy all parameters and local variables from the interface of "FC_Signal" into the interface
of "FB_Signal".
4. Copy all networks from the "FC_Signal" block into the "FB_Signal" block.
5. Change the instance of the "LGF_Frequency" function block to a multiple instance.
m
6. Save your project.
co
n.
sa
ru
bo
@
sa
m
sa
ry

8-19 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 5:
8.9.2 Replacing
Exercise the call of "FC_Signal"
5: Replacing with "FB_Signal"
the Call of "FC_Signal" with "FB_Signal"

.c
s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Task
The call of the "FC_Signal" block is to be replaced with the call of the "FB_Signal" block.
ry

What to Do
1. Open "OB_Cycle" and go to the call of "FC_Signal".
2. Open the selection menu of the blocks by double-clicking on the name "FC_Signal".
3. Select the "FB_Signal" block.
4. Open the context menu of the block call and choose the function "Create instance…".
5. In the follow-up window, give the single instance the name "iDB_FB_Signal"
6. As backup, you can copy "FC_Signal" into your project library and then delete it since it is
no longer required.
m
7. Save, compile, download, and test your project.
co
n.
sa
ru
bo
@
sa
m
sa
ry

8-20 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
8.10 Appendix
Local, Temporary Variables
8.10.1 Local, Temporary Variables

.c
s an
ru
1. Declaration

bo
@
sa
2. Assignment
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

3. Scan
ry

Declaration
The variables are also defined in the declaration part of the block. The name of the variable and
the data type must be specified.

Access
With optimized blocks, all temporary variables are initialized with 0 at the beginning of block
execution.
m
With non-optimized blocks, all temporary variables have an undefined value at the beginning of
block execution. When working with temporary variables, you must therefore make sure that the
co

variable is first of all assigned a defined value before it is scanned.


In the example, the result of the Addition is assigned to the temporary variable #inRes before it
n.

is then scanned during the Multiplication.


sa

Note
Variables that begin with the # special character are local variables (parameters or local
variables) that must be declared in the declaration part of the block. Local variables are only
ru

valid and usable in the block in which they were declared.


bo

The Program Editor automatically inserts the # character.


@
sa
m
sa
ry

8-21 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Local Data Stack
Local Data Stack

om
Operating system

.c
1

an
OB 1 FC 17 3 FC 20
2 Event 1 2 3 4 5 6 7

s
with temp. 4 with temp.
variables variables

ru
Usage of
the Local FC20 FC30
5
FC 30

bo
data stack
7 FC17 FC17 FC17 FC17 FC17
6 with temp.
OB 1 OB 1 OB 1 OB 1 OB 1 OB 1 OB 1
variables
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m
sa

Total Usage of the Local Data Stack (L-Stack)


ry

For every program execution level or priority class (such as OB1 with all blocks that are called in
it), a separate local data stack is reserved. That is, a segment of defined size is reserved on the
L stack of the CPU (allocation or reservation of memory space).
The local variables of OB1 as well as the local, temporary variables of the blocks (FCs and FBs)
called in or by OB1 are stored in this local data stack.
m
The display of the "Call structure" shows to what extent an S7 program puts a burden on the
local data stack (Menu "Tools" > "Call structure").
co
n.
sa
ru
bo
@
sa
m
sa
ry

8-22 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
9 Complex Data and Addressing

.c
an
9.1LearningLearning
objectives objectives

s
• You can use complex data types and are able to explain them

ru
• You can declare variables of complex data types and are able to use them

bo
• You know various direct and indirect accesses to complex variables and
are able to use them

@
• You know PLCSIM and are able to apply it

• You know how to simulate an HMI device


sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

c om
n.
sa
ru
bo
@
sa
m
sa
ry

9-1 SITRAIN
SIMATIC Programming 2 in the TIA Portal

9.2 Task Description: Managing Weight Values in Weight Store and

om
Task Description: Managing
Displaying Weight Values
Statistical in Weight Store and Displaying
Values
Statistical Values

.c
s an
ru
bo
@
346
237
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

144
sa

#tempAutoLeftStop
m

Program Function Up Until Now


sa

When "P_Operation" (Q0.1) is switched on, parts are placed on the conveyor at the light barrier
bay, weighed (weight simulation via "S_Slider1" (IW10) on the simulator) and, after pressing the
ry

bay pushbutton, are transported to the next free Bay 1, 2, or 3. When a part reaches the bay,
the indicator light signals with a flashing light that the part can be removed. After that, it has a
continuous light indicating that the bay is still occupied. The bay may be cleared using the
associated bay pushbutton, whereupon the bay indicator light goes dark.
The transported parts are counted for each bay and the statistical data are calculated. Both
total quantity and the utilization of the 3 bays are determined. After a part has reached a bay,
m
the bay can immediately be enabled again by pressing the associated bay pushbutton, so that
any number of parts can be transported to every bay. Only when "P_Operation" (Q0.1) is
co

switched off and switched on again are the IEC counters used for counting as well as the
statistic values reset to ‘0’.
n.

Expanding the Program


sa

The program is now to be expanded so that the weights of the transported parts are saved. For
this, a weight storage (WeightStore) is created in which the (simulated) weight of the
transported part is saved as soon as it reaches a free bay.
ru

In the touch panel screen "Statistic", in addition to the statistic values so far, the minimum,
bo

maximum and average weight up until now is also displayed as well as the sum of all weights.
Since the capacity of the weight storage is limited, only a maximum number of parts can be
transported. If this maximum number of parts is reached, no further transportation can be
@

started at the light barrier bay (indicator light is dark), even if one or more of the Bays 1, 2, or 3
is enabled (free).
Only after "P_Operation" (Q0.1) is switched off and then switched on again, are all statistic and
sa

weight values initialized and new parts can be transported


m
sa
ry

9-2 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Overview
9.3 of Data Types inof
Overview STEP 7 Types
Data in STEP 7

.c
Type Data types

an
Elementary Binary number BOOL
Data types
Bit sequences BYTE; WORD; DWORD; LWORD

s
Integers SINT; USINT; INT; UINT; DINT; UDINT; LINT ULINT

ru
Floating-point numbers REAL; LREAL

bo
Timers S5TIME; TIME; LTIME
DATE; TIME_OF_DAY; LTIME_OF_DAY;
Date, Time-of-day
LDT(DATE_AND_LTIME);

Complex
Data types
Characters
@
Date, Time-of-day
CHAR; WCHAR

DT(DATE_AND_TIME); DTL;
sa
Character string STRING; WSTRING
Arrays ARRAY […] of <Datatype>
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Anonymous Structures STRUCT


m

User-defined data types PLC-data type (User Defined DataType)


sa

Elementary Data Types


ry

Elementary data types are predefined in accordance with IEC 61131-3. They always have a
length less than or equal to 64 bits.

Complex Data Types


Complex data types contain data structures that can be made up of elementary and/or complex
data types. Complex data types can be used for the declaration of variables only in global data
blocks and within blocks for the declaration of local variables (TEMP, STAT) as well as
parameters (IN, OUT, and INOUT).
c om
n.
sa
ru
bo
@
sa
m
sa
ry

9-3 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Time Stamp: DTL

om
9.3.1 Time Stamp: DTL

.c
s an
ru
Structure belongs
to the data type
(automatically created)

bo
LAD
@ FBD
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Overview
The DTL (Date and Time) data type represents a point in time, consisting of the date, the time of
ry

day, and the weekday identifier.


Unlike the time stamp of the data type DT, the time stamp of the data type DTL is created as a
structure for which the individual components can be addressed symbolically.
Furthermore, the values of the individual structure elements are coded in arithmetic data types
so that these can be further processed by the program with the available "Mathematical
Functions".
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

9-4 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Character String: STRING/WSTRING
9.3.2 Character String: STRING/WSTRING

om
STRING: (max. 254 characters)

.c
Grouping of ASCII characters

an
(CHAR) in bytes
WSTRING: (max. 16382 characters)
Grouping of characters in

s
Unicode format (WCHAR)

ru
(one word per character)
Byte/Word n max length= 8 Number of possible

bo
characters (reserved
Byte/Word n+1 actual length= 3
memory space)
Byte/Word n+2 1. character= 'T'
Number of
Byte/Word n+3 2. character= 'I' actually valid
Byte/Word n+4
Byte/Word n+5
3. character= 'A'
B#16#00
@characters

Access with direct addressing


sa
Byte/Word n+6 B#16#00
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Byte/Word n+7 B#16#00


m

Byte/Word n+8 B#16#00


Byte/Word n+9 B#16#00
sa

Overview
ry

The String/WSTRING data type is used for storing character strings (such as message texts). In
this way, a simple “(message) word processing system” can be implemented in an S7-CPU. The
STRING data type represents a character string of up to 254 ASCII characters. The WSTRING
data type, however, can store up to 16382 characters in Unicode format.
The number specified in square brackets in the declaration gives the maximum number of
characters that can be saved in the STRING/WSTRING variables.
m
Storing Variables
In setting up the variable, you enter its maximum length into the first byte (STRING) or first word
co

(WSTRING) of the variable according to the variable declaration. Likewise, the actual number of
stored characters according to the start value is entered in the second byte (STRING) or second
word (WSTRING).
n.

The standard instructions require these two pieces of length information to process STRING or
sa

WSTRING variables.
Subsequently, the characters follow a STRING variable in ASCII format and a WSTRING
ru

variable in Unicode format.

Parameter Passing
bo

Just like ARRAY or STRUCT variables, variables of the STRING or WSTRING data type can be
passed to block parameters with the same data type and same length.
@
sa
m
sa
ry

9-5 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Slice
9.4Access Slice
(All Languages)
Access (All Languages)

om
.c
"My_Var ", Data type LWORD

an
Slice Access
Examples:

s
ru
X X X bit-by-bit:
63 7 0 "M y_Var".%X0

bo
byte-by-byte:
B7 B1 B0
"M y_Var".%B1
@ word-by-word:
W3 W1 W0
"M y_Var".%W3
dword-by-dword:
D1 D0
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
"M y_Var".%D1
m
sa

Slice Access
In all programming languages, the slice access enables a bit, byte, word, and double-word
access to variables of larger dimensions.
ry

With a bit access, for example, the individual bits of an integer variable can be scanned or low
and high byte can be loaded even though no symbolic names exist for these variable elements.

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

9-6 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Example of a Slice Access: ‘Sign’ Scan
Example of a Slice Access: ‘Sign’ Scan

.c
s an
ru
bo
LAD
@ FBD
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Example: Scanning the Sign Bit of an Integer variable


ry

An individual bit of an Integer variable cannot be addressed symbolically and can only be
scanned by means of indirect addressing or by slice access.
In the example shown, the sign bit (bit no. 15) of the data block variable Weight is scanned in
order to check whether the value of the variable is positive and with that plausible (a negative
weight value cannot exist and so would not be plausible). c om
n.
sa
ru
bo
@
sa
m
sa
ry

9-7 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Access
9.5 to ARRAY Elements
Access to ARRAY Elements

.c
an
ARRAY:
Grouping of components

s
of the same data type

ru
bo
Array access with
direct addressing
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Overview
ry

The ARRAY data type represents a field with a fixed number of components (elements) of the
same data type. A field (=ARRAY) can have up to six dimensions (number of indexes).
The data types of the components (within an array) can be bit sequences, integers, floating-
point numbers, timers, character strings, structures or PLC-data types (UDT). Parameter types
or FBs (multiple instance model) are not permitted.
ARRAYs cannot be nested. The limits of the minimum or maximum index range are defined for
S7-300/400 by the value range of INT, that is, from -32768 to 32767 and for S7-1500 by the
value range of DINT, that is, from -2147483648 to 2147483647.
m
Maximum Array Limits
co

The maximum Array limits depend on the following factors:


• Data type of the Array elements
n.

• Maximum size of a data block of a CPU (you will find further information in the respective
manual)
sa

• The entire length of the Array is available within a data block. Within a program block (OB,
FB or FC), the possible length is reduced according to the memory capacity which the
ru

program code requires.


bo

Note
Valid for CPUs of the S7-1500 series
For a block with the block property "Optimized block access", one bit requires a memory space
@

of 1 byte. This is also true if you use an ARRAY of <Datatype>. Thus, for example, an ARRAY
[0..1] of BOOL requires 2 bytes in an optimized block.
sa
m
sa
ry

9-8 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Indexed Array Accesses
9.5.1 Indexed Array Accesses

.c
Read access

an
LAD
FBD

s
ru
bo
Write access

FBD @ LAD
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

FieldWrite
ry

The instruction "FieldWrite" writes the value of the operand passed at input VALUE into the
array passed at output MEMBER. The value is written in the array element whose number is
specified via the input INDEX. (Note that the block editor at output MEMBER always displays
the first Array element #WeightStore.Part_Weight[1]).
The data types of the array specified at output MEMBER and of the operand at input VALUE
must match the data type of the instruction "FieldWrite".
The instruction signals an error with Status '0' at output ENO when the array element specified
via input INDEX does not exist in the array specified at output MEMBER.
om
FieldRead
The instruction "FieldRead" reads the value of an array element of the array passed at input
MEMBER and writes this in the variable specified at output VALUE. Which array element is read
.c

is specified via the input INDEX.


The data types of the array specified at input MEMBER and the variable specified at output
an

VALUE must match the data type of the instruction "FieldRead".


The instruction signals an error with Status '0' at output ENO when the array element specified
us

via input INDEX does not exist in the array specified at input MEMBER.

Indexed Array Accesses with the FBD Instruction MOVE


r
bo

Just as with the instructions "FieldRead" and "FieldWrite", indexed Array accesses can be
programmed with the MOVE instruction.
@
sa
m
sa
ry

9-9 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Example of Indexed Array Accesses: Saving Part Weights in "WeightStore"
Example of Indexed Array Accesses: Saving part weights in "WeightStore"

om
.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Example: Saving part weights in "WeightStore"


sa

In the example shown, the value of the variable #WeightStore.CurrQuant is increased by 1


every time a part arrives, that is, with every execution of the block. With that, the value of this
ry

variable corresponds becomes an index counter. On the next block execution, the value of
#Weight is stored in the array variable #WeightStore.Weight[i], where [i] is the value of this
index counter. c om
a n.
r us
bo
@
sa
m
sa
ry

9-10 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Program Loops with Indexed Array Access

om
Program Loops with Indexed Array Access

.c
Initialize loop counter

an
(Number of first
ARRAY element)

s
Write ‘0’ to

ru
WeightStore for
part weight with

bo
index [loop
counter]

Increment loop
counter
(add 1)
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Loop counter less than or


equal to number of last
m

ARRAY element? Variables also


possible
sa

Program Loops
ry

Program loops are used, among other things, when larger amounts of data are to be processed.
Due to the inner structure of the loop, one and the same code (logic) part is processed
repeatedly. This code uses indirect addressing to access variables in which the data to be
processed is stored.

Function of the Example Shown:


Each element of the Array #WeightStore.Weight[0..9] of UINT is initialized with ‘0’.
NW11: Initialize Loop counter / Index:
m
The variable #temp_index is used within the loop to count the number of loop executions and
for the indirect addressing of the Array elements.
co

NW12: Code part


Every time the code part of the loop is executed, the Array element, whose number the loop
n.

counter variable #temp_index contains, is initialized with ‘0’. The individual Array elements are
thus indirectly addressed via the loop counter variable #temp_index, that is, #temp_index is
sa

used as "Pointer" to the Array elements.

NW13: Count up loop counter


ru

The value of the variable #temp_index is increased by 1 with every loop execution.
NW14: Jump back if #temp_index is <= 9
bo

In order to initialize each Array element with 0, the loop must be executed as often as the Array
has elements.
As long as the value of #temp_index is <= 9 (number of the last ARRAY element), a jump back
@

to the label "loop" occurs where the program execution then continues or the program loop is
once again executed.
sa
m
sa
ry

9-11 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Array of Multiple Instance

om
9.5.2 Array of Multiple Instance

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Functions
• Save multiple instance data in an Array
ry

• Multiple instances can be called in loops


• Also for PID technology objects, however, without configuration and commissioning screens

Use
• Drastic reduction of code
• Better readability

om
Efficient programming of mass calls (data localization)
c
a n.
r us
bo
@
sa
m
sa
ry

9-12 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Copying
9.6 and Copying
Filling Variables of Complex
and Filling Data Types
Variables of Complex Data Types

om
Copying the entire variable or individual elements

.c
s an
Copying an area as of a certain element (can be interrupted / cannot be interrupted)

ru
bo
@
Filling an area as of a certain element (can be interrupted / cannot be interrupted)
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

MOVE (Copy/Move Values of a Variable)


sa

You use the "MOVE" instruction to copy variables of any dimension. The memory areas of the
source and target variables can be in memory areas that are created as optimized and/or non-
ry

optimized. Values of any data type can be transferred. The only condition is that the variables
are of the same data type or are declared according to the same PLC data type.

MOVE_BLK (Copy/Move Area/Block)


You use the "Move Block" instruction to copy the contents of an ARRAY memory area (source
om
range) into another ARRAY memory area (target range). You transfer the first element of the
source range to the parameter IN. You specify the first element of the target range at the
parameter OUT and you specify the number of elements that are copied (moved) into the target
range with the parameter COUNT. The width of the elements to be copied is defined by the
c

width of the element at parameter IN.


n.

The instruction can only be executed if the elements of the source and target range have the
same data type.
a
us

FILL_BLK (Fill Area/Block)


You use the "Fill Block" instruction to fill an ARRAY or STRUCT memory area (target range)
r

with the value of the input IN. The target range is filled beginning with the variable specified at
bo

the output OUT. The number of repeated copy operations is specified with the parameter
COUNT.
The instruction can only be executed if the data type of the source range and the data type of
@

the elements in the target range have the same data type.
Only as many elements are changed as the ARRAY or Structure has elements. If you copy
more data than there are elements at the output OUT, you will get an unintended result. (ENO =
sa

'FALSE')
m
sa
ry

9-13 SITRAIN
SIMATIC Programming 2 in the TIA Portal

9.7 – Simulating
PLCSIM PLCSIMa Controller (S7-PLCSIM
– Simulating S7-1200/1500)

om
a Controller (S7-PLCSIM S7-1200/1500)

.c
an
Compact view

s
(PLCSIM project not

ru
necessary)

bo
Modification of noninputs

Load all project tags


Project view @ Monitor/modify tags/variables
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

“TIA Portal Information Center” > Documentation >


m

Use Sequences
FAQs > Control Technology > SIMATIC S7-PLCSIM
sa

S7-PLCSIM is used to test and validate a single PLC program or parts of it without requiring the
ry

actual hardware for it.


PLCSIM can be started directly from STEP 7. The program with the hardware configuration is
loaded into PLCSIM (all other interfaces are switched off).
Features:
• Compact and Project view
• No simulation project is necessary to start

om
Supports F including F I/Os, compact CPUs and T CPUs including Motion functions
• Loading and Monitor/Modify the tags/variables from the S7 project
• Simulation of distributed I/Os possible
c

• Use of Sequences
a n.
r us
bo

• Event tables to simulate hardware interrupts, diagnostic errors, plug and pull modules, rack
@

and station failures


sa
m
sa
ry

9-14 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Activating
9.7.1 and Deactivating
Activating the Ability tothe
and Deactivating Simulate Blocks
Ability to Simulate Blocks

.c
an
1. Set the property of

s
the project

ru
bo
2. Compile software

@
Know-how protection must
be deactivated and ‘typed’
blocks must be editable 3. Check the ability to
simulate the blocks
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Caution: The simulation of blocks reduces the know-how protection!!!


ry

In order to be able to simulate an S7 program, it must be possible to simulate all blocks with
SIMATIC S7-PLCSIM. In the Properties > Compile > Simulation, the ability to simulate the block
can be checked.
To activate the simulation, you must first activate - in the Properties dialog of the project under
Protection - that the simulation is supported when the blocks are compiled. Second, you must
compile all blocks that are to support the simulation.

Note
You can only change the support of the simulation if the block can be edited. That is, for know-
how protected blocks, you must cancel the know-how protection, and for ‘typed’ blocks, you
must activate the editing. After the compilation, you can re-activate the know-how protection or
release a new version.
m
Caution
co

The know-how protection of blocks is reduced by the simulation. For that reason, deactivate the
simulation of know-how protected blocks when you no longer simulate them.
n.
sa
ru
bo
@
sa
m
sa
ry

9-15 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Simulating an HMI Device
9.8 Simulating an HMI Device

.c
s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

Starting the Simulation

The simulation of an HMI device is started with the button "Start simulation".

Note
The simulation can be active parallel to a real HMI device.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

9-16 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Settings for Simulating an HMI Device
9.8.1 Settings for Simulating an HMI Device

.c
s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Example of Interface Parameter Assignment Used:


Access via given network card (on real CPU)
sa

Access to simulated CPU in PLCSIM S7-1200/1500


ry

HMI devices (the touchpanel) can also be simulated. For this, however, you must first set the
interface through which the simulation accesses the PLC controller.
In the Connections of the HMI device, the correct Access point must be specified (default setting
is "S7ONLINE") and this, in turn, must be assigned the correct PG/PC interface (see picture
"Set PG/PC Interface").
You can select a real network card when the communication is to be established to a controller
connected via this network card (select the relevant network card). Furthermore, you can
specify that the communication is to take place to a simulated CPU which is simulated with the
PLCSIM S7-1200/1500 software. (Select PLCSIM.xxx, whereby xxx corresponds to the type of
interface, for example, PROFIBUS or TCPIP).
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

9-17 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
9.9 Task Description: Managing Weight Values in Weight Store and
Task Description:
DisplayingManaging Weight Values
Statistical in Weight Store and Displaying
Values
Statistical Values

.c
s an
ru
bo
346
@
sa
237
144
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

#tempAutoLeftStop
m
sa

Program Function Up Until Now


When "P_Operation" (Q0.1) is switched on, parts are placed on the conveyor at the light barrier
ry

bay, weighed (weight simulation via "S_Slider1" (IW10) on the simulator) and, after pressing the
bay pushbutton, are transported to the next free Bay 1, 2, or 3. When a part reaches the bay,
the indicator light signals with a flashing light that the part can be removed. After that, it has a
continuous light indicating that the bay is still occupied. The bay may be cleared using the
associated bay pushbutton, whereupon the bay indicator light goes dark.
The transported parts are counted for each bay and the statistical data are calculated. Both
total quantity and the utilization of the 3 bays are determined. After a part has reached a bay,
the bay can immediately be enabled again by pressing the associated bay pushbutton, so that
any number of parts can be transported to every bay. Only when "P_Operation" (Q0.1) is
m
switched off and switched on again are the IEC counters used for counting as well as the
statistic values reset to ‘0’.
co
n.
sa
ru
bo
@
sa
m
sa
ry

9-18 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
9.9.1 Exercise 1: Creating PLC-Data Type "type_WeightStore" and Weight-Database-
Exercise 1:
DB Creating PLC-Data Type "type_WeightStore" and
"DB_Weight"

.c
Weight-Database-DB "DB_Weight"

s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Task
ry

The PLC data type "type_WeightStore" is to be created as shown in the picture, according to
which the weight storage or structure variables WeightStore_A, WeightStore_B, and
WeightStore_C are then to be declared within "DB_Weight". These variables are later to be
used to save the weights of the transported parts.

What to Do
1. Create the new PLC data type "type_WeightStore" as shown in the picture. Make sure that
you create the component MaxQuant with a default value 10, which specifies the maximum
number of storable part weights.
2. Create the new "DB_Weight" and in it declare the weight storage or structure variables
WeightStore_A, WeightStore_B, and WeightStore_C of the data type "type_WeightStore"
m
(see picture).
Note: The default value of the variable "MaxQuant" is adopted as Start value in all three
co

structures and should therefore have the value 10.


3. Save your project.
n.
sa
ru
bo
@
sa
m
sa
ry

9-19 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 2: Expanding "DB_OP" and Connecting New Tags to the touch panel

om
9.9.2 Exercise 2: Expanding "DB_OP" and connecting new tags to the touch panel

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
In addition to the already displayed statistic values with regards to part quantities and current
ry

weight, the maximum, minimum, and average value of saved weights so far as well as their sum
are now to be displayed in the touchpanel screen "Statistic".

What to Do
1. Expand "DB_OP" by adding the tags "MaxQuant", "MaxWeight", "AvWeight", "MinWeight",
and "WeightSum" with the relevant data types as shown in the picture.
2. Open the touch panel screen "Statistic" and in the Properties of the output fields Total,
max, average and min, define the relevant PLC tags from the "DB_OP" data block.
m
3. If necessary, adjust the properties of the fields.
co

4. In the Project tree, select the data block "DB_OP" and, using drag & drop, drag the tag
"MaxQuant" from the Details view into the "Conveyor" screen (see picture).
5. Load the modified configuration into the touchpanel, and in the Inspector window check
n.

whether the compilation and loading could be carried out without error.
sa

6. Save your project.


ru
bo
@
sa
m
sa
ry

9-20 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
ExerciseExercise
9.9.3 3: Programming "FB_Weight"
3: Programming "FB_Weight"

.c
#MaxQuant ← #WeightStore. MaxQuant Pos. Edge at #Operation
no yes

an
#StoreFull when #WeightStore. CurrQuant >= #WeightStore.CurrQuant, #MaxWeight,
#WeightStore. MaxQuant #WeightSum ← 0;
#MinWeight ← 500; #AvWeight, ← 0.0

s
#NewWeight AND NOT #StoreFull ?
no yes
#temp_index ← 0

ru
#WeightStore.Weight[#WeightStore.CurrQuant]←#Weight
#WeightStore.Weight[# temp_index] ← 0

bo
#WeightStore.CurrQuant ← #WeightStore.CurrQuant + 1 # temp_index ← # temp_index + 1

#Weight > #MaxWeight ? #temp_index < #WeightStore. MaxQuant ?


no yes

@
#MaxWeight ← #Weight
#Weight < #MinWeight ?
no
sa
#MinWeight ← #Weight Ja
#WeightSum ← #WeightSum + #Weight
#AvWeight ← #WeightSum / #WeightStore.CurrQuant
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

The new block "FB_Weight" is to be programmed. It is to save the weights of the transported
parts in a weight-storage and determine the maximum, average, and minimum value of the
ry

saved weights as well as their sum.

What to Do
1. Insert the new block "FB_Weight" and provide it with the following parameters (also see
picture):
Input Parameters (IN)
#Operation (BOOL)
With a rising edge at this input, the block overwrites all weight values #WeightStore.Weight,
the current quantity (#WeightStore.CurrQuant) and the statistical values (#MaxWeight,
#AvWeight, #MinWeight, and WeightSum).
om
#NewWeight (BOOL)
With Signal ‘1’ at this input, the block writes the weight existing at parameter #Weight to the
storage #WeightStore.Weight with the Index actual quantity (#WeightStore.CurrQuant) and
.c

then increases the actual quantity by 1. Since this is to occur only once per part, a 1 must
exist only for one cycle.
an

#Weight (UINT)
The currently set weight.
r us
bo

Continued on the next page


@
sa
m
sa
ry

9-21 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Output Parameters (OUT)

.c
#Storefull (BOOL)
Signal ‘1’, when actual quantity (#WeightStore.CurrQuant) is >= Max quantity

an
(#WeightStore.MaxQuant).

#MaxQuant (UINT)

s
Output of the value from #WeightStore.MaxQuant

ru
#MaxWeight (UINT)
Largest part weight stored

bo
#AvWeight (REAL)
Average value of all part weights

#MinWeight
@(UINT)
Smallest part weight stored
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

#WeightSum (UINT)
Sum of all stored part weights
m
sa

In/Out Parameters (INOUT)

#WeightStore ("type_WeightStore")
ry

Weight-storage, from which the Max.quantity is read and into which the actual quantity is
written and the part weights are saved.

Static Variables (STATIC)

#AuxPosOperation (BOOL)
Auxiliary bit for evaluating the positive edge at input #Operation for initializing the weight
storage
om
Temporary Variables (TEMP)
c

#temp_index (DINT)
n.

Number of the current part weight, for the initialization of the individual weights.
a
us

2. Program "FB_Weight" and proceed as shown in the structogram.


3. Save your project.
r
bo
@
sa
m
sa
ry

9-22 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 4:
9.9.4 Calling "FB_Weight"
Exercise 4: Calling "FB_Weight"

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
The new block "FB_Weight" is to be called in "OB_Cycle". For the first test using PLCSIM, the
ry

transport end is simulated with the help of a memory bit.

What to Do
1. Expand "DB_Conveyor" by adding the variable "WeightStoreFull" (BOOL).
2. In the Organization block "OB_Cycle", program the call of "FB_Weight" and parameterize it
with the actual operands shown in the picture.
3. Connect a memory bit (for example, M200.0) to the formal parameter "NewWeight", and
give it the symbol name "SimNewPart".
Note: So that it has the value "TRUE" for only one cycle, it is reset when it has the value
"TRUE".
m
4. Compile the entire hardware and software of the "S7-1500" device.
co

5. Select the "S7-1500" device and start the simulation via the button "Start simulation" and
load the hardware and software.
Note: Confirm the deactivation of all interfaces and specify "PLCSIM" for the PG/PC-
n.

interface in the dialog "Extended download to device".


sa
ru
bo
@
sa
m
sa
ry

9-23 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 5:
9.9.5 Function
Exercise 5:Test with PLCSIM
Function Test with PLCSIM

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
You are to check how the "FB_Weight" block functions using the simulation program PLCSIM.
ry

What to Do
1. Switch to PLCSIM in the project view.
2. Create a new project with the name "MyPLCSIMProject" in order to be able to modify
variables.
3. In PLCSIM, open the SIM table or create a new table.
4. In the table, enter the variables "P_Operation", "S_Slider1":P (for setting the weight),
"DB_Conveyor".Weight (for checking the weight) and "SimNewPart" as simulation bit for
"New part was transported").
5. In addition, as a check, you can display the variables as shown in the picture.
om

6. Open the data blocks "DB_Weight" and "DB_OP" and monitor the weight storage
"WeightStoreB" of the data block "DB_Weight" as well as the calculated values in the data
block "DB_OP".
c

7. In PLCSIM, give the variable "S_Slider1":P a value between 0 and 27648 decimal in the
n.

column "Monitor/Modify value" (the values correspond to the values of the variable
"DB_Weight".Weight as 0..500 in decimal).
sa

8. Activate the function "Enable/Disable Modification of non-inputs" using the button in


ru

order to change outputs, memory bits and data block variables.


9. In the column "Bits", activate the bit "P_Operation" for Operation = ON, and, to simulate a
bo

new transported part activate the bit "SimNewPart" (the memory bit is automatically reset to
0 in the program and consequently is TRUE for only one cycle).
10. Check whether the values of the variable "DB_Weight".WeightStoreB and the calculated
@

values in "DB_OP" are correct.


sa
m
sa
ry

9-24 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 6:
9.9.6 Commissioning
Exercise "FB_Weight"
6: Commissioning "FB_Weight"

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

If the simulation was successful, the call of "FB_Weight" can be re-parameterized as shown in
the picture. In addition, when the weight memory is full, no new transport is to be possible. For
ry

this, the transport start and the display are locked.

What to Do
1. Exit the simulation (CLASSROOM).
2. In "OB_Cycle", modify the parameterization of "FB_Weight" with the actual parameters
shown in the picture.

Note: The call of "FB_Weight" must be programmed after the call of "FB_Signal" since the
temporary variable #AutoLeftStop is written to it. (This was already programmed in the
om
chapter "Program Design Methods")
c

3. Logically link the new variable "DB_Conveyor".WeightStoreFull in "FB_Signal" in such a


way that the conveyor model indicator light "ConveyorOut".P_BayLB remains dark when the
n.

WeightStore is full.
sa

4. Furthermore, logically link this variable in "FB_Conveyor" in such a way that no part
transportation can be started when the WeightStore is full.
5. Download all blocks into the CPU and check the new program functions by interpreting the
ru

values shown on the touchpanel screen "Statistic".


bo

6. Save your project.


@
sa
m
sa
ry

9-25 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
AdditionalAdditional
9.9.7 Exercise (CLASSROOM): Simulating the
Exercise (CLASSROOM): Touchpanel
Simulating the Touchpanel

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
You are to start the touchpanel simulation:
ry

What to Do
1. Check the name of the configured Access point of the HMI connection. (Area_1 >
Touchpanel (TP700 Comfort) > Connections)
2. Under Windows > Control system, open the dialog "Set PG/PC interface" and assign the
interface "PLCSIM.XXX" (XXX is the name of the Ethernet network card) to the Access
point with the name what was read-out in #1.

3. In TIA Portal, select the touchpanel and start its simulation using the button "Start
simulation".
m
4. Check the displayed values and the functioning of the individual buttons.
co
n.
sa
ru
bo
@
sa
m
sa
ry

9-26 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
9.10 Appendix

.c
PLCSIM Advanced Completely Virtual S7-1500 Controller for Simulation
9.10.1 PLCSIM Advanced Completely Virtual S7-1500 Controller for Simulation

s an
Virtual S7-1500 (F/T) Simulation Features

ru
Controller
PLCSIM Advanced

bo
• Interface for coupling to
Co-simulations such as
• Mapping of real PLC Process Simulate, Plant


functions
No simulation-specific
adjustments
@ Simulation and
WinMOD
• Multiple & distributed
sa
necessary PLCSIM Adv. instances
• Virtual time for realtime,
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Slow & Fast Mode


S7-1500
sa

Digital twin
ry

With S7-PLCSIM Advanced, CPU programs can be simulated on a virtual controller. For this, no
real controllers are required. The CPU is configured in STEP 7, the application logic is
programmed and the hardware configuration and the program are loaded into the virtual
controller. From there, the program logic can be executed, the implications of the simulated
inputs and outputs monitored, and the program adjusted.
PLCSIM Advanced has an interface for coupling process simulations which enables a real
system simulation.
In addition to the communication via Softbus, S7-PLCSIM Advanced offers a full-fledged
m
Ethernet connection and is consequently also capable of distributed communication.
co

Online Support application examples:


• SIMATIC S7-PLCSIM Advanced: Co-Simulation via API
n.

(Entry-ID: 109739660)
• S7UnitTest: Automated testing with SIMATIC S7-PLCSIM Advanced
sa

(Entry-ID: 109746405)
ru
bo
@
sa
m
sa
ry

9-27 SITRAIN
SIMATIC Programming 2 in the TIA Portal
PLCSIM Advanced - Software in the Loop
9.10.2 PLCSIM Advanced - Software in the Loop

om
Real World Virtual World

.c
S7-1500 PLCSIM Advanced

an
Hardware Controller Virtual Controller for Simulation
Controller

s
ru
bo
API

Process Plant Other


Simulate Simulate Co-Simulation
@
Process

sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Application example under Entry-ID:


109739660
m
sa

Software in the Loop simulation serves the virtual commissioning of machine tools. Due to the
connection to software from third-parties, simulations of production machines and systems, as
ry

well as combined simulations of automation and mechanics can be made possible.

User Interface (API)


Via the user interface (API), S7-PLCSIM Advanced makes it possible to interact with your own
C++/C#-programs or software.
om
Advantages
• Improve the quality of automation projects
• Reduce time-to-market
c

• Reduce production times


n.

• Reduce the risks with the commissioning


a

• Avoid the costs for hardware in simulation environments


us

• Increase efficiency in maintenance


r
bo
@
sa
m
sa
ry

9-28 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Difference between PLCSIM and PLCSIM Advanced
9.10.3 Difference between PLCSIM and PLCSIM Advanced

.c
an
/ S7-1200/-1500 /
PLCSIM PLCSIM Advanced
API

s
up to 2 Multiple instances up to 16

ru
Distributed instances
OPC UA

bo
Web server
Process diagnostics
( ) Traces
( ) Motion

@
Softbus S7 communication
Controller Simulation integrated Softbus Open User communication Virtual S7-1500 Controller
in STEP 7 in TIA Portal
KHP blocks
sa
Applications:
Virtual time
Application: • Function test of the STEP 7 program,
Connection of real also in the context of a system/machine
Function test and validation
m

CPUs/HMIs
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

of the STEP 7 program • Operator Training


DNS usage
• Virtual commissioning / Factory
sa

Virtual Memory Card


Acceptance Test (FAT)
ry

API:
Application Programming Interface

OPC UA:
Open Platform Communications Unified Architecture:
is a software interface in the Automation technology area

Traces:
In PLCSIM Standard, can be monitored in TIA Portal; in PLCSIM Advanced can also be
monitored in the Web server.

Motion:
m
In PCLSIM Standard, the axes are always in simulation mode. For PLCSIM Advanced, you can
co

also operate the axis in "Real" mode.

S7 Communication
n.

(PUT / GET, BSEND / BRCV, USEND / URCV)


sa

KHP Blocks:
ru

Know-How Protected blocks (Blocks that are protected with a password)


bo
@
sa
m
sa
ry

9-29 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Scatter* / Gather*
9.10.4 Scatter* / Gather*

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Scatter
ry

The instruction "Parse the bit sequence into individual bits" disassembles a (variable) tag of the
BYTE, WORD, DWORD or LWORD data type into individual bits and saves them in an ARRAY
of BOOL.

Gather
The instruction "Merge individual bits into a bit sequence" combines the bits from an ARRAY of
BOOL into a bit sequence. The bit sequence is saved in a (variable) tag of the data type BYTE,
WORD, DWORD or LWORD.

Note
om
The ARRAY of BOOL must have exactly the number of elements that is specified by the bit
sequence. This means for the data type BYTE, for example, the ARRAY must have exactly 8
elements (WORD = 16, DWORD = 32 and LWORD = 64).
c
n.

Scatter_BLK
The instruction "Parse elements of an ARRAY of bit sequence into individual bits" disassembles
sa

one or more elements of an ARRAY of BYTE, WORD, DWORD, or LWORD into individual bits
and saves them in an ARRAY of BOOL. At the COUNT_IN parameter you specify how many
elements of the source ARRAY are going to be disassembled. The ARRAY of BOOL must have
ru

sufficient elements to save the bits of the disassembled bit sequences.


bo

Gather_BLK
The instruction "Merge individual bits into multiple elements of an ARRAY of bit sequence"
combines the bits from an ARRAY of BOOL into one or multiple elements of an ARRAY of <bit
@

string>. At the COUNT_OUT parameter you specify how many elements of the destination
ARRAY are going to be written. With this step you also implicitly specify how many elements of
the ARRAY of BOOL are required. The ARRAY of <bit string> must have sufficient elements to
sa

save the bits that are going to be combined.


m
sa
ry

9-30 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Extended Instructions: STRING, DT

om
9.10.5 Extended Instructions: STRING, DT

.c
san
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

c om
a n.
r us
bo
@
sa
m
sa
ry

9-31 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
10 Optimized Blocks

.c
an
Learning objectives
10.1 Learning objectives

s
ru
• You know the difference between blocks with optimized access and with non-optimized access

• You know under which conditions DBs can be downloaded into the CPU with and without re-initialization

bo
• You know how to download an expanded data block into the CPU without re-initialization

• You know how to read out the start information of an optimized OB using
the function "RD_SINFO"
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

om
.c
an
r us
bo
@
sa
m
sa
ry

10-1 SITRAIN
SIMATIC Programming 2 in the TIA Portal

10.2 Task Description: Downloading structurally changed Data

om
Task Description: Downloading
blocks without Structurally Changed Data Blocks without Re-
re-initialization
initialization

.c
s an
ru
New tag "MessageBits"

bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Download without
m

reinitialization
sa

Task Description
ry

During running operation or in the CPU RUN state, S7-1500 allows the downloading of data
blocks into the CPU that were structurally changed or that were expanded by adding variables
(tags) without overwriting the monitoring values (actual values) of the originally already existing
variables. In this way the loading of program expansions when a system is running is made
possible without losing current system data in the process.
In this chapter, you are to become familiar with this "Downloading without re-initialization" of
structurally changed data blocks.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

10-2 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Programming
10.3 Languages: Overview
Programming Languages: Overview

.c
an
S7-300/400/WinAC WinAC S7-1500
S7-300

s
S7-400

ru
All languages are equal :
- All programming languages basically provide the same performance

bo
- All languages support all types of access
- Switching is only possible between LAD and FBD
FBD LAD (Mixed blocks are however possible)
SCL SCL Graph

@
LAD
STL STL
FBD
sa
m

Machine code Machine code


Private copy for Recep Yigit Samsa, rysamsa@borusan.com

S7-300/400/WinAC S7-1500
sa
ry

Overview of Programming Languages


While for S7-300/400, the programs of the programming languages LAD/FBD were first of all
compiled in STL and then from STL into the machine code of the controller, for S7-1500, all
programming languages have their own compiler which compiles the respective language
directly into the machine code of the controller.

Note
Since the programming language requires registers for execution and the S7-1500/1200 doesn’t
have any registers, the necessary registers have to be emulated for blocks that are
programmed in STL. This has a negative impact on the performance of the program. Therefore,
avoid programming in STL.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

10-3 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
System Architecture of S7-1500
10.3.1 System Architecture of S7-1500

.c
S7-1500

s an
ru
bo
• Process Image for
Inputs and Outputs Local data Data blocks



Memory bits
S5-Counter
S5-Timer
@ Local data optimized
non-optimized

Data blocks
sa
optimized
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

System Architecture of S7-1500


ry

The S7-1500 has separate memory areas for the process images, memory bits, S5-Timers, S5-
Counters as well as for the local data and data blocks. The memory areas for the local data and
data blocks are further subdivided into areas for optimized and non-optimized data storage.

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

10-4 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Block
10.4Attribute: Optimized
Block Block Optimized
Attribute: Access Block Access

.c
s an
ru
bo
-> optimized data storage
-> symbolic addressing

@ ->
->
tag-by-tag retentiveness
better performance
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Attribute "Optimized Block Access"


ry

The "Optimized block access" attribute can be assigned to all code (logic) blocks and data
blocks. Blocks created as optimized offer the following advantages:
For data blocks:
• The retentive behavior of the variables can be adjusted tag-by-tag
• With S7-1200, these DBs are created memory-optimized
• With S7-1500, these DBs are created access-optimized
• The variables of the data block can only be accessed symbolically
For code (logic) blocks:
om
• The code of the block is compiled runtime-optimized
• No indirect addressing via pointer with absolute addresses
.c

Note
an

You find more information in the "Programming guideline for S 7-1200 and S 7-1500".
(Online support - Entry ID: 81318674).
us

Communication HMI Device <→ DB in CPU


If the HMI device and S7 controller are integrated in one project or if the controller is integrated
r

in an HMI project as Proxy, the HMI can symbolically access a DB of the CPU, that is, the DB
bo

can also be created as "optimized".


If the HMI device is not integrated in the project (because it is a third-party device or an older
panel still configured with ProTool), it can only access a DB of the CPU absolutely, that is, the
@

DB must not be created as "optimized" in the CPU.


sa
m
sa
ry

10-5 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Comparison: Non-optimized and Optimized Block Accesses
10.4.1 Comparison: Non-optimized and Optimized Block Accesses

om
.c
Non-optimized Block Access Optimized Block Access

an
Managed and optimized by the system:
Data storage Any, depending on the user declaration The user can set up any structure without
burdening the memory capacity.

s
The access is not always as fast as it could The access always takes place as quickly as

ru
be for S7-1200/1500 since the data could be possible since the data storage is optimized
Performance "unfavorably" located depending on the by the system and is independent of the
declaration. declaration.

bo
Lower, since generally symbolic accesses
Absolute accesses (for example, from HMI
are used. Declaration changes do not lead to
Prone to errors or through indirect addressing) can lead to
access errors since, for example, HMI
inconsistencies with declaration changes.

Retentiveness Block-by-block
@ accesses take place symbolically.

Variable-by-variable (Tag-by-tag)
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Recommendation: Mix non-optimized and optimized blocks as little as possible.


The system automatically converts the data models during access between the blocks
which uses up resources!
m
sa

Data Storage
For the declaration of variables of global data blocks, for parameters and static variables within
ry

function blocks, or for temporary variables, the Block Editor inserts "fill bytes", if necessary, for
blocks with "non-optimized access". This occurs, for example, when variables of the data types
BOOL and INT are declared in alternate sequence because INT variables are always placed on
even absolute addresses (even-numbered bytes).
For blocks with optimized access: the individual variables for a 1500-CPU are created access-
optimized and for a 1200-CPU they are created memory-optimized.
m
Performance
co

If both the data block and the code (logic) block which accesses the data block are created with
the attribute "Optimized block access", the accesses take place with optimized performance.
n.

Prone to Errors
Since optimized blocks work exclusively with symbolic variables, they are less prone to error.
sa

Also, the readability of a program improves because of the use of symbolic variables.
ru
bo
@
sa
m
sa
ry

10-6 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Programming Possibilities: Non-optimized and Optimized Block Access
Programming Possibilities: Non-optimized and Optimized Block Access

om
.c
Types of Access Non-optimized Block Access Optimized Block Access

an
Symbolic

s
Indexed (Arrays)

ru
Slice Accesses

bo
AT Construct * In planning

Absolute

Indirect (Pointer)
@
Download w/o
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

re-initialization
m

Non-optimized and Optimized Block Access


sa

The table shows that blocks with "Optimized block access" provide the possibility of
"Downloading without re-initialization". Expanded data and function blocks, however, do not
ry

offer any other additional programming possibilities.


The advantages of the optimized blocks is rather that data blocks are created as memory-
optimized (S7-1200) or access-optimized (S7-1500) with variable-by-variable retentiveness, and
that optimized code (logic) blocks have more performance and are less prone to error in the
access to these data blocks. m
co
n.
sa
ru
bo
@
sa
m
sa
ry

10-7 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Optimized Blocks (All): Automatic Initialization of Temporary Variables

om
10.4.2 Optimized Blocks (All): Automatic Initialization of Temporary Variables

.c
Non-optimized block Optimized block

s an
ru
bo
Value of Temp_Var Value of
is undefined Temp_Var is "0"
@
If the data type of the variable (tag) is a
sa
PLC data type, then the values of the elements are
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

initialized with the default values!


m
sa

Automatic Initialization of Local Temporary Variables


For non-optimized blocks, the local temporary variables are assigned with undefined values at
ry

the beginning of a block processing.


For optimized blocks, the local temporary variables are automatically initialized.
If the variables are of a PLC data type, then the elements of the variable are initialized with the
default values of the PLC data type. For all other variables, it is the value "0" or 'FALSE'.
om
c
a n.
r us
bo
@
sa
m
sa
ry

10-8 SITRAIN
SIMATIC Programming 2 in the TIA Portal
OB Start Information Non-optimized and Optimized OBs
10.4.3 OB Start Information Non-optimized and Optimized OBs

om
Startup-OB - Start information (non-optimized)

.c
an
s
ru
bo
Startup-OB - Start information (optimized)
@ RD_SINFO
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
For reading out the
complete Start
information
m

Start Information
sa

As already explained in the chapter "Program - Design Methods", when the operating system
calls organization blocks, the user is provided with system start information.
ry

• For non-optimized OBs, the start information has a length of 20 bytes and is available after
the start of the OB execution in the first 20 bytes of local data.
• For optimized OBs, the start information is passed by means of Input parameters and is
reduced for runtime reasons. Apart from the "Date and time", it can be read out with the
instruction "RD_SINFO".
com
n.
a
r us
bo
@
sa
m
sa
ry

10-9 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Reading-out the OB Start Information using RD_SINFO
10.4.4 Reading-out the OB Start Information using RD_SINFO

.c
an
Optimized
Non-optimized

s
ru
bo
@
sa
Start information of current OB
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Start information of the most recently


sa

executed Startup OB
ry

The function "RD_SINFO" provides the start information of the most recently called OB that is
not yet completely executed (current OB) at parameter TOP_SI and of the most recently called
OB with the event class "Startup" at parameter START_UP_SI
Since the parameters TOP_SI and START_UP_SI are of the data type Variant, it is possible to
conditionally define which information exactly and in which structure the information is to be
returned with the data type of the actual parameter. For this there are several system data types
available to the user (see Help on RD_SINFO).
In the example shown, the system data type "SI_classic" is used for TOP_SI and "SI_none" is
used for START_UP_SI.
With the help of the data type "SI_classic", you get the same start information and in the same
structure as it would be found in the temporary data for a non-optimized OB. Only the data and
m
time are not provided.
You use the system data type "SI_none" when, apart from the block number, no further start
co

information is to be queried.
n.

Advantage of OBs with Optimized Access:


• Optimized and thus fastest possible data access
sa

• Faster OB call since no 20 bytes temporary data are written,


• Start information can be queried as required.
ru
bo
@
sa
m
sa
ry

10-10 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Structurally Changed Data Block: "Download with Re-initialization"
10.4.5 Structurally Changed Data Block: "Download with Re-initialization"

.c
s an
Start value changed
and Structural change:

ru
DB downloaded Name
into CPU No change:
initialization

bo
Download DB in CPU
is only possible with
re-initialization

Initialization

Restart
carried out
@ of all tags
sa
Initialization
of non-retentive
tags
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Downloading Data Blocks with Re-initialization


ry

No matter whether a DB was created with non-optimized or optimized block access, a change of
start values is not a structural change. Therefore, it can be done and downloaded into the CPU
without a re-initialization of the data block variables (tags) being necessary.
After structural changes, on the other hand, it is only possible to download the data block by re-
initializing all tags.
Structural changes are:
• Name changes
• Changes of the retentive behavior
• Adding / removing variables (tags)
om

DB Re-initialization during Restart


No matter whether a DB is created with non-optimized or optimized block access, all monitor
c

values (actual values) of non-retentive tags are overwritten with their start values when the CPU
n.

is restarted.
sa
ru
bo
@
sa
m
sa
ry

10-11 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Principle: "Download without Re-initialization" Structurally Changed Data
10.4.6 Principle: "Download without Re-initialization" Structurally Changed Data Blocks
Blocks

.c
an
Downloading without re-initialization
retains actual values

s
ru
Block in Block Block in Block

bo
the project in CPU the project in CPU

Name Name Name Value


Name Value
Tag1 Tag1 Tag1 3.4
Tag1 3.4

@
Tag2 Activate memory Tag2 Tag2 451
Down- Tag2 451 Down-
Tag3 reserve “Keep Tag4
load in Tag3 23 load in Tag4 0
actual values” in
the Tag3 the
order to retain the Variable4
Tag3 23
0
CPU CPU
actual values Tag5
sa
Variable5
Tag5 00

Adjusting the tags Actual values


m

Block with memory Reserve requires


Private copy for Recep Yigit Samsa, rysamsa@borusan.com

within the of block are


reserve for down- more memory
framework of the retained
loading without space
sa

reserve area
re-initialization
ry

Download without Re-initialization


In order to make structural changes to data blocks or function blocks even while the system is
running, modified blocks can be downloaded into the CPU without switching the CPU to STOP
and without affecting the current online values in the CPU. The controlled system is not affected
by this "Download without re-initialization".

Functional Principle:
Basically, every function block and data block with the attribute "Optimized block access"
includes by default a memory reserve which can be used for changes made later on. All later
additionally declared tags are created in this memory reserve. During the subsequent download,
the values of already loaded tags are not affected.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

10-12 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Memory Reserve of Data Blocks
10.4.7 Memory Reserve of Data Blocks

.c
an
Memory reserve

s
only for
non-retentive

ru
tags (max. 2MB)

bo
Retentive tags
as well

@
sa
Memory reserve
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

only for
retentive tags
sa

Memory Reserve of Data Blocks


ry

The memory reserve for the "Download without reinitialization" can only be used...
• for data blocks with the attribute "Optimized block access"
• after an expansion of the data block with additional tags (not after deleting already existing
tags).
The "Download without reinitialization" of a data block that is to be expanded by non-retentive
tags, does not have to be explicitly activated (enabled). A memory reserve of 100 bytes is
always activated. This setting can be changed under "Options > Settings > PLC programming >
General > Download without reinitialization".
The "Download without reinitialization" of a data block that is to be expanded by retentive tags,
m
on the other hand, must be explicitly activated via "Enable download without reinitialization
(also) for retentive tags". As well, the memory reserve used for this "Retentive memory reserve"
co

must be explicitly set up.


n.
sa
ru
bo
@
sa
m
sa
ry

10-13 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Data Blocks "Download without Re-initialization"
10.4.8 Data Blocks "Download without Re-initialization"

.c
s an
ru
1

bo
2

Add tag(s)
Before change:
and download Activate memory reserve “Keep actual values”
DB into CPU

@
(enables download without having to re-initialize)
via (is not an action here, rather a Property of the DB!)
No
initialization
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Data Blocks "Download without Re-initialization"


ry

The "Download without reinitialization" of a data block can only be used if the data block has
been expanded by additional retentive and/or non-retentive tags and this expansion
corresponds with the created memory reserve.
The function cannot be used if already existing retentive and/or non-retentive tags were deleted
in the data block.

How to Proceed
Before adding tags, the "Keep actual values" icon must be pressed in the editor. That way, the
memory reserve is activated, allowing new tags to be inserted. The already existing tags can
then no longer be edited and new retentive and/or non-retentive tags can be additionally
om
declared.
The data block expanded in this way can now be downloaded into the CPU without
re-initialization via the "Download in CPU" icon or it can be downloaded from the Project tree.
.c
an
r us
bo
@
sa
m
sa
ry

10-14 SITRAIN
SIMATIC Programming 2 in the TIA Portal

Downloading
Downloadingwithout Re-initialization for Structurally Changed Function
without Re-initialization

om
Blocks
for Structurally Changed Function Blocks

.c
an
1

s
Before change:
Activate memory reserve “Keep actual values”

ru
(enables download without having to re-initialize)
(is not an action here, rather a Property of the IDB!)

bo
2

Add tag(s) and download


FB into CPU via
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Function Blocks "Download without Re-initialization


The "Download without reinitialization" of a function block can only be used if it has been
ry

expanded by additional retentive and/or non-retentive parameters and/or tags and this
expansion corresponds with the created memory reserve.
The function cannot be used if already existing retentive and/or non-retentive parameters and/or
tags were deleted in the function block.

Functional Principle
Basically, every function block and data block with the attribute "Optimized block access"
m
includes by default a memory reserve which can be used for changes made later on. All later
additionally declared tags and/or parameters are created in this memory reserve.
co

For structurally changed function blocks, the changes are automatically also updated in the
associated instance DBs. During a consistent "Download without reinitialization" of the
n.

expanded function block, the associated instance data blocks are also transferred through a
consistent "Download without reinitialization" into the CPU.
sa

In the blocks that call the affected function block, the FB calls are automatically updated. Even
these blocks that reference the function block are downloaded into the CPU during a consistent
ru

download of the expanded function block.


bo
@
sa
m
sa
ry

10-15 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Resetting the Memory Reserve

om
10.4.9 Resetting the Memory Reserve

.c
Before Compilation

s an
ru
bo
@ After Compilation
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Reset Memory Reserve


After a data block with the option "Reset memory reserve" is compiled, the tags created in the
ry

memory reserve are integrated in the regular part of the data block making the memory reserve
completely available once again.
The subsequent download of the data block into the CPU can then only be made with a re-
initialization of the tags.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

10-16 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
10.5 Task Description: Downloading structurally changed Data
Task Description:
blocks Downloading structurally changed Data blocks without re-
without re-initialization

.c
initialization

s an
ru
bo
Add tag "messageBits"

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task Description
ry

During running operation or in the CPU RUN state, S7-1500 allows the downloading of data
blocks into the CPU that were structurally changed or that were expanded by adding variables
(tags) without overwriting the monitoring values (actual values) of the originally already existing
variables. In this way the loading of program expansions when a system is running is made
possible without losing current system data in the process.
In this chapter, you are to become familiar with this "Downloading without re-initialization" of
structurally changed data blocks.
om
.c
an
r us
bo
@
sa
m
sa
ry

10-17 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
10.5.1 Exercise 1: Expanding a Data Block and Downloading it into the CPU without Re-
Exerciseinitialization
1: Expanding a Data Block and Downloading it into the CPU without
Re-initialization

.c
Before the expansion:

an
Activate memory reserve
"Keep actual values" 1
(is not an action, rather a

s
Property of the DB!)
2

ru
Add tag "messageBits"
and download DB into

bo
CPU

3
@
sa
Tags were not
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

re-initialized
m
sa

Task
You are to expand "DB_Weight" by adding a tag (variable) and then download it into the CPU
ry

without re-initialization.

What to Do
1. In the Properties of the "DB_Weight" data block, check whether the attribute "Optimized
block access" is activated and, if necessary, activate it.
2. In the "Download without reinitialization" submenu declare a memory reserve of 20 bytes.
3. Close the Properties dialog and download the changed data block into the CPU (this load
sequence is only possible with re-initialization).
4. Open "DB_Weight", start the monitoring function and transport some parts in Automatic
m
mode so that the actual quantity is greater than zero and some weight values are entered.
5. Press the icon "Keep actual values" in order to retain the actual values in the event of a
co

structural change.
6. Between the already existing variables "WeightStoreA" and "WeightStoreB" insert the new,
n.

additional variable NewValue of the data type REAL with a Start value of 3.14.
7. Download this expanded data block into the CPU and check whether the monitoring value
sa

of the DB variable "WeightStoreB.CurrQuant" and the weight values have been retained
even after the data block is downloaded.
ru

8. Also note that a reloading of the touchpanel configuration is not necessary even though the
absolute addresses of the variables in the data block have changed. The values are still
bo

displayed correctly because the touchpanel works with "symbolic access" when accessing
the DB variable.
9. Save your project.
@
sa
m
sa
ry

10-18 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 2: Resetting the Data Block Memory Reserve
10.5.2 Exercise 2: Resetting the Data Block Memory Reserve

.c
an
Before Compilation

s
ru
bo
@ After Compilation
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Task
ry

The variable that was created later on during the data block expansion is to be removed from
the memory reserve and integrated in the regular part of the data block. Then, the data block is
to be downloaded into the CPU with re-initialization.

What to Do
1. Open the Properties dialog of "DB_Weight" and check how many bytes of memory reserve
are still available (see picture upper right).
2. "Compile" the data block with the option "Software (reset memory reserve".
3. Open the Properties dialog of "DB_Weight" once more and check whether all bytes of the
memory reserve are once again available (see picture bottom right).
om
4. Download the data block into the CPU. Accept the message that this loading sequence is
only possible with re-initialization of the data block.
5. Save your project.
.c
an
r us
bo
@
sa
m
sa
ry

10-19 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Additional Exercise: OB "Startup" with optimized block Access
10.5.3 Additional Exercise: OB "Startup" with Optimized Block Access

om
.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task:
The "Startup" Startup-OB created in the Program-Design Methods chapter is to be changed in
ry

such a way that it works with optimized accesses.

What to Do:
1. Open the Properties of "Startup" and change the access type from non-optimized to
optimized block access in the "Attributes" menu.
2. Open "Startup"
3. Create the following temporary variables
om
4. Interface: Temp
tempRET_VAL datatype: INT
c

tempTOP_SI datatype: SI_classic


n.

tempSTARTUP_Si datatype: SI_none


5. Insert a new network before Network 1. (You may need to create a new network below and
a

then drag it above Network 1.)


us

6. Call the function "RD_SINFO". (Using drag & drop, copy from the “Instructions” Task card
under “Extended instructions > Diagnostics” or insert an "Empty box" and subsequently
enter RD_SINFO)
r
bo

7. Interconnect the formal parameters with the previously declared temporary variables.
8. Correct the two other networks by comparing the correct variables from the structure of
TOP_SI with the constants.
@

9. Compile, download, save, and test your project.


sa
m
sa
ry

10-20 SITRAIN
SIMATIC Programming 2 in the TIA Portal

10.6 Appendix

om
Data Block Control Instructions
10.6.1 Data Block Control Instructions

.c
s an
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m
sa

CREATE_DB
ry

...creates a new data block in the load and/or work memory.

READ_DBL
...copies a DB or a part of a DB, that is located in the load memory (Micro Memory Card), into
the data area of a destination DB in the work memory of the CPU.
m
WRT_DBL
co

...copies a DB or a part of a DB, that is located in the work memory of the CPU, into the data
area of a destination DB that is located in the load memory (Memory Card).
n.

ATTR_DB
sa

• ...supplies information about a data block (DB) located in the work memory of the CPU:
• DB unlinked / linked
ru

• DB write-protected yes/no
• DB retentive yes/no
bo

• DB in the load/work memory, both

DELETE_DB
@

...deletes a data block (DB) in the work memory that was created by user program with the
instruction "CREATE_DB".
sa
m
sa
ry

10-21 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
11 HMI Alarm Messages

.c
Learning objectives
11.1 Learning objectives

san
• You know the various alarm message procedures

ru
• You can create trigger or monitoring tags

bo
• You can configure discrete and analog alarm messages

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

c om
a n.
r us
bo
@
sa
m
sa
ry

11-1 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
11.2 Task Description: Configuring Discrete and Analog Alarm
Task Description:
Messages Configuring Discrete and Analog Alarm Messages

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Function Up Until Now:


ry

When Automatic Mode is switched on, the parts to be transported are weighed at the light
barrier bay and then transported to the next free bay.
If the weight of the part is not within the allowable range of 100kg to 400kg, it is displayed and
the part transportation cannot be started. (Part weight is set with slide control 1 on the operator
panel [simulator])
If none of the Bays 1 to 3 is free, part transportation can not be started.
If the current weight store is full, none of the bays can be enabled.

Task Description
m
You are to configure an alarm window in which the following messages are output:
co

• If the weight falls below the lower weight limit of 100kg, the alarm (message) "Weight too
low: <actual weight> kg" is to be output; if the upper weight limit of 400kg is exceeded the
alarm (message) "Weight too high: <actual weight> kg" is to be output.
n.

• If none of the Bays 1 to 3 is free, the alarm (message) "All bays occupied!!" is to be output.
sa

• If the weight storage cannot save any further part weights, the alarm (message) "Current
weight store full!!" is to be output.
ru
bo
@
sa
m
sa
ry

11-2 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Tasks
11.3of an Alarm
Tasks(Message) System(Message)
of an Alarm System

.c
an
Basic Task:
• Displaying alarms

s
ru
bo
Expanded Tasks:
• Reporting alarms through a printer
• Logging alarms in a file

@ • Logging alarms in a database

File
sa
Option (Sm@rt Service):
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

• Sending e-mails
m
sa

Tasks of an Alarm (Message) System


ry

Alarm messages are output depending on events or states that occur in the system or in the
process.
• Displays:
The alarms are displayed on the operator panel. This task is supported by every operator
panel.
• Reporting:
The alarms are output to a printer. This task is only supported by operator panels that also
support reporting (protocols).
• Logging:
m
The alarms are stored for further processing and analysis in a file (flash or hard drive).

co

Sending e-mails:
With the "Sm@rt Service" option package, it is possible to send the alarm message as an e-
mail by using the "SendEmail" system function.
n.
sa
ru
bo
@
sa
m
sa
ry

11-3 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Structure of an Alarm (Message)
11.4 Structure of an Alarm (Message)

om
Alarm class Alarm status Alarm text

.c
Name or identifier I: incoming with a max. 8
(can be O: outgoing displayable

an
configured) A: acknowledged process values

s
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Alarm number Alarm group


sa

Time stamp
within an alarm Date and for group
class time-of-day acknowledgement
m

(optional)
sa

Alarm Classes
ry

Each alarm is assigned to an alarm class that has specific properties. In addition to the following
standard alarm classes, you can also declare your own alarm classes.
• Diagnosis Events are generated by the controller and report diagnostic events with
standard texts (such as exceeding the measuring range of an analog input module)
• System Alarms are alarms with standard texts that are output by the operator panel (such
as, connection setup to the controller …)
m
• Error Alarms must always be acknowledged and can be freely configured by the user. That
co
is, you define the alarm event (→ discrete or analog alarms) as well as the alarm text.
• Warnings do not have to be acknowledged and like error alarms can be freely configured
n.

by you.
sa

Alarm Statuses
The following alarm statuses exist:
ru

• Alarm statuses that do not need to be acknowledged:


– I: incoming
bo

– IO: incoming and outgoing


• Alarm statuses that must be acknowledged:
@

– I: incoming
– IA: incoming, still existing (pending) and already acknowledged
– IO: incoming, outgoing, but not yet acknowledged
sa

– IOA: incoming, outgoing and later acknowledged


– IAO: incoming, acknowledged and outgoing
m
sa
ry

11-4 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Alarm Classes

om
11.4.1 Alarm Classes
Predefined alarm classes
• Diagnosis events

.c
→ Error/diagnostic alarms of the controller
→ Are generated by the connected controller

an
• System
→ Status alarm messages of the operator panel
→ Are generated by the operator panel

s
• Errors (for unrestricted use)

ru
→ For discrete and analog alarms that have to be acknowledged
• Warnings (for unrestricted use)

bo
→ For discrete and analog alarms that do not have to be acknowledged

@ Display name Ackn. requirement Log assignment


sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

User may define new alarm classes


sa

Alarm Classes
Each alarm must be assigned to an alarm class. Alarm classes primarily define the need for
ry

acknowledgement and the appearance of alarms in the display on the operator panel. Beyond
that, they are used to group alarm messages for different forms of representation.
WinCC offers predefined alarm classes as well as the opportunity to configure your own alarm
classes.
Predefined alarm classes "Errors" and "Warnings" for unrestricted use
• Errors
for discrete and analog alarms that indicate critical or dangerous operating and process
statuses.
m
Alarms of this alarm class must always be acknowledged.

co

Warnings
for discrete and analog alarms that indicate regular operating statuses, process statuses,
and process sequences.
n.

Alarms of this alarm class are operator information and do not have to be acknowledged.
sa

Display Name
Here, an individual name can be set for each alarm class that can then also be displayed in the
ru

alarm display when several alarm classes are represented in an alarm display. These display
names can also be individually adjusted for the predefined alarm classes.
bo

Acknowledgement Concept
The need to acknowledge an alarm depends on whether the alarm class to which the alarm was
@

assigned is required to be acknowledged.


The operator acknowledges an alarm on the operator panel by pressing the relevant
acknowledgement button.
sa
m
sa
ry

11-5 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Alarm (Message) Procedures
11.5 Alarm (Message) Procedures

.c
s an
Discrete alarm procedure
Alarm numbers procedure

ru
Analog alarm procedure

bo
Operator panel Controller
cyclically polls sends
alarm telegram

@
the relevant data in
the CPU
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

Alarm Procedures
WinCC flexible supports the following alarm procedures:
• Discrete Alarm Procedure:
The operator panel displays an alarm if a certain bit of a so-called trigger tag is set in the
controller. For this, the operator panel must read out the trigger tag cyclically from the S7
controller.
• Analog Alarm Procedure:
The operator panel displays an alarm if a certain tag exceeds a specified upper limit value or
m
falls below a specified lower limit value. For this, the operator panel must read out the tag
cyclically from the S7 controller.
co

• Alarm Number Procedure:


The operator panel displays an alarm if the controller sends an alarm telegram to the operator
n.

panel. For this, the Program_Alarm block must be programmed or a ProDiag monitoring must
be configured in the S7 program.
sa

Advantages:
– the alarms are displayed in exactly the same sequence as they actually occur in the
ru

process

bo

the alarms have a CPU time stamp and not an operator panel time stamp
– reduced bus load because communication only takes place in case of an alarm
– no alarms are lost
@
sa
m
sa
ry

11-6 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Configuring Discrete Alarms
11.5.1 Configuring Discrete Alarms

om
.c
s an
ru
bo
HMI tag PLC tag

@
Display text
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Discrete Alarms
sa

A discrete alarm is triggered when a defined bit of a tag changes its state from 0 to 1 (rising
edge).
ry

ID
Freely selectable alarm number that is also displayed in the alarm display

Alarm Text
The alarm text can be a maximum of 254 characters long and can be formatted character by
om
character. Tag values and/or texts from text lists can be displayed (inserted) in the alarm text.
The current value of the tag used is updated when an alarm occurs.
It is possible to display (insert) the value of a tag in the alarm text via "Insert tag field…".
c
n.

Trigger Tags
The trigger tag is the tag whose bits are monitored for rising edges. Each alarm is assigned to a
a

specific bit of this tag.


us

• Data type of Trigger Tags


The trigger tag must be of the data type WORD, DWORD, INT, or DINT.
r

• Acquisition mode: Cyclic continuous


bo

means that these tags are constantly updated or read-in the background, not only as
required ("Cyclic in operation").
@
sa
m
sa
ry

11-7 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Configuring Analog Alarms
Configuring Analog Alarms

.c
s an
ru
bo
@ Display text
Displayed (inserted) HMI tag value
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Analog Alarms
ry

An analog alarm is triggered when the value of a specific tag exceeds or falls below a limit.

Alarm Text
The alarm text can be a maximum of 254 characters long and can be formatted character by
character. Tag values and/or texts from text lists can be displayed (inserted) in the alarm text.
The current value of the tag used is updated when an alarm occurs.
It is possible to display (insert) the value of a tag in the alarm text via "Insert tag field…".

Trigger Tag
The trigger tag is the tag whose value is monitored. Each alarm is assigned to a specific tag
om
with a specific limit and whether the tag value must exceed or fall below this limit.

Limit
c

The limit for which the trigger tag is monitored can be specified as a constant or, in turn, via a
n.

tag whose data type must match that of the trigger tag.
sa

Dead Zone
When a process value swings around the limit, the associated alarm for this fault is triggered
ru

several times. To prevent this, a dead zone can be configured.


bo
@
sa
m
sa
ry

11-8 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Displaying Alarm (Messages)
11.5.2 Displaying Alarm (Messages)

om
• Alarm View
- Alarms from the alarm buffer or log

.c
- Can be configured in every screen

an
- Only visible when the relevant
screen is open

s
ru
• Alarm Window

bo
- Alarms from the alarm buffer
- Can only be configured
in "Global screen" @
- Window appears when a
corresponding alarm occurs
- In addition, the
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

alarm indicator
can be configured
m

Alarm View
sa

Several alarm views can be configured for different alarm classes and in various screens or
various windows. The alarm view is only visible when the relevant screen is called.
ry

• Display of currently pending alarms or alarms from the alarm buffer or alarm log
• Alarm selection according to alarm class
• Can be configured in every screen
• Is only visible when the relevant screen is open
om
• Selectable display type: Table | Line

Alarm Window
c

The alarm window can only be configured in the screen "Global screen". Just as with the alarm
n.

view you can select the classes to be displayed. In all other screens, you can select whether or
not the alarm window is to appear when an alarm "comes".
a

• Display of currently pending alarms or alarms from the alarm buffer or alarm log
us

• Alarm selection according to alarm class


• Can only be configured in the screen "Global screen"
r


bo

Window can automatically appear when a new entry is made in the window (for example, a
new alarm has come).

Alarm Indicator
@

Just like the alarm window, the alarm indicator can only be configured in the "Global screen". It
is a graphic symbol that points to pending or unacknowledged alarms in all screens, depending
sa

on the configuration. With the help of the alarm indicator, a defined alarm window can be
shown.
m
sa
ry

11-9 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
11.6 Task Description:
Task Description: Configuring Discrete and Analog Alarm Messages
Configuring Discrete and Analog Alarm Messages

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

Task Description
You are to configure an alarm window in which the following messages are output:
• If the weight falls below the lower weight limit of 100kg, the alarm (message) "Weight too
low: <actual weight> kg" is to be output
• If the upper weight limit of 400kg is exceeded the alarm (message) "Weight too high:
<actual weight> kg" is to be output.
• If none of the Bays 1 to 3 is free, the alarm (message) "All bays occupied!!" is to be output.
• If the weight storage cannot save any further part weights, the alarm (message) "Current
m
weight store full!!" is to be output.
co
n.
sa
ru
bo
@
sa
m
sa
ry

11-10 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 1:
11.6.1 Configuring
Exercise a Discrete Alarm
1: Configuring a discrete Alarm

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

You are to configure the discrete alarms shown in the lower right picture. Later, they will be
displayed in an alarm window.
ry

What to Do
1. Expand "DB_Conveyor" by adding the tag MessageBits [data type WORD]
2. Configure the required discrete alarms (see picture) of the alarm class "Warnings". Declare
the new DB variable "DB_Conveyor". MessageBits as the trigger tag.
Select the "trigger bits" as follows:
Trigger bit 0 ("DB_Conveyor". MessageBits.X0) for the message "Weight store full !!"
Trigger bit 4 ("DB_Conveyor". MessageBits.X4) for the message "All bays occupied !!"
om
3. In "FB_Signal", create a new Output parameter #MessageBits [data type WORD].
4. Program the management of bits 0 and 4 of the new Output parameter:
c

As long as all bays are occupied, the Output parameter bit #MessageBits.%X4 must be
assigned Status '1'.
n.

The status of the Input parameter #StoreFull must be assigned to the Output parameter bit
sa

#MessageBits.%X 0.
ru
bo
@

5. In "OB_Cycle", update the call of "FB_Signal" and assign "DB_Conveyor".MessageBits. to


the the new formal parameter #MessageBits.
6. Save your project.
sa
m
sa
ry

11-11 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 2: Configuring an Analog Alarm
11.6.2 Exercise 2: Configuring an Analog Alarm

.c
s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

Task
The analog alarms "Weight too low: <DB_Conveyor_Weight>" or "Weight too high:
<DB_Conveyor_Weight>" shown in the picture are to be displayed when the weight currently
set on the slide control "S_Slider1" is less than 100 or greater than 400kg.

What to Do
1. Configure the required analog alarms as alarms of the alarm class "Error" with the texts
shown in the picture and as "dynamic parameter" ["Insert tag field…"] insert the variable
DB_Conveyor_Weight into the text in each case (see picture).
2. In both alarms, define the variable "DB_Conveyor_Weight" as the trigger tag.
3. Define the limits as shown in the picture and define the limit mode – higher or lower, as
m
necessary.
co

4. Save your project.


n.
sa
ru
bo
@
sa
m
sa
ry

11-12 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 3: Configuring a New Alarm Window
11.6.3 Exercise 3: Configuring a New Alarm Window

om
.c
s an
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

Task
sa

Now that you have configured 2 discrete and 2 analog alarms, you now still have to configure
where these alarms are to be displayed. This is to happen in an alarm window that – as soon as
ry

one of the alarms is pending – is displayed on every touchpanel screen. In addition, all system
alarm messages are also to be displayed in this alarm window.

What to Do
1. In the "Screen management", open the "Global screen".
2. There, configure an alarm window and, in its properties, define that the pending alarms of
m
the alarm classes "Errors", Warnings", and "System" are to be displayed.
co
3. Check in the properties of the alarm window whether the function "display automatically" is
activated in the menu item Window > Settings.
n.

4. Compile and download the modified program into the touch panel.
5. Compile and download all modified S7 blocks into the CPU.
sa

6. Check whether the alarms are displayed as required.


7. Save your project.
ru
bo
@
sa
m
sa
ry

11-13 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Additional Exercise: HMI Device Time Synchronization with the CPU
11.6.4 Additional Exercise: HMI Device Time Synchronization with the CPU

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
ry

The current date and time synchronized with the CPU is to be displayed at the upper-right edge
of every touchpanel screen.

What to Do
1. Open the "Connections" of the touchpanel and there select the mode "Slave" under "HMI
time synchronization mode". With this, the touch panel synchronizes its own time with that
of the CPU.
2. In the "Screen management" in the screen "Template_1" configure a Date/Time output field.
3. Download the modified configuration into the touchpanel and check the function.
m
4. Save your project.
co
n.

Note
sa

So that the times match, the daylight saving time must be switched on or switched off for both
devices and the same time zones must be set. This is done in the CPU at (Properties > Time of
ru

day), and in the touch panel at (Settings > Date/Time).


bo
@
sa
m
sa
ry

11-14 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
12 System Diagnostics and Error Handling

.c
an
Learning objectives
12.1 Learning objectives

s
ru
• You know the function of system diagnostics

• You know how to configure the function CPU system diagnostics

bo
• You know how to use the CPU web server for diagnostics

• You know how to program diagnostic functions in the S7 program

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

om
.c
an
r us
bo
@
sa
m
sa
ry

12-1 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
12.2 Task Description:
Task Description: Displaying an I/O-Device Failure on the Touchpanel
Displaying an I/O-Device failure on the touch panel

.c
s an
"LOG2GEO" &
"DeviceStates"

ru
bo
@
sa
CPU system
diagnostics
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

Task Description
In the touch panel menu under "Diagnostics", it should be possible to call the status and the
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 displayed on the "Conveyor" screen stating the station and module number.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

12-2 SITRAIN
SIMATIC Programming 2 in the TIA Portal

Functional
12.3 Principle of the
Functional CPU System
Principle ofDiagnostics
the CPU System Diagnostics

om
CPU diagnostics detects CPU I/O module

.c
a system error
Diagnostic Diagnostics-

an
CPU diagnostics detects
errors in the user program interrupt capable module
detects an
error and

s
generates a

ru
diagnostic
Error Diagnostic interrupt
OB buffer

bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

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
sa

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
ry

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
m
The operating system does not analyze whether the error handling (programmed error OB)
really solves the triggering error. For that reason, particular care has to be taken when
co

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

function "STP". (Task Card Instructions → Basic Instructions → Program control… → Runtime
control).
sa
ru
bo
@
sa
m
sa
ry

12-3 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
12.4 Diagnostics – Possibilities in the event of a module Failure or
Diagnostics – Possibilities in the Event of a Module Failure or Error
Error

.c
an
Diagnostic possibilities System diagnostics
Web Service
of the CPU

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

Start info Start info Start info


"Diagnostic "Pull or plug "Rack or

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

Extended instructions -> Diagnostics/Addressing


Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Get_IM_Data DeviceStates
sa

Get_Name ModuleStates

LOG2GEO GEO2LOG
ry

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 OB with the Start event "Diagnostic error interrupt"
is called if the module is diagnostics-capable and the diagnostic interrupt is also activated in the
m
hardware configuration. The HW_ID of the defective module is then stored in the start
information of the OB.
co

OB83 (Pull or plug of modules)


If a configured module is removed or inserted, the OB with the Start event "Pull or plug of
n.

modules" is called. The HW_ID of the failed or recovered module is then stored in the start
information of the OB.
sa

OB86 (Rack or station failure)


ru

When a distributed I/O module fails or recovers, the OB with the Start event "Rack or station
failure" is called. The HW_ID of the failed or recovered module is then stored in the start
information of the OB.
bo

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

Web Service
All PROFINET-capable S7-CPUs provide a web presence for diagnostics which can be
m

accessed through a commercially available web browser (such as Internet Explorer, Mozilla
Firefox, or Opera). These HTML pages offer access to device status and tags and enables the
sa

execution of device functions.


ry

12-4 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Diagnostics
12.5 using the PG with
Diagnostics usingSTEP 7 PG with STEP 7
the

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Diagnostics Buffer
In the picture you can see an error message for an IO Device module that has failed or been
ry

removed. In this case, the digital output module in Slot 2 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.
c om
n.
sa
ru
bo
@
sa
m
sa
ry

12-5 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
CPU System CPU
12.6 Diagnostics
System Diagnostics

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

System Diagnostics
ry

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.
om
Advantages
Compared to the frequently used discrete alarm procedure, the system diagnostics offers the
following advantages:
c

• The system diagnostics is an active alarm procedure. If an alarm occurs, the CPU actively
n.

sends an appropriate message to all connected operator panels and doesn’t wait until the
operator panels make inquiries.
sa

• The process values always coincide exactly with the values at the time of the alarm. This is
not guaranteed in the discrete alarm procedure.
ru

• The timestamp specifies exactly when an event occurs, even when the operator panel is
only connected later on.
bo
@
sa
m
sa
ry

12-6 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
CPU System Diagnostics: Functional Principle
12.6.1 CPU System Diagnostics: Functional Principle

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

CPU System Diagnostics


The CPU system diagnostics is integrated in the firmware of the S7-1500 CPU 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 this to the CPU with an interrupt signal.
2. Detected faults are immediately signaled to the higher-level HMI devices, the Web server,
and the S7-1500 CPU Display. In that way, the system diagnostics is always consistent with
the actual system state.
om
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.
c
n.
sa
ru
bo
@
sa
m
sa
ry

12-7 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Activating CPU System Diagnostics

om
12.6.2 Activating CPU System Diagnostics

.c
san
ru
bo
The output of individual alarm
categories can be activated or
deactivated in the System
@ Always active

diagnostic settings.
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

CPU System Diagnostics


The system diagnostics is always activated and cannot be deactivated.
sa

Alarm settings
ry

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.
c om
a n.
r us
bo
@
sa
m
sa
ry

12-8 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
12.6.3
Displaying Displaying
System System
Diagnostics Diagnostics
Alarms on theAlarms on the HMI
HMI Device Device with "System
with
Diagnostics
"System Diagnostics View" View"

.c
s an
ru
bo
@ Start page
sa
System diagnostics view
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Diagnostic buffer of the CPU

Module status Level lower/back


ry

→ 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.
om
• Higher-level components (for example, PN interface)
→ subordinate components/modules are displayed
• Diagnostics buffer or module without subordinate components
.c

→ Details view of the Diagnostics buffer entry or the module is displayed


an

Splitting the View in the System Diagnostics View


The system diagnostics view also offers a split view of the display. In that way, associated
us

details can immediately be seen in the lower area of the display.


r
bo
@
sa
m
sa
ry

12-9 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Diagnostics with the CPU Web Server

om
12.7 Diagnostics with the CPU Web Server

.c
Internet

s an
• Standard HTML pages of the module can be

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

bo
• Enable the accessing of
- Device status
@
- Diagnostic information
- Variable (tag) values
- etc.
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

• Provide the execution of


some device functions
m

• With operator panels,


sa

activation of remote
maintenance possible
ry

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, 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
om
create your own HTML pages.

Security
c

Please bear in mind that you must protect the CPU against compromise through various
n.

techniques, for example, through network access limitations and the use of firewalls.
The web server offers the following security features:
a

• Access via the secure transmission protocol HTTPS


us

• Configurable user authorizations via user lists


r
bo
@
sa
m
sa
ry

12-10 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Accessing the CPU Web Server
12.7.1 Accessing the CPU Web Server

om
.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

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)
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

12-11 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Web Server: "Start Page"
12.7.2 Web Server: "Start Page"

.c
s an
ru
User administration

bo
Select the
display language

@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

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.
m
Setting the Project Languages that are downloaded to the CPU:
co
n.
sa
ru
bo

Maximum of
three different
project
languages
@
sa
m
sa
ry

12-12 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Web Server:
12.7.3 Web"Diagnostic Buffer"
Server: "Diagnostic Buffer"

.c
s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Among other things, the entries of the diagnostic buffer can be read out with the help of the
ry

Web server.
Furthermore, as can be seen in the picture, access to diverse diagnostics, the module
information, alarms, communication, the topology, 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.

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

12-13 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Parameterizing
12.7.4 the CPU Web
Parameterizing the Server
CPU Web Server

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Web Server Activation


sa

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

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.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

12-14 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise12.7.5 Exercise 1 (CLASSROOM):
1 (CLASSROOM): Displaying
Displaying System System Diagnostics
Diagnostics Alarms onAlarms
the CPU-
Display on the CPU-Display

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

s
ru
bo
Main menu item:

@ Diagnostics
Display diagnostic buffer
Display CPU alarms
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

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
om
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
c

out straight and must also be reinserted straight. Tilting damages them.
n.

3. On the CPU, select the menu item "Diagnostics"


sa

With the cursor keys and select the menu item "Diagnostics" and confirm the
selection with the OK button.
4. Look at the alarm message
ru

With the cursor keys and select the menu item "Alarms".
bo

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

A maximum of 3 languages can be selected and can be assigned to the available interface
languages for CPU-Display and Web Server.
m
sa
ry

12-15 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 2 (CLASSROOM): Displaying System Diagnostics Alarms in STEP 7
12.7.6 Exercise 2 (CLASSROOM): Displaying System Diagnostics Alarms in STEP 7

.c
s an
ru
Activate

bo
Inspector
window @Change device
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
ry

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
om
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.
.c

4. Terminate the online connection. .


an
r us
bo
@
sa
m
sa
ry

12-16 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 3Exercise
12.7.7 (CLASSROOM): Viewing System
3 (CLASSROOM): Diagnostics
Viewing System on the HMI Device
Diagnostics on the HMI Device

om
.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

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
sa

with the Control "System-diagnostics" which is prepared for this.


ry

What to Do
1. Open the screen "03_Diagnostics" (Touchpanel > Screens > Application > 01_Template)
2. There, configure a "System diagnostics view" using drag & drop (see picture)
3. Download the modified configuration into the touchpanel.
4. Open the Diagnostics on the touchpanel via the menu
5. Check the new function by provoking an IO-Device error by pulling and reinserting an
m
ET 200SP module or by switching off the ET 200SP.
co

6. Save your project.


n.
sa
ru
bo
@
sa
m
sa
ry

12-17 SITRAIN
SIMATIC Programming 2 in the TIA Portal
ExerciseExercise
12.7.8 4 (CLASSROOM): Activating and
4 (CLASSROOM): Parameterizing
Activating the Web Serverthe Web Server
and Parameterizing

om
.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task:
m

The CPU Web server is to be activated and set up so that it can be used.
sa

What to Do
ry

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.
m
6. Under the item Watch tables, select the already existing watch table "Conveyor" and
activate the Read/Write access
co

7. Save, compile, and download the modified hardware configuration.


8. Test the changes by calling the CPU Web server on the Field-PG using an Internet browser.
n.
sa
ru
bo
@
sa
m
sa
ry

12-18 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 1 (ONLINE): Displaying System Diagnostics Alarms in STEP 7
12.7.9 Exercise 1 (ONLINE): Displaying System Diagnostics Alarms in STEP 7

om
.c
s an
Activate

ru
bo
Inspector window
@
Change device
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m
sa
ry

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 m
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
co

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

ET 200SP-DI module or by switching off the ET 200SP. For that use the Project view in
PLCSIM and create a event "Pull or plug of modules" in an event table.
sa
ru
bo
@
sa

4. The alarm display occurs in the Inspector window in the "Diagnostics"/"Alarm display" tabs
in TIA Portal.
m

5. Terminate the online connection. .


sa
ry

12-19 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
ExerciseExercise
12.7.10 2 (ONLINE): Viewing System
2 (ONLINE): Diagnostics
Viewing on the HMI Device
System Diagnostics on the HMI Device

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task: Displaying and Viewing System Diagnostics on the HMI Device


sa

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

What to Do
1. Open the screen "03_Diagnostics" (Touchpanel > Screens > Application > 01_Template)
2. There, configure a "System diagnostics view" using drag & drop (see picture)
3. Download the modified configuration into the touchpanel.
4. Open the Diagnostics on the touchpanel via the menu
5. Check the new function by provoking an IO-Device error by pulling and reinserting an
ET 200SP module or by switching off the ET 200SP (as in exercise 1).
6. Save your project.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

12-20 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Diagnostics using the S7 Program

om
12.8 Diagnostics using the S7 Program

.c
CPU detects an error

an
SF

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

ru
bo
Asynchronous error Synchronous error
e.g.: “Rack or station failure” e.g.: “Programming error”

@
Start information

Error OB is executed twice:


Start information

Error OB is executed as often as


sa
the error occurs.
1. Error occurs (incoming event)
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

2. Error goes (outgoing event)


m
sa

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


which also contains a description of the error
ry

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
om
Asynchronous errors occur regardless of the program execution and accordingly cannot be
traced to a defined point in the program:
• for example, module failure
c


n.

for example, I/O fault (exceeding the measuring range, wire break)
These OBs are executed exactly twice:
a

1. When the error occurs (with start information that contains the identifier "incoming")
us

2. When the error goes (with start information that contains the identifier "outgoing")
r

Synchronous Errors
bo

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
sa

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.
m
sa
ry

12-21 SITRAIN
SIMATIC Programming 2 in the TIA Portal

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

.c
Byte

an
0/1 Event class and ID Error code Management
information
Structure of the 2/3 Priority class OB No.

s
information read out with
"RD_SINFO"

ru
4/5 Error info (such as, block type in which the error occurred)
when
actual parameters are of 6/7 Error info (such as, address at which the error occurred)

bo
the data type Error
"SI_Classic" information
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
sa
14 / 15 Day Hours
Start
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

time
16 / 17 Minutes Seconds
m

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


sa

Start Information
ry

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
om
beforehand. The access to the variables can be symbolic or absolute. Symbolic access is
recommended for reasons of program readability and the avoidance of addressing errors.
.c

Notes
an

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
us

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
r

be declared at the end, after the standard variables.


bo

An explanation of the meanings of the individual variables can be found in the Help of the
respective organization block.
@
sa
m
sa
ry

12-22 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Start Information
12.8.2 of the OB Rack
Start Information of theFailure
OB Rack Failure

.c
an
Event class
and Identifier

s
Error code

ru
Which module

bo
@ RD_SINFO

For reading out the


complete Start
information
sa
For the precise meaning of the start information of individual organization blocks, please see the Help
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Global Error Handling


with Asynchronous Error OBs
sa

Just as with the call of Startup OBs, with the call of a "Rack or Station failure" OB, the user is
provided with start information by the system. This can be used during programming in order to
ry

determine what the cause for the call of the OB is.


In this way, different reactions can be made to various causes.
This most important information is also passed to an optimized OB

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

12-23 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Global Error Handling with Asynchronous Error OBs
12.8.3 Global Error Handling with asynchronous Error OBs

.c
an
Type of Error Example Error OB Priority

Time Error:

s
Max. allowed cycle time
exceeded once Exceeding the

ru
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

bo
Max. allowed cycle time of a time OB
exceeded by more than double
System reaction with OB: STOP
"Diagnostic

@
Diagnostic Interrupt Wire break at diagnostics-capable 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
sa
S7-1200/1500:
Remove / Insert a module of modules"
System reaction w/o OB: RUN (OB83) Can be set: 2 to 26
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

"Rack or
m

Rack Failure Failure of a DP-Slave S7-1200/1500:


RUN station failure"
System reaction w/o OB: or an IO-Device (OB86) Can be set: 2 to 26
sa

All events lead to an entry in the diagnostics buffer!


ry

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

Time Error Interrupt


This interrup occurs when the current cycle time exceeds the cycle monitoring time set in the
device configuration.

Diagnostic Error Interrupt


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

Pull or Plug of modules


These interrupts are triggered when modules are removed or inserted. When a module is
an

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

Rack or station Failure


This failure is detected when a rack, a subnet, or a station on the network fails
r
bo
@
sa
m
sa
ry

12-24 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Determining
12.8.4 the Geographic
Determining Address using
the Geographic "LOG2GEO"
Address using "LOG2GEO"

.c
an
Address of the module that lead

s
to the call of the error OB

ru
System data type "GEOADDR"

bo
(Structure of the geographic address)

@
sa
INOUT parameter
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

With the "LOG2GEO" instruction, you can determine the geographic address, that is, the
ry

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).
m
Structure of the Data Type "GEOADDR"
co

HWTYPE: 1 = IO-System (PROFINET/PROFIBUS),


2 = IO-Device / DP-Slave
n.

3 = rack,
4 = module and
sa

5 = submodule
AREA: 0 = central module;
ru

1 = PROFINET IO;
2 = PROFIBUS DP and
bo

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
sa

SUBSLOT: Number of the submodule. (If no submodule exists or can be inserted, this
parameter has the value "0".)
m
sa
ry

12-25 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
"DeviceStates": Reading the Module Status Information in an IO-System
12.8.5 "DeviceStates": Reading the Module Status Information in an IO-System

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

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

BOOL or ARRAY [0..n]


of BOOL
ry

The "DeviceStates" instruction 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
m
Through the parameter MODE you can select which status information is to be read.
co

• 1: IO-Devices/DP-Slaves are configured


• 2: IO-Devices/DP-Slaves faulty
n.

• 3: IO-Devices/DP-Slaves deactivated

sa

4: IO-Devices/DP-Slaves exist
• 5: IO-Devices/DP-Slaves, in which a problem has occurred (such as, "Maintenance
necessary")
ru

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


bo

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-
sa

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
m

(see Properties of the DP-Slave in the Device view and Network view)
sa
ry

12-26 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Global Handling of Synchronous Errors with Error OBs: Principle

om
12.8.6 Global Handling of Synchronous Errors with Error OBs: Principle

.c
Block

an
OB1 with
program Error
error OB

s
ru
bo
Type of Error Example OB Priority

"Programming

Programming error @ A non-existent Array element


is indirectly accessed in
the program
error"
(OB121)
(only S7-1500)
According to
the OB
sa
that was
interrupted by
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

A defective or non-existent "IO access


error" the error
I/O module is directly
m

Access error accessed in the program (OB122)


(only S7-1500)
sa

Synchronous Errors
ry

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.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

12-27 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Global Error Handling of Synchronous Errors with Error OBs: CPU Behavior
12.8.7 Global Error Handling of Synchronous Errors with Error OBs: CPU Behavior

.c
an
Type of Error Example OB Priority

S7-1200

s
Programming error Access to non-existing DB no OB

ru
Access error Direct access to non-existing exists
System reaction w/o OB: RUN or defective I/O module

bo
"Programming
Programming error error"
Access to non-existing DB
System reaction w/o OB: STOP

S7-1500 @ (OB121)
Can be set:
2 to 26
sa
"IO access
Access error Direct access to non-existing error"
System reaction w/o OB: RUN or defective I/O module
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

(OB122)
m
sa

All errors lead to an entry in the diagnostic buffer!


ry

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.
om
.c
an
r us
bo
@
sa
m
sa
ry

12-28 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Local Handling
12.8.8 Local of Synchronous
Handling Errors
of Synchronous Errors

om
.c
Error in the
OB / FC / FB
block

an
OB 121
GET_ OB 122
ERROR

GET_ERROR or no OB call, no entry

s
GET_ERR_ID programmed in diagnostic buffer

ru
in the block

bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

If the "Handle errors within block" attribute is selected, and this block is integrated in another
program, the adjustment of already existing error OBs is not necessary. Thus the "local error
handling" contributes to designing the block as re-usable.
ry

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
m
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.
co

Furthermore, the call of the associated error OB (OB121 or OB122) and an entry in the
diagnostic buffer are suppressed.
n.

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
sa

associated error OB (OB121 or OB122) and an entry in the diagnostic buffer is suppressed.

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


ru

• With the help of the error information, a reaction to the error that occurred can be
programmed in the program block.
bo

• 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.
sa
m
sa
ry

12-29 SITRAIN
SIMATIC Programming 2 in the TIA Portal

Task Description
12.9 (ONLINE): Displaying
Task Description: an IO-Device
Displaying anError
IO-Device Error

om
.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task Description
m

As soon as an IO-Device has failed or an error has occurred on the IO-Device, the message
sa

shown in the picture – with the device number of the IO-Device concerned and the slot number
of the module concerned – is to appear on the touchpanel screen "Conveyor".
ry

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 'TRUE' to the tag
(variable) "InterfaceTP".IODeviceError for as long as the message is to be displayed, which
assigns the device number of the station concerned to the tag (variable)
"InterfaceTP".IODeviceNo and which assigns the slot number of the module concerned to the
tag (variable) "InterfaceTP".DeviceSlotNo.
Then, the error time/downtime of the modules or the IO-Device is to be determined.
c om
a n.
r us
bo
@
sa
m
sa
ry

12-30 SITRAIN
SIMATIC Programming 2 in the TIA Portal
ExerciseExercise
12.9.1 5 (ONLINE): Displaying an
3: Displaying anIO-Device
IO-DeviceError
Error

om
.c
an
Start information

s
of the OB

ru
Temp variable
data type "GEOADDR"

bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Task
m

You are to create an S7 program which, when there is a station error/failure or during
pulling/plugging, assigns status 'TRUE' to the tag (variable) "InterfaceTP".IODeviceError, which
sa

assigns the device number of the station concerned to the tag (variable)
"InterfaceTP".IODeviceNo and which, when there is a module failure, assigns the slot number of
ry

the module concerned to the tag (variable) "InterfaceTP".DeviceSlotNo.


Note: The text with station and slot number (see picture on the previous page) displayed on the
touchpanel screen "Conveyor" is already configured and is displayed as long as the tag
(variable) "InterfaceTP".IODeviceError has status 'TRUE'.

What to Do
m
1. Create a new OB of the type "Pull or plug of modules",
2. In this newly created OB, program the required functions,
co

3. Use the input variable #Event_Class for determining whether the module has failed or was
re-inserted,
n.

4. Create the temporary variables #tempAddress [GEOADDR] and #tempRetVal [WORD]


sa

5. With the help of the instruction "LOG2GEO", determine the geographic address of the
module that causes the OB to be called,
6. Read-out the values of the station number and module number from the structure of
ru

#tempAddress and write these in the tags (variables) "DB_OP".IODeviceNo and


"DB_OP".DeviceSlotNo
bo

7. Create a new OB of the type "Rack or station failure" (IO_Device failure).


8. Also program the required functions in it.
Note: Since this OB is called when a station fails, the module number is always '0'.
@

9. Download all program changes into the CPU.


sa

10. Check the functions.


Caution: once again, when you pull and insert the modules make sure you do not
damage them.
m

10. Check the functions.


sa

For that use the Project view in PLCSIM and create a event "Pull or plug of modules" in an
event table just as in exercise 1.
ry

11. Save your project.

12-31 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
ExerciseExercise
12.9.2 6 (ONLINE): Determining the
4: Determining theError
ErrorTime/Downtime
Time/Downtime

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

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

What to Do
1. In the “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.
om

Solution Hints:
In order to recognize whether the error or the failure occurs or is eliminated, use the appropriate
c

Input parameter in optimized OBs or, for non-optimized OBs, the appropriate Start information in
n.

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
sa

"Extended instruction" "RD_SYS_T" or "RD_LOC_T" and for calculating how long the slave
downtime is, the instruction "T_DIFF".
ru
bo
@
sa
m
sa
ry

12-32 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Additional
12.9.3 Exercise (ONLINE):
Additional Exercise:Integrating
IntegrationLocal
LocalError Handling
Error Handling

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

In OB "CyclicInterrupt Weight", 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.
ry

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: local error handling)
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.
m
Exercise is continued on the next page
co
n.
sa
ru
bo
@
sa
m
sa
ry

12-33 SITRAIN
SIMATIC Programming 2 in the TIA Portal

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


om
Select your S7-1500 station
– Go Online
– Start "Online & diagnostics"

.c
– There, select the diagnostic buffer in the "Diagnostics" tab.

san
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m
sa
ry

5. In OB "CyclicInterrupt Weight", 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.
m
7. The CPU should now stay in RUN in spite of programming errors. Open OB "CyclicInterrupt
Weight" and activate the function "Monitor block".
co

8. At the Output ID of the instruction, an Error-ID is output. Read about its meaning in the
online help (select instruction -> F1).
n.

Optional - Local Error Handling with "GET_ERROR":


sa

1. In a global data block create a new variable with the name "getError" [ErrorStruct]
2. Replace the instruction "GET_ERR_ID" with the instruction "GET_ERROR" and supply the
ru

formal parameter "ERROR" with the new variable.


3. Download the change into the controller,
bo

4. Evaluate the error information. Use the help for more information.

Correcting the Project


@

1. Delete the access to the non-existing data block and once again specify the correct actual
parameter.
sa

2. Compile, download, and save your project.


m
sa
ry

12-34 SITRAIN
SIMATIC Programming 2 in the TIA Portal

TRACE Analyzer
12.10 TRACE Function
Analyzer Function

om
internal Flash

.c
separate CPU memory

s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

"Trace" Analyzer Function


The value-over-time of one or several CPU tags (max. 16) can be stored in a TRACE. In
sa

STEP 7, a TRACE recording can be presented graphically.


The number of Traces depends on the CPU.
ry

Depending on the CPU, internal TRACE memories with 512 Kbyte each are available.
• S7-1200 2x TRACE (FW  V4.0)
• Up to S7-1517 4x TRACE, S7-1518 8x TRACE
• A maximum of 16 Trace signals or CPU tags (variables) can be recorded per Trace.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

12-35 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Configuring
12.10.1 a TRACE -aSignals
Configuring TRACEand Sampling
- Signals and Sampling

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Trace – Signals
sa

All global PLC tags (variables) of an elementary data type can be recorded.
ry

Trace – Sampling and – Recording Duration


Here, you define how often or in which intervals the Trace signals are to be recorded. From
these sampling intervals and the data type or the dimension of the Trace signals you get the
maximum duration of a Trace recording since the memory space available for the recording is
limited.
• Maximum memory space per Trace: 512 Kbytes – 30 bytes
(for internal management) = 524,258 bytes
Each sample is saved with a time stamp (8 bytes). This results in a…
• number of bytes per sample = 8 bytes + number of bytes of a sample
om
(for Boolean Trace signals, the number of bytes of a measured value is 1 byte)
• Example: Trace with 1x INT variable and a sampling interval of 100ms
– Trace signal of the data type INT -> 8+2 bytes/sample -> 52,425 possible samples
c

– Sampling interval = 100ms -> 10 samples per second


n.

– -> maximum recording duration: 52425 samples / 10 samples per second = 5242
seconds
sa
ru
bo
@
sa
m
sa
ry

12-36 SITRAIN
SIMATIC Programming 2 in the TIA Portal
a TRACE –

om
Configuring
12.10.2 Configuring a Trigger
TRACEand Saving and
– Trigger Measurement on Device
Saving Measurement on Device

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Triggering the Trace Recording


sa

Activating the Trace recording starts the measurement and recording of the Trace signals,
however, not the permanent saving of values since these are merely only temporarily saved in a
ring buffer which is continuously overwritten with new values. Only when the configured trigger
ry

event is fulfilled are the temporarily saved values permanently saved, and no longer overwritten
with new values. The trigger event is dependent on the data type of the trigger variable. The
Trace recording ends as soon as the maximum recording duration configured in Trace Sampling
is reached.
By defining a pre-trigger, you determine how many of the samples recorded before the trigger
event occurs are to remain stored.

Measurement on Device (Memory Card)


m
Completed measurements can be stored on the memory card in order to start a new
measurement. In the item "Measurements on device", you then number of measurements to be
co

stored. In addition, you define whether the oldest measurement is to be deleted when the set
number of measurements is reached or whether no more measurements are to be made.
n.
sa
ru
bo
@
sa
m
sa
ry

12-37 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Downloading a TRACE into the CPU, Activating It, Monitoring It
12.10.3 Downloading a TRACE into the CPU and Activating It

.c
Down/Up load Activate / Delete Trace Automatically

an
Observe
Trace Stop from the repeat
Trace
in CPU / in Project recording device recording

s
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

Transfer Trace Configuration to Device


Add Trace Configuration from the Device to Trace Configurations
After the Trace has been configured offline, that is, in the project, the configuration must be
downloaded into the CPU, since it is not the engineering tool that executes the Trace but the
CPU.
Only Trace configurations that exist online in the CPU can be uploaded from the CPU into the
project.
om

Observe Trace
c

Observe Trace displays the status of a Trace on the CPU:


n.

• inactive (Trace already loaded in the CPU, but not yet activated)
• wait for trigger (Trace activated in the CPU, but trigger event not yet fulfilled)
sa

• recording running (Trace activated in the CPU and recording running)



ru

recording completed (Trace activated in the CPU and recording already completed)
bo

Activate Recording / Deactivate Recording


The Trace is activated with "Activate recording", that means that the measuring and recording of
@

the Trace signals is started immediately, even if the possibly configured trigger event is not yet
fulfilled. The recorded values are continuously displayed and stored in a ring buffer which is
continuously overwritten with new values. Only when the trigger event is fulfilled are the
recorded values no longer overwritten and remain saved. At this time, the recording is
sa

continued until the maximum recording duration is reached.


Through "Deactivate recording", a Trace with the status "Wait for trigger" is deactivated
m

(stopped) or an already running recording is aborted.


sa
ry

12-38 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Evaluating,
12.10.4 Saving, Exporting
Evaluating, Saving, aExporting
TRACE a TRACE in STEP 7

.c
Export Trace configuration and Measurement

an
with the settings of the current view

s
Add to measurements

ru
(offline)

bo
@
Measurements on device
(memory card)

Combine measurements
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

View and Evaluate Trace


ry

When an online connection exists, the Trace recording currently saved in the CPU is displayed
in the Diagram view of the Trace editor.
You will find the measurements stored on the memory card in the "Measurements on device"
folder.
Trace recordings saved offline in the project can be looked at by double-clicking on the Trace
recordings saved in the Project tree in the "Measurements" folder.
Furthermore, in the "Combined measurements" folder, measurements can be simultaneously
evaluated and compared.

Save Trace in Project


m
With this function, Traces saved online in the CPU can be uploaded into the offline project (Add
to measurements). A Trace can only be saved in the project when it is full or the recording has
co

been stopped.
n.

Trace Configuration
sa

This function exports the configuration of a Trace which can then be imported into other
projects. (TTCRX-file)
ru
bo

Trace Measurement:
This function exports a Trace recording in CSV-format which can then be further processed with
MS Excel, for example, or, in TTRCRX-format which can be imported into a TIA Portal project.
@
sa
m
sa
ry

12-39 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Combined
12.10.5 Measurements
Combined Measurements

.c
an
Preselection of
all signals

s
ru
bo
Alignment of
measurements

Group signals

@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

In order to be better able to compare measurements with one another, it is possible to create
ry

combined measurements (laying one measurement over the other). You can create a new
"Combined measurement" and add individual measurements in it using drag & drop, or, you can
select several measurements and drag these into the "Combined measurements" folder using
drag & drop.

"Measurements" Table Tab (Alignment of Measurements)


In the "Measurements" tab, you can align the measurements according to the trigger or the
sample, or, according to their absolute timestamp.

"Signals" Table Tab


The signal table is in the "Signals" tab. It lists the signals of the measurements and makes it
possible for you to set options for the presentation.
m
In the column "Scaling group", you can create groups and assign individual signals to the
groups. Signals that are assigned to the same group are scaled the same and presented in a
co

diagram, which, for example, enables a better comparison of graph progressions. Binary signals
cannot be grouped.
n.

"Signal Selection" Tab


sa

In the "Signal selection" tab, you can activate and deactivate individual signals (preselect them)
for the "Diagram" tab. Deactivated signals are not visible in the signal table.
ru
bo
@
sa
m
sa
ry

12-40 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Trace Task
12.10.6 CardTask Card
Trace

.c
s an
Measuring cursor

ru
bo
@
Snapshots
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

"Measuring Cursor" Pane


sa

The "Measuring cursor" pane shows the position of the measuring cursor in the graph and the
values at the intersections.
ry

"Snapshots" Pane
The "Snapshots" pane enables the saving and restoring of different views of a measurement.
A snapshot is created from the current view in the "Diagram" tab. The snapshots are saved in
the measurement with the project.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

12-41 SITRAIN
SIMATIC Programming 2 in the TIA Portal

12.11 Exercise 7: Creating, Looking at, Saving, Evaluating, and

om
ExerciseComparing
7: Creating, Looking at, Saving, Evaluating, and Comparing a TRACE
a TRACE

.c
s an
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

Task
sa

You are to create a Trace configuration with the following properties:


• The Trace signal is to be the "DB_Conveyor".Weight" variable.
ry

• The variable is to be sampled once with every "OB_Cyclic interrupt" call.


• The recording of the values of the "DB_Conveyor".Weight" variable is to be started as soon
as the variable value falls below 100 or exceeds 400.
• The Trace is to have a recording duration of 10 seconds.
The last second before the trigger condition occurs is also to be recorded in the Trace
m
recording (pre-trigger).
• As an example, 3 Trace recordings are to be recorded and saved on the SMC.
co

• In addition, a combined measurement is to be created, two measurements integrated and


compared.
n.

What to Do
sa

1. Create the new Trace and configure it as described.


2. Download the Trace into the CPU and activate it.
ru

3. On the left slider potentiometer of the simulator, set an invalid weight (<100 or >400) and
monitor whether the Trace recording ends after 10 seconds. Repeat the setting of an invalid
bo

weight.
4. Look at the Traces and save them in the project.
5. Create a combined measurement, copy two Traces in it using drag & drop and compare the
@

Traces. For this, use the "Trace" task card.


sa
m
sa
ry

12-42 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
13 Commissioning a Drive with Startdrive and

.c
Technology Object

an
LearningLearning
13.1 objectives objectives

s
ru
• You know how to reset the inverter to factory settings

bo
• You know how to integrate a drive in the device configuration

• You know how to parameterize and test a drive with Startdrive

@
• You know how to parameterize and apply the technology object SpeedAxis

• You know how to control the drive with the help of a technology object
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

13-1 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Task Description:
13.2 G120 as an Additional
Task Description: G120Conveyor Drive
as an Additional Conveyor Drive

.c
an
Specify the
G120 speed

s
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

PROFINET
sa

Task Description
Imagine that the drive is being used as an additional drive for the conveyor model.
ry

The drive is to be controlled as follows:


• The G120 drive is switched on and switched off parallel to the Automatic mode of the
conveyor motor.
• The speed of the G120 can be set via the right slide control (potentiometer) on the operator
panel (simulator).
• The drive runs in Automatic mode parallel with the conveyor motor with the set speed
om
c
n.
sa
ru
bo
@
sa
m
sa
ry

13-2 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Communication
13.3 Standard PROFIdrive
Communication Standard PROFIdrive

.c
an
PROFIdrive

s
PROFIBUS & PROFINET

ru
International (PI)

bo
• Consistent industrial communication
• Comprehensive range of applications

@
• PROFIdrive is the standard profile for drives technology in conjunction
with the PROFIBUS and PROFINET communication systems
• Proven method for the easy and integrated connection of drives and
sa
controllers of different manufacturers
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Communication via PROFIBUS and PROFINET


sa

PROFIBUS and PROFINET are the solutions which provide absolute consistency and are highly
application-oriented. The main reason that PROFIBUS and PROFINET stand out from other
ry

industrial communication systems is because they span such an extraordinary breadth of


applications.
One of the most important applications in industrial automation is drives technology.
Open technologies need, for their maintenance, ongoing development, and market penetration,
a company-independent institution that can serve as a working platform. For this purpose, the
PROFIBUS Nutzerorganisation e.V. (PNO) [PROFIBUS User Organization] was founded in
1989 as a non-profit organization representing the interests of manufacturers, users and
institutes (world’s largest interest association in the field of industrial communication).
PNO is a member of the international umbrella organization PI (PROFIBUS & PROFINET
m
International) founded in 1995.
co

PROFIdrive
PROFIdrive is the standard profile for drives technology in conjunction with the communication
n.

systems PROFIBUS and PROFINET.


→ open "application profile" for connecting drives and controllers
sa

of different manufacturers via communication systems


The control word and status word of the G120 comply with the specifications of
ru

PROFIdrive profile Version 2.0 or Version 3.0 for the "speed control" operating mode.
bo
@
sa
m
sa
ry

13-3 SITRAIN
SIMATIC Programming 2 in the TIA Portal
CPU - Drive Communication: CPU – G120
13.3.1 CPU - Drive Communication: CPU – G120

om
Main tasks of the CPU – Drive Communication:

.c
Reading / Writing of parameters:
Controlling the drive process:

an
• Reading-out fault and diagnostic values
• Constant setting of control bits and setpoint values
• Reading and changing function values
• Constant reading of status bits and actual values
e.g. when setting up the machine

s
Parameter data range (PKW) Process data range (PZD)

ru
Parameterizing Controlling

bo
Source of the main setpoint Value of main setpoint
Source of the control bits Logic state of control bits
@ The data is transferred:

• On request only if necessary • Fast and constantly triggered


sa
• With free access to any parameter • With assigned (fixed) “wiring” to the process
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

acyclic cyclic
m
sa

via DS47 telegrams via standard telegrams


ry

Process Control
Fast data transmission of short data telegrams to all participating stations with the maximum
speed available on the bus whereby all participants can receive different data. In drive systems
these are typically setpoints, control commands, status replies and actual values (measured
values).

Operating Control
m
In addition to this permanently available data, there is data that is only needed in particular
co

cases. It would therefore be senseless to permanently put load on the bus if this data is only
needed once per hour or per day, for example, when starting up the machine (Class 1 Master).
Another reason for an expanded communication need could be the commissioning, optimization
n.

or diagnosis of machine components from a central location. In this case, (such as a fault) a
detailed access of an Engineering Tool to the system components or the drive is enabled.
sa

Since, as a rule, only one affected device/component is directly addressed, this window is only
made available once per bus cycle for one bus station and not simultaneously for every station.
ru

Cyclic Data Exchange


bo

This is used to fulfill the demand for fast, permanent data exchange.

Acyclic Data Exchange


@

The acyclic exchange of entire data sets (for example, DS47, DS100) between
Master/Controller and Slave/Device occurs according to standardized procedures which are
implemented with FBs from the libraries (for example, Drive ES SIMATIC).
sa

The initiation of a data transmission for the acyclic communication of a Class 1


Master/Controller with a Slave/Device is always triggered by the user program. That is, the user
program decides whether a data exchange with a Slave/Device is necessary or not based on
m

further conditions. Only when there is a need, does a data transmission request get signaled to
the DP Master/Controller which then executes it.
sa
ry

13-4 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Standard Telegrams
13.3.2 Standard Telegrams

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Telegrams 1, 20 Manufacturer-independent Standard Tel. automatic configuration in drive


sa

Telegrams 352 to 391 Siemens-specific Standard Telegrams automatic configuration in drive


Telegram 999 Free Telegrams manual configuration required
ry

Master-Slave / Controller-Device Communication via Standard Telegram


The best way to implement a cyclic data exchange between Master/Controller (CPU) and
Slave/Device (G120) is using a standard telegram, which typically is also used for simple speed
controls. Between the Master/Controller and Slave/Device, two input words and two output
words with the following contents are exchanged:
• Output word 1: Control word
• Output word 2: Main setpoint value

om
Input word 1: Status word
• Input word 2: Main actual value
• Control Word
.c

• The control word (Bit 0 to 10) complies with the PROFIdrive profile standard. Bits 11 to 15
an

are inverter-specific.

Status Word
us

The status word (Bit 0 to 10) complies with the PROFIdrive profile standard.
• Bits 11 to 15 are inverter-specific.
r
bo

Scaling the Speed Values


Via the parameter p2000, a reference speed is defined which all setpoint and actual values use
as a reference.
@

The range of -100% to 100% of the setpoint or actual value, in turn, is scaled to the range
-16384 (C000HEX) to +16384 (4000HEX).
sa
m
sa
ry

13-5 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Inserting a Drive into the Project
13.4 Inserting a Drive into the Project

.c
an
Enter device name

s
ru
bo
@
sa
Select correct
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Drive with parameter settings


version
m

and Power Unit can also be


uploaded via the function
sa

"Online > Upload device as


new station (hardware and
software)”
ry

"Startdrive" Option Package


If the "Startdrive" option package is installed in TIA Portal, drives can be added, configured and
parameterized as a new device.
Otherwise, a drive can be inserted in the project via GSD file as a distributed I/O station using
the Hardware catalog. However, then only the communication with the CPU can be configured
in TIA Portal, no hardware configuration, no parameter settings.
m
Note
The drive, with the power unit that is used and all the parameter settings can be uploaded via
co

the function "Upload device as new station (hardware and software)" which is found in the
"Online" menu (for this, the drive must have an IP address).
n.
sa
ru
bo
@
sa
m
sa
ry

13-6 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Configuring
13.4.1 a Power Unit
Configuring a Power Unit

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Configuring a Power Unit:


sa

A drive consists of two components


• Control unit → already configured with the device that is added
ry

• Power unit → must be configured

om
.c
an
r us
bo
@
sa
m
sa
ry

13-7 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Networking
13.4.2 a Drive with
Networking the CPU
a Drive with the CPU

om
.c
s an
ru
Drag connection

bo
between devices

@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Editor
m

Hardware & Networks → "Network view"


sa

Networking
Click on the interface of the one module, hold the left mouse button and drag onto the interface
ry

of the other module.


→ here in the picture: PN interface of the G120 dragged onto PN interface of the CPU

Unassigned Devices
This section then disappears since the device is now assigned to the CPU and the link can be
om
found in the Distributed I/O folder of the controller.
c
a n.
r us
bo
@
sa
m
sa
ry

13-8 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Parameterizing
13.4.3 the Module
Parameterizing Address
the Moduleand Module and
Address NameModule Name

om
.c
an
Select the control
unit

s
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Name of the Module


m

If the property "Generate PROFINET device name automatically" is activated in the Properties
sa

of the drive under PROFINET interface > Ethernet addresses > PROFINET, then the module
name set under "Properties > General" is also the PROFINET device name. With the help of
this name, it is possible for the CPU to assign the module, that is, the PROFINET-IO Device is
ry

identified by the PROFINET-IO Controller through this name.

This name must be assigned to the PROFINET-IO module online; otherwise, the
CPU (PROFINET-I/O Controller) cannot identify the module.

Address Assignment of the Distributed IO-Module


om
For PROFINET-IO, the parameterized IP address of the module is assigned by the CPU
through the configured device name.
c
a n.
r us
bo
@
sa
m
sa
ry

13-9 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Parameterizing
13.4.4 the Process
Parameterizing theData Area (PZD)
Process Data Area (PZD)

.c
an
Select control unit

s
ru
bo
Status word
and actual value

Control word
and setpoint (value)

T QW 60
T QW 62
Control word
@
Main setpoint
sa
...
L IW 60 Status word
L IW 62
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Main act. value


m

Process Data Area


sa

Communication using Standard telegram 1 is based on a cyclic process data exchange that is
very easy to program.
ry

The control word and status word comply with the specifications of PROFIdrive profile
Version 2.0 or Version 3.0 for the "speed control" operating mode.
The control word and, if necessary, the main setpoint are sent from the CPU to the drive. In the
response telegram, the drive returns the status word and the main actual value.
Since only two words are exchanged between the CPU and the drive, simple load and transfer
operations are all that are required in the program. When a double word is transferred, data
consistency is also assured.

Control Word
m
The control word contains 16 binary signals for controlling the drive (On/Off, direction of rotation,
etc.).
co

Main Setpoint
n.

According to standard parameterization of the drive, the main setpoint specifies the setpoint
speed.
sa
ru
bo
@
sa
m
sa
ry

13-10 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Assigning a Device Name ONLINE (Module Initialization)

om
13.4.5 Assigning a Device Name ONLINE (Module Initialization)

OFFLINE

.c
configured
device name

s an
ru
ONLINE

bo
accessible
device

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Device Name
The PROFINET device name that was configured OFFLINE must be assigned to the drive that
sa

actually exists ONLINE.


ry

Name of the Module


The name is the assignment CPU ↔ module.
Through this, the PROFINET-IO is identified by the PROFINET-Controller.
This name must be assigned to the PROFINET-IO module online; otherwise, the
CPU (PROFINET-Controller) cannot identify the module.

Checking the Result in the Inspector Window


m
co
n.
sa

Note:
ru

If you do not use the "Assign device name" dialog but instead the Online access (Online &
diagnostics/Functions/Assign name) to set the device name on a drive which already has a
bo

PROFINET device name, then you will have to restart the device.
@
sa
m
sa
ry

13-11 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Parameterizing
13.5 the Drive with the
Parameterizing the"Commissioning Wizard"
Drive with the "Commissioning Wizard"

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Commissioning Wizard
sa

The most important settings for the drive can be made with the menu-driven Commissioning
Wizard. These are, among others:
ry

• Details of the setpoints / command sources


• Drive setting(s)
• Motor (data)
• Important parameters (dynamic data)
• Drive functions m
co
n.
sa
ru
bo
@
sa
m
sa
ry

13-12 SITRAIN
SIMATIC Programming 2 in the TIA Portal

13.6 Online Commissioning: Activating / Deactivating the Control

om
Online Commissioning:
Panel Activating / Deactivating the Control Panel

.c
Requirement:
• Online connection PG  Drive exists

an
• No fault is active (if necessary, acknowledge first)

s
ru
Activate

bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Acknowledge fault
m
sa

As soon as the drive has a valid IP address and thus is accessible online, the parameterization
and functions of commissioning are available.
ry

Online Accesses
As soon as the drive has been assigned a valid IP address in the subnet used, the functions of
commissioning are available here.

Device in the Project Tree


m
If the drive was inserted as a new device, it is assigned the default IP address
192.168.0.1.
co

is only possible when the IP address of the device configuration corresponds to


the subnet used and is also assigned to the drive.
n.
sa

Control Panel
This can only be activated when an online connection exists and no fault exists.
ru

Caution!
Activation terminates a possibly existing connection to the CPU and gives the operator
bo

full control of the drive. Therefore it is important to have at your disposal a hardware
solution for an Emergency Stop.
@
sa
m
sa
ry

13-13 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Operating the Control Panel for Commissioning

om
13.6.1 Operating the Control Panel for Commissioning

.c
Activate / Deactivate Master Control Set / Reset Drive enables

s an
ru
Continuous mode
Motor off
according to specified speed

bo
Specify speed Jog Modeaccording
Jog Mode to specified
according speed
to specified speed

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

For reasons of safety, the drive is stopped when the editor is exited (e.g. Editor change, Windows task change)
sa

If the Master control is activated on the PG, you can switch on "Modify".
ry

Operation is enabled and the buttons for modifying are active.

Safety Shutdown
The drive is stopped and...
• operating enables are cancelled,
when the "Commissioning" editor is exited through a Windows task change.

m
• the Master control is deactivated with a fault message,
co

when a switch is made to the editor of another device.


 and
n.
sa
ru
bo
@
sa
m
sa
ry

13-14 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Monitoring
13.6.2 Control and
Monitoring Statusand
Control Word(s) ONLINE
Status Word(s) ONLINE

.c
s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Monitoring control and status Words


The Control and Status words dialog displays the different control and status words for
ry

diagnostics.
The signals actually used by the inverter are indicated by LED lights. The display is only
relevant if the drive is controlled via the fieldbus.

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

13-15 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
13.7 Task Description (CLASSROOM):
Task Description:
G120 as G120
anasAdditional
an Additional Conveyor
Conveyor Drive
Drive

.c
an
Specify the
G120 speed

s
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

PROFINET
sa

Task Description
Imagine that the drive is being used as an additional drive for the conveyor model.
ry

The drive is to be controlled as follows:


• The G120 drive is switched on and switched off parallel to the Automatic mode of the
conveyor motor.
• The speed of the G120 can be set via the right slide control (potentiometer) on the operator
panel (simulator).
• The drive runs in Automatic mode parallel with the conveyor motor with the set speed
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

13-16 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
ExerciseExercise
13.7.1 1 (CLASSROOM): Reading-out
1 (CLASSROOM): the Firmwarethe
Reading-out Version of theVersion
Firmware Drive of the Drive

.c
s an
ru
bo
Optional:
Assign IP address

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

In order to be able to configure the drive in the project in the next exercises, you must know the
firmware version of the training unit. Since the firmware of the drive can be upgraded, the
ry

version of the firmware specified on the outside does not necessarily reflect reality. For that
reason, the current version of the firmware is now to be read out online from the drive.

Problem
Should the drive only have a MAC address and neither a PROFINET device name nor an IP
address, the firmware version cannot be read out, since an IP address is required for this
diagnostic service.

What to Do
1. In the Project tree, open the "Online access" folder
om
2. Select your interface and update it
3. In the list of "accessible devices", open the drive and activate "Online & diagnostics".
c

4. If the drive does not yet have an IP address, assign a temporary IP address under
n.

"Functions > Assign IP address" and the update the interface,


5. In the work area, activate "Diagnostics > General diagnostics" and make note of the
sa

firmware version of the inverter.


ru
bo
@
sa
m
sa
ry

13-17 SITRAIN
SIMATIC Programming 2 in the TIA Portal
ExerciseExercise
13.7.2 2 (CLASSROOM): Resetting toResetting
2 (CLASSROOM): Factory Settings
to Factory Settings

om
.c
s an
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Task
m

You are to reset the drive to its factory settings.


With the "Restore factory settings" function, the PROFINET device name and the IP address
sa

are also deleted.


ry

What to Do
1. In the work area, switch to the menu "Saving / reset"
2. In the function "Restore factory setting", activate "All parameters will be reset" and start the
function,
3. Close the window.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

13-18 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
13.7.3 Exercise 3 (CLASSROOM): Inserting and Networking the Drive in the Offline
ExerciseProject
3 (CLASSROOM): Inserting and Networking the Drive in the Offline Project

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
You are to insert the drive in the project and network it with the CPU via PROFINET.
ry

What to Do
1. Open the "Hardware & Networks" editor and there activate the Network view.
2. In the Task Cards, open the Hardware catalog.
3. Insert the G120 drive by dragging the CU240E-2PN-F control unit into the Network view
using drag & drop.
Pay attention to the Article no (order number) and the Version in the "Information"
section.
4. Network the drive with the CPU by dragging the PROFINET interface of the drive to the
m
PROFINET interface of the CPU using drag & drop.
5. Save your project.
co

Note
n.

The drive that is used along with the power unit can be uploaded via the function "Upload
device as new station (hardware and software)" which is found in the "Online" menu. For this,
sa

the drive merely needs an IP address.


ru
bo
@
sa
m
sa
ry

13-19 SITRAIN
SIMATIC Programming 2 in the TIA Portal
ExerciseExercise
13.7.4 4 (CLASSROOM): Parameterizing
4 (CLASSROOM): the Drive Communication
Parameterizing the Drive Communication

om
.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
m

So that the configuration of the drive is complete, a power unit still has to be added.
sa

Furthermore, the control unit still has to be parameterized.

What to Do
ry

1. Open the Device configuration of the drive.


2. Open the Hardware catalog and, using drag & drop, add the power unit if it is not already
integrated. Pay attention to its Article no (order number) in the "Information" section.
3. Select the control unit and, in the Inspector window under "Properties", parameterize the
module with the parameters shown in the picture.
4. Save your project.
c om
a n.
r us
bo
@
sa
m
sa
ry

13-20 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
ExerciseExercise
13.7.5 5 (CLASSROOM): Assigning the
5 (CLASSROOM): PROFINET
Assigning theDevice Name ONLINE
PROFINET Device Name ONLINE

.c
OFFLINE

an
configured
device name

s
ru
bo
ONLINE
accessible device

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

ONLINE, assign the OFFLINE configured PROFINET device name and the IP address to the
drive.
ry

What to Do
1. Open the "Hardware & Networks" editor and there activate the Network view.
2. Select the subnet (see picture) and via the right mouse button, activate the function "Assign
device name"
3. In the dialog that follows, complete it as shown in the picture and assign the name.
4. Check whether the name assignment was successful by "Updating the accessible devices"
under the Online access.
5. Save your project.
om
.c
an
r us
bo
@
sa
m
sa
ry

13-21 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
13.7.6 Exercise 6 (CLASSROOM): Parameterizing the Drive OFFLINE with the
ExerciseCommissioning
6 (CLASSROOM):Wizard
Parameterizing the Drive OFFLINE with the
Commissioning Wizard

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

OFFLINE, you are to set the most important drive parameters and use the "Commissioning
Wizard" to do this.
ry

What to Do
1. Start the Commissioning Wizard as shown in the picture. Implement the parameterization
as shown in the following.

Note if Firmware of the drive is lower than 4.7.3


For a Firmware of the drive that is lower than 4.7.3., the Commissioning Wizard starts with the
setting "Setpoint specification".
om
Setpoint specification
c
a n.
r us
bo
@
sa
m

Open-loop/closed-loop parameters
sa

Note: This setting can only be chosen if "[0] Expert" is selected for the Application class or for a
Firmware of the drive that is lower than 4.7.3.
ry

13-22 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
.c
san
ru
bo
@
Defaults of the setpoints / command sources
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

c om
n.
sa
ru
bo
@
sa
m
sa
ry

13-23 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Drive setting

.c
an
Additional setting: Power unit
application for FW lower than 4.7.3

s
or selected Application class

ru
"[0] Expert"

bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

• Drive options
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

13-24 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal

• Motor

.c
Take the motor data from the motor’s nameplate and enter it in the Motor dialog:

an
:

s
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

m
co
n.

Setting for FW lower than 4.7.3 or selected Application class "[0] Expert"
sa

Additional Rated motor power factor.


ru
bo
@
sa
m
sa
ry

13-25 SITRAIN
SIMATIC Programming 2 in the TIA Portal

• Important parameters

om
Set the Maximum speed and the Reference speed, as well as change the ramp-up and the
ramp-down times:

.c
s an
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m
sa
ry

Drive functions

m
co
n.
sa
ru
bo
@
sa

Additional setting:
Calculation of the motor data for FW lower
m

than 4.7.3 or selected Application class "[0]


Expert"
sa
ry

13-26 SITRAIN
SIMATIC Programming 2 in the TIA Portal

• Summary

om
.c
s an
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m
sa
ry

c om
a n.
r us
bo

2. Have the Commissioning Wizard complete the commissioning by pressing the "Finish"
button and save your project.
@
sa
m
sa
ry

13-27 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
13.7.7 Exercise 7 (CLASSROOM): Downloading Drive Parameterization to the Drive and
ExerciseHardware
7 (CLASSROOM): Downloading
Configuration to theDrive
CPUParameterization to the Drive
and Hardware Configuration to the CPU

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

Now that you have implemented the basic parameterization offline, it is now to be downloaded
into the drive online. In addition, the hardware change of the CPU is also to be downloaded.
ry

What to Do
1. In the Project tree, select the drive and start the download of the hardware configuration
and parameterization using the button "Download to device" (see picture).
2. The dialog "Extended download to device" appears which contains the list of compatible
devices in the target subnet in the lower part. Should the drive of your training area not be
listed there, activate the option "Show all compatible devices" (see picture).
3. In the list "Select target device", select the drive of your training area and start the
m
"Download".
co

So that the drive doesn’t lose the parameterization even after a power failure, answer the
following dialog as follows:
n.
sa
ru
bo
@
sa

4. Also download the hardware configuration of the SIMATIC station once more into the
S7-1500.
m
sa
ry

13-28 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
ExerciseExercise
13.7.8 8 (CLASSROOM): Operating the
8 (CLASSROOM): Drive viathe
Operating the Drive
Control
viaPanel
the Control Panel

.c
s an
ru
Activate Master control

bo
Specify speed START backwards / forwards

@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Task
Since the drive is already configured and has been assigned an IP address by the Controller, it
ry

can be operated via the Control panel.

What to Do
1. In the Project tree under "G120" open the menu "Commissioning" and there the "Control
panel" (see picture).
2. Activate the "Master control" and "Continue" the dialog that appears.
m
co
n.
sa

3. Set the Drive enables,


ru

4. Wait for the motor data identification and then set the Drive enables once again,
5. In the control panel, specify a speed and switch on the drive.
bo

6. Before the motor can rotate with the desired speed, one of the two directions "Forward" or
"Backward" still has to be selected.
7. Let the motor move "Forward" and "Backward" with different speeds.
@

8. Switch the motor off again and deactivate the master control.
9. Close the editor and disconnect the online connection to the G120 (Go Offline).
sa
m
sa
ry

13-29 SITRAIN
SIMATIC Programming 2 in the TIA Portal

13.8 Axis
Axis Control byControl
means of aby meansObject
Technology of a Technology Object

om
.c
s an
ru
Device configuration Controlled

bo
of drive drive

Technology object (virtual axis)


with information about real
@ axis, telegram etc.

User program with


Motion Blocks
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Principle of Axis Control


For the control of axes, there is a model grouped into four sections in which you are supported
sa

by wizards and diagnostic screens for the commissioning and diagnosis of axes.
• User Program
ry

The user program utilizes standardized Motion Control instructions for the control of the
"Axis" technology object and thus the axis or the drive.
• Technology Object "Axis"
The technology object "Axis" represents a virtual axis in the controller. Through dialog
boxes (wizard), the information about the real axis, the telegram used, possible drives, and
the parameters of the axis can very easily be specified. In the proper sense, the technology
object is a data block with an exactly defined structure in which the parameters input by you
m
are entered. The specification of the DB is then required for the programming in the user
program for the Motion Control instructions. As a result, it is possible to program very simple
and understandable instructions. The conversion of these instructions - that is, for example,
co

the creation of the control word or the conversion of the speed, taking into account gearbox
factors - into the standardized value is then handled by the technology object. You, as the
n.

user, don’t require any knowledge about the structure of the control word or how the speed
has to be converted.
sa

• Drive
Suitable are all drives or motors which support a control via a bus interface (PN, DP)
ru

according to the PROFIdrive profile, an analog setpoint/actual values, or pulse/direction


interface.
bo
@
sa
m
sa
ry

13-30 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Technology Objects (TO) in SIMATIC S7
13.8.1 Technology Objects (TO) in SIMATIC S7

om
general: TO → Software for controlling and monitoring technical components

.c
an
TOs in STEP 7
What characterizes a TO?:
• Can be parameterized

s
• Can be diagnosed
• Instructions for control and

ru
monitoring

bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

TO is mapped to a DB
sa

Depends on the CPU


ry

Technology Object (TO) in General


Technology Objects (Abbreviation: TO) provide software for controlling and monitoring technical
components.
Depending on the TO, these require different inputs/outputs for the process control/monitoring
of the actuator/encoder.
m
SIMATIC TO
Depending on the CPU, different TOs are provided for:
co

• Motion Control → axis control


• PID Control → closed-loop controllers
n.

• SIMATIC Ident → Parameterization of an Ident system


sa

• Counting and measurement → high-speed counters


ru
bo
@
sa
m
sa
ry

13-31 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Properties of the TO

om
13.8.2 Properties of the TO

.c
an
Configuration:
Specify signals, limits, limit
switches, reference point

s
ru
bo
Commissioning:
Control axis in manual mode
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Diagnostics:
m

Display current position of


axis, evaluate signals
sa
ry

After the technology object "Axis" has been created, there are three selection possibilities
available for handling:

Configuration
Selection of the drive connection and the drive itself,
Properties of the mechanics and gear ratio, the telegram,
m
Properties for dynamic parameters,
co

The configuration is stored in the data block of the technology object

Commissioning
n.

With the "Commissioning" tool, the functioning of the axis is tested without having to create a
user program. When you start this tool, the Control panel opens. The following commands are
sa

available in the Control panel:


Enable and Disable the axis
ru

Start with a certain speed,


bo

Acknowledge errors

Diagnostics
@

With the "Diagnostics" tool you check the current Status and Error
information of axis and drive.
sa
m
sa
ry

13-32 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Technology Object "Motion Control"
13.8.3 Technology Object "Motion Control"

.c
Motion Control

an
Technology object “Motion Control”
→ Speed control

s
→ Positioning an axis

ru
→ Synchronous speed control (relative and absolute)
→ Cam control etc.

bo
Available functionality depends on the CPU

Information about the drive, the


communication, etc. is entered in
the technology object (the data
@
sa
block) with the help of a Wizard
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

Motion Control refers to the control of position, velocity, acceleration, or a combination thereof.
Electric motors, for example, are used as actuators/encoders for control.

Typical Application
• Speed control
• Point-to-Point positioning control
om
• Synchronous speed controls
• Cam (track) control
c

A virtual axis is created (data block) in which all properties of the drive are stored with the help
n.

of a Wizard. With the help of this DB, the drive can be controlled in the easiest way.
sa
ru
bo
@
sa
m
sa
ry

13-33 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Technology Functions
13.9 Technology Functions

om
.c
PID Control

s an
ru
bo
@
sa
High-speed Counter
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Motion
m
sa
ry

High-speed Counters
For the precise monitoring of incremental encoders, frequency counting, or for counting highly
frequent process events, high-speed counters with up to 100 kHz (depends on the CPU) are
available.

Motion
m
To control rotary speed, position, or pulse duty factor, PWM outputs (pulse width modulation)
are available. Application examples are, for example, controlling the speed of a motor, position
co

of a valve, or the mark-to-space ratio for a heating element.


For rotary speed and position controls, PTO outputs with 100 kHz (pulse train output) are
n.

available. Application examples are rotary speed and position control of stepper motors or servo
motors.
sa

PID
For simple closed-loop control tasks, PID control circuits with automatic PID adjustment and
ru

tuning control panel are available.


bo
@
sa
m
sa
ry

13-34 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Technology
13.9.1 FunctionsFunctions
Technology "SpeedAxis"
"SpeedAxis"

om
.c
SpeedAxis

an
Enable/Disable axis → "MC_Power"

s
Acknowledge alarms / Restart → "MC_Reset"

ru
Start axis, Move axis with velocity speed → "MC_MoveVelocity"
setpoint

bo
Pause axis → "MC_Halt"

Move axis in Jog mode → "MC_MoveJog"


@
Force / Torque limit / Fixed stop detection → "MC_TorqueLimiting"
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

The speed of a drive can easily be controlled with the help of various instructions which can be
sa

found in the Task card "Instructions" under "Technology > Motion Control".
The only requirement here is that a technology object was configured for the particular drive.
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

13-35 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Applying Technology Functions
13.9.2 Applying Technology Functions

om
.c
s an
ru
Technology object of the

bo
drive that is controlled.

@
Pos. edge –
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

start task

0 – only Status and


m

acknowledge error bits


sa

pending alarms
ry

In order to achieve the desired behavior of the drive, the necessary instruction is simply called,
parameterized, and linked with the correct technology object.
In the instruction, the relative status word of the drive is evaluated, the control word as well as
the setpoint (if necessary) etc. is formed and sent to the drive.
All information necessary for this, such as addresses or parameterizations of the drive, are
m
stored in the technology object.
co
n.
sa
ru
bo
@
sa
m
sa
ry

13-36 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Task Description:
13.10 Commissioning of a Technology
Task Description: object of a Technology object
Commissioning

.c
san
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

Task Description
A new technology object should be inserted and commissioned.

om
.c
an
r us
bo
@
sa
m
sa
ry

13-37 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
ExerciseExercise
13.10.1 9 (CLASSROOM): TechnologyTechnology
9 (CLASSROOM): Object "SpeedAxis"
Object "SpeedAxis"

.c
s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Task
You are to insert a new technology object.
ry

What to Do
1. In the Technology objects folder, insert (add) a new technology object.
2. Select "Motion Control > TO_SpeedAxis"
3. Give the object (DB) the name "SpeedAxisG120"

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

13-38 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
ExerciseExercise
13.10.2 10 (CLASSROOM): Parameterizing
10 (CLASSROOM): the Technology
Parameterizing theObject
Technology Object

.c
s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Task
You are to parameterize the technology object with the help of the Wizard, as explained on the
ry

following pages:

• Drive:

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

13-39 SITRAIN
SIMATIC Programming 2 in the TIA Portal

• Data exchange:

om
.c
san
ru
bo
Parameters such as the "rated
speed" are transferred from the
parameterization of the drive.

• Mechanics:
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

• Dynamic default values:

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

13-40 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
• Emergency stop:
Note: The values ‘Emergency stop deceleration’ and ‘Emergency stop ramp-down time’ can

.c
only be set – as shown in the picture – after the maximum speed is set in the following
window (Dynamic limits).

s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

• Dynamic limits:

m
co
n.
sa
ru
bo
@
sa
m
sa

Save your changes!


ry

13-41 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
ExerciseExercise
13.10.3 11 (CLASSROOM): Testing withTesting
11 (CLASSROOM): the Axiswith
Control
the Panel
Axis Control Panel

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

You are to check the parameterization of the technology object with the help of the Axis control
panel.
ry

What to Do:
1. Load the previously made changes.
2. Go Online.
3. Open the "Axis control panel" via the Technology object’s function "Commissioning".
4. Activate the master control.
5. Enable the axis.
6. Acknowledge pending errors, if necessary.
7. Set a velocity and let the drive run forward and backward.
m
8. Stop and disable the drive.
co

9. Deactivate the master control.


n.
sa
ru
bo
@
sa
m
sa
ry

13-42 SITRAIN
SIMATIC Programming 2 in the TIA Portal
ExerciseExercise
13.10.4 12 (CLASSROOM): Copying theCopying
12 (CLASSROOM): Master Copy FB "Drive"
the Master Copy FB "Drive"

om
.c
s an
ru
bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Task
m

copy the variable "S_slider2" and the Master copy for the FB "Drive".
sa

What to Do:
1. Open the global library "Pro2_LIB_Vxx" and the folder "Master copies > Chapter13",
ry

2. Copy the variable "S_slider2" into the already existing PLC tag table “mytags”.
3. Copy the function block "FB_Drive” and open the block.
The required Input and Output parameters, temporary variables, and the empty networks
with network comments already exist. m
co
n.
sa
ru
bo
@
sa
m
sa
ry

13-43 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
13.10.5 Exercise 13 (CLASSROOM): Controlling the Drive by means of Technology
ExerciseObject
13 (CLASSROOM): Controlling the Drive by means of Technology
Object

.c
s an
ru
Acknowledge alarms

Enable TO

bo
Read Speed

Turn axis to the right

@
sa
Turn axis to the left
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Stop axis
m
sa

Task
The drive can be activated with the help of technology functions. You are to program the
function block "Drive" in such a way that the speed of a drive can be controlled with it. Make
ry

sure that the function block is re-usable.

What to Do:
1. Declare the new IN-OUT parameter "speedAxis" of the type "TO_SpeedAxis".
Note: Since the data type "TO_SpeedAxis" cannot be found in the drop-down selection list,
it must be written out.
2. In Network 1, with the help of the appropriate technology instruction, program the
acknowledgement of all technology alarms passed to the "speedAxis". Call the instruction
as multiple instances and specify the necessary actual parameters.
m
3. Program the remaining 5 networks with the functions as they are described in the network
co

titles and use the already existing parameters and tags/variables of the block.
4. Create a new Program cycle - OB "MainDrive"
n.

5. In it, call “FB_Drive" with the instance "iDB_FB_Drive",


Note: some parameters are automatically supplied with actual parameters since this is set
sa

in the Properties of these parameters.


6. Supply the remaining formal parameters with the relevant actual parameters,
ru

7. Compile, save, download, and test your program,


bo
@
sa
m
sa
ry

13-44 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
13.11Task Description (ONLINE): Commissioning of a Technology
Task Description: Commissioning of a Technology object
object

.c
san
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

© Siemens 2021 SITRAIN


Task Description
A new technology object should be inserted and commissioned.
c om
a n.
r us
bo
@
sa
m
sa
ry

13-45 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 9 (Online):
13.11.1 ExerciseTechnology Object
9 (ONLINE): "SpeedAxis"
Technology Object "SpeedAxis"

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

You are to insert a new technology object.


ry

What to Do
In the Technology objects folder, insert (add) a new technology object.
Select "Motion Control > TO_SpeedAxis"
Give the object (DB) the name "SpeedAxisG120"
c om
n.
sa
ru
bo
@
sa
m
sa
ry

13-46 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 10Exercise
13.11.2 (Online): Parameterizing the Technology Object
10 (ONLINE): Parameterizing the Technology Object

.c
s an
ru
bo
Virtual axis

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

You are to parameterize the technology object with the help of the Wizard, as explained on the
following pages:
ry

Dynamic default values: c om


n.
sa
ru
bo
@
sa
m
sa
ry

13-47 SITRAIN
SIMATIC Programming 2 in the TIA Portal

Emergency stop:

om
Note: The values ‘Emergency stop deceleration’ and ‘Emergency stop ramp-down time’ can
only be set – as shown in the picture – after the maximum speed is set in the following
window (Dynamic limits).

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

Dynamic limits: c om
a n.
r us
bo
@
sa
m
sa
ry

Save your changes!

13-48 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 11 (Online):
13.11.3 ExerciseMC_Servo: cycle
11 (ONLINE): time
MC-Servo: cycle time

om
.c
s an
Cycle time: 16 ms

ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
The calculation of the movement of the TO is done in the OB MC-Servo and MC-Interpolator.
sa

The cycle time of the OB MC-Servo has to be changed executing the program in a simulated
plc.
ry

What to Do
1. Select the OB MC-Servo and open the properies.
2. change the value of the cycle time to 16 ms.
3. Save the project.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

13-49 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 12 (Online):
13.11.4 ExerciseTesting with theTesting
12 (ONLINE): Axis Control Panel
with the axis control panel

om
.c
s an
ru
bo
Current speed
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Task
m

You are to check the parameterization of the technology object with the help of the Axis control
sa

panel.

What to Do
ry

1. Load the previously made changes.


2. Go Online.
3. Open the "Axis control panel" via the Technology object’s function "Commissioning".
4. Activate the master control.
om
5. Enable the axis.
6. Acknowledge pending errors, if necessary.
7. Set a velocity e.g. 500 1/min, the acceleration 1.0 1/s2, the deceleration 1.0 1/s2 and let the
c

drive run forward and backward. Monitor the current speed.


n.

8. Stop and disable the drive.


a

9. Deactivate the master control.


r us
bo
@
sa
m
sa
ry

13-50 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 13Exercise
13.11.5 (online): Copying the Master
13 (ONLINE): Copythe
Copying FB "Drive"
Master Copy FB "Drive"

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

copy the variable "S_slider2" and the Master copy for the FB "Drive".
ry

What to Do
1. Open the global library "Pro2_LIB_Vxx" and the folder "Master copies > Chapter13",
2. Copy the variable "S_slider2" into the already existing PLC tag table “mytags”.
3. Copy the function block "FB_Drive” and open the block.
The required Input and Output parameters, temporary variables and the empty networks
with network comments already exist.
c om
n.
sa
ru
bo
@
sa
m
sa
ry

13-51 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise 14 (online):
ExerciseControlling the Technology
ControllingObject by function blocks

om
13.11.6 14 (ONLINE): the Drive by means of Technology Object

.c
an
Axis moves to the
right
Velocity: 500

s
Acceleration: 10
Acknowledge alarms
Deceleration: 10

ru
Jerk: 0
Direction: 1 Axis stops

bo
Deceleration: 10
Jerk: 0
Axis moves to the
left
Velocity: 500
Enable TO

Read speed (not


@ Acceleration: 10
Deceleration: 10
Jerk: 0
sa
necessary online) Direction: 2
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

The tecvhnology object can be controlled by technology functions. You are to program the
function block "Drive" in such a way that the speed of a drive can be controlled with it. Make
ry

sure that the function block is re-usable.

What to Do
1. Declare the new IN-OUT parameter "speedAxis" of the type "TO_SpeedAxis".
Note: Since the data type "TO_SpeedAxis" cannot be found in the drop-down selection list,
it must be written out.
2. In Network1, with the help of the appropriate technology instruction, program the
acknowledgement of all technology alarms passed to the "speedAxis". Call the instruction
m
as multiple instances and specify the necessary actual parameters.
3. Program the remaining 4 networks with the functions as they are described in the network
co

titles and use the already existing parameters and tags/variables of the block
a. Network 2: call MC_POWER
n.

b. Network 3: not necessary for online courses


sa

c. Network 4: call MC_MOVEVELOCITY to move the axis to the right with the
parameters:
ru

velocity: 500, acceleration: 10, deceleration: 10, jerk: 0


d. Network 5: call MC_MOVEVELOCITY to move the axis to the left with the
bo

parameters
velocity: 500, acceleration: 10, deceleration: 10, jerk: 0
@

e. Network 6: call MC_HALT with the parameters


deceleration: 10, jerk: 0
4. Create a new Program cycle - OB "MainDrive"
sa

5. In it, call “FB_Drive" with the instance "iDB_FB_Drive",


Supply the remaining formal parameters with the relevant actual parameters,
m

6. Compile, save, download and test your program.


sa
ry

13-52 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 15 (Online):
13.11.7 ExerciseTrace: configuration
15 (ONLINE): Trace: parametrization

.c
san
sampling

ru
- Sample with: Main (OB1)
- Recording duration: 20000

bo
Signals
- TO_SpeedAxis_G120.velocity

@
- TO_SpeedAxis_G120.acceleration
- ConveyorOut.K_left
sa
Trigger tag
- ConveyorOut.K_left
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Kapitelnummer- und titel


Task
The velocity can be monitored using the trace.
ry

What to Do
1. Create a new trace.
2. Select the following signals
a. SpeedAxisG120.velocity
b. SpeedAxisG120.acceleration
c. Conveyoroutput.k_left
3. The trace is to be triggered with Conveyorout.k_left
4. The trace should run for 20 seconds
om
5. Load the trace to the CPU.
c
n.
sa
ru
bo
@
sa
m
sa
ry

13-53 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 16 (Online):
13.11.8 ExerciseTrace: monitoring
16 (ONLINE): Jerkmeasurements
Trace = 0 and Jerk= 20
without and with jerk

.c
velocity: 500 1/min velocity: 500 1/min

an
acceleration: 10 1/s2 acceleration: 10 1/s2
jerk: 0 1/s3 jerk: 20 1/s3

s
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Kapitelnummer- und titel


Task
sa

The measurement can show how the movement is influenced by the acceleration and the jerk.
ry

What to Do:
1. After activating the trace the measurement is waiting for the trigger sgnal
2. Start the conveyor belt and put some boxes on the belt.
3. After 20 seconds the measurement is done and the movement is visualized.
4. Change the jerk to the value 20 at the parameters óf the function block
MC_MOVEVELOCITY and MC_HALT.
5. Activate the trace again, start the conveyor belt.
6. Again after 20 seconds the measurement is done and the influence of the jerk can be seen.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

13-54 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
13.12 Appendix
Monitoring
13.12.1 Active Alarms
Monitoring ONLINE
Active Alarms ONLINE

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Description
ry

"Active alarms" displays the currently pending alarms and faults.


• For a fault, the parameterized fault reaction is initiated and the status signal word 1.3 is
sent. In addition, the fault is entered in the Fault buffer. Faults must be acknowledged after
the cause is eliminated.
• For an alarm, the status signal word 1.7 is set. In addition, the alarm is entered in the Alarm
buffer.

Faults and Alarms


om
Fault code / Alarm code Number of the fault / alarm
Message Description of the fault / alarm
Fault time / Alarm time Time stamp that shows when the fault / alarm occurred.
c
n.

Acknowledging Faults
sa
ru

Click on the button in order to acknowledge all active faults.


Faults and alarms are moved to the Alarm history after they have been acknowledged.
bo
@
sa
m
sa
ry

13-55 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Changing
13.12.2 Parameters
Changing in the Inverter
Parameters in the Inverter

.c
s an
ru
bo
Functional parameter groups:
• DI/DO assignment
• Control word structure

@
• Behavior in case of error
...etc.
Parameter lists
P-No. and Value:
• Entire list
sa
• Filtered by function
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Back up parameter assignments


sa

Parameters can be changed through the "Parameter" editor.


ry

Calling the "Parameter" Editor from the Device in the Project Tree
When the online connection is to be terminated, a prompt comes up questioning whether the
data is to be copied to EEPROM (nonvolatile backup of the parameter changes).
If the change is only to be tried for test purposes, you can answer the query for copying
with NO and after a Power OFF/ON, the inverter then works with its previous values.

Calling the "Parameter" Editor from the Online Access


The change of these parameters is immediately written to the EEPROM.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

13-56 SITRAIN
SIMATIC Programming 2 in the TIA Portal
G120 Reset to Factory
Reset toSettings via BOP-2 via BOP-2

om
13.12.3 G120 Factory Settings

.c
Menu "Extras"

s an
ru
Menu function "DRVRESET"

bo
Exit menu

@
ESC / OK
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

13-57 SITRAIN
SIMATIC programming 2 in the TIA Portal

14 Structured Control Language (SCL)

om
.c
Learning objectives
14.1 Learning objectives

an
• You know the application areas of SCL

s
• You know operators and control operation structures

ru
• You know how to commission a given SCL block

bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m
sa
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

14-1 SITRAIN
SIMATIC programming 2 in the TIA Portal

om
14.2 Task Description: Initializing the "Store" and Calculating the
Task Description: Managing
Statistic ValuesWeight
with Values
SCLinBlocks
Weight Store and Displaying

.c
Statistical Values

san
ru
bo
@
sa
346
237
144
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

#tempAutoLeftStop
sa

Task Description
ry

The tasks of "FB_Weight" – to store the weight values of the transported parts in "DB_Weight",
to check whether the Weight storage is full, to calculate the minimum, maximum, average
weight, and the sum of all weights and initialize the data for "P_Operation" ON-OFF – is to be
taken over by a function block written in SCL.
om
.c
an
r us
bo
@
sa
m
sa
ry

14-2 SITRAIN
SIMATIC programming 2 in the TIA Portal

SCL: Programming
14.3 Complex Calculations
SCL: Programming and Algorithms
Complex Calculations and Algorithms

om
Structured Control Language as text-based structured high-level language

.c
• Structured Text
• Complex calculations & algorithms

an
• Examples: Database operations, sorting data
• Program code exchangeable between
S7-1200 and S7-1500 as well as between

s
S7-300, S7-400, and WinAC

ru
bo
@ WinAC
S7-300
S7-1500
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

S7-400
sa

S7-1200
m

S7 SCL
SCL (Structured Control Language) is a PASCAL-similar high-level textual language. It
sa

simplifies the programming of mathematical algorithms and complex data processing tasks for
PLCs. SCL therefore also enables S7 PLCs to be used for more complex tasks such as closed-
loop control or statistical evaluation.
ry

SCL offers the functional scope of a high-level language such as:


• Loops
• Alternatives
• Branch distributors, etc.
m
co
Combined with PLC-specific functions such as:
• Bit accesses to the I/O, memory bits, timers, counters, etc.
n.

• Access to the symbol table


• STEP 7 block accesses
sa
ru
bo
@
sa
m
sa
ry

14-3 SITRAIN
SIMATIC programming 2 in the TIA Portal

om
Advantages of the SCL Programming Language
14.4 Advantages of the SCL Programming Language

.c
Solution in SCL for S7-300/400 AND S7-1200/1500

an
Solution in STL
for S7-300/400

s
ru
Solution in FBD for S7-1200/1500

bo
Solution in STL
for S7-1500

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

Advantages of SCL
• Easy to learn programming language, especially for beginners
• Easy to read (understandable) programs are created.
• Easier programming of complex algorithms and processing of complex data structures
• System integration in S7 languages, such as STL, LAD, and FBD.
• Relatively easy for PLC technicians to understand through similarity with S7 languages.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

14-4 SITRAIN
SIMATIC programming 2 in the TIA Portal

om
Using
14.5an SCLUsing
Network
aninSCL
LAD/FBD Blocksin
Network LAD/FBD Blocks

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

An SCL network can be inserted any time in a LAD or FBD block. For this, the function "Insert
SCL network" in the context menu of the instruction section is used (right-click in the instruction
section).

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

14-5 SITRAIN
SIMATIC programming 2 in the TIA Portal

om
Creating
14.6 an SCL Block
Creating an SCL Block

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Creating an SCL Block


ry

SCL blocks are inserted in the same manner as blocks in the programming languages
LAD/FBD. Depending on the task, SCL blocks can be of the OB, FC, or FB block type.
Even the internal structure in the declaration and statement section is identical to the LAD/FBD
blocks:
Declaration Section:
The IN, OUT, and INOUT parameters as well as the local temporary and local static variables of
the block are declared in the declaration section of a block.
Statement Section:
The statement section contains the instructions that are executed after a code (logic) block (OB,
m
FB, FC) is called. These instructions are used to process data and operands.
co

Note
In programming instructions, the following points must be taken into consideration:
n.

• Each instruction must be completed with a semicolon.



sa

All identifiers (names) used in the statement section must be declared.


ru
bo
@
sa
m
sa
ry

14-6 SITRAIN
SIMATIC programming 2 in the TIA Portal

om
SCL Block Editor
14.6.1 SCL Block Editor

.c
s an
Same interface as in

ru
LAD/FBD/STL Master copies for
Regions (use as
control operation
Networks)

bo
structures

Automatic
indentation of

@ statement sections
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Statement Section
ry

The statement section contains the instructions that are executed after a code (logic) block (OB,
FB, FC) is called. These instructions are used to process data and operands.
Subdivision
The individual instructions can basically be divided into three groups:
• Value assignments:
− They are used to assign an expression or a value to a variable.
• Control instructions:
− They are used to branch within a program or to repeat groups of instructions.
m
• Subroutine call:
− They are used to process functions and function blocks.
co

Note
n.

In programming instructions, the following points must be taken into consideration:


• Each instruction must be completed with a semicolon.
sa

• All identifiers (names) used in the statement section must be declared.


ru

Using Regions as Networks



bo

Code structuring
• Greater clarity & readability
• Easy navigation even in large blocks
@

In addition, there is a synchronized navigation column including the display of syntax errors.
sa
m
sa
ry

14-7 SITRAIN
SIMATIC programming 2 in the TIA Portal
Operators
14.6.2 Operators

om
Syntax: result := expression;

.c
Example: #Q_Average := (#Value1 + Value2) / 2;

an
Logic operation Description Operator
Assignment Assignment :=

s
Parenthesis (Expression) (,)

ru
Negation NOT
Binary logic AND AND, &

bo
operation OR OR
Exclusive-OR XOR
Less than, less than or equal to,
<, <=, >, >=
Comparison @
greater than, greater than or equal
to, equal to, not equal to
=, <>

Plus, Minus (sign) +,-


sa
Addition, Subtraction +,-
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Math Multiplication, Division *, /, MOD


Exponentiation **
m
sa

Expressions
Expressions consist of operands, operators, and round brackets (parentheses). Within an
ry

expression the operators (e.g. +, -, *, /, etc.), that is, the active components of an expression,
are linked with the passive elements such as constants, variables, and function values, in order
to form a new value. An expression therefore stands for the value it represents. SCL permits the
formation of standard expressions, that is, mathematical, logical, and comparative expressions.
Variables from data blocks, arrays, structures, and CPU memory areas (inputs, outputs, etc.)
can be enlisted for the formation.

Operators and Operands


om
Expressions consist of operators and operands. Most SCL operators link two operands
(e.g. A + B) and are therefore termed binary operators. The others work with only one operand
and are thus called unary operators.
c

The result of an expression can


n.

• be assigned to a variable (e.g. A := B + C;)


a

• be used as a condition for a control statement


us

(e.g. IF A< B DO ... )


• be used as an actual parameter for the call of a function or a
function block (e.g. FB20 (Input := A + B))
r
bo
@
sa
m
sa
ry

14-8 SITRAIN
SIMATIC programming 2 in the TIA Portal
Control Operation
14.6.3 Structures Structures
Control Operation

om
There are master copies (so-called code snippets) for the control operation structures!

.c
Keyword Functionality

an
IF Program branching with Boolean value
Program
branching CASE Program branching with INT value

s
FOR Program loop with run variable

ru
Program loops
WHILE Program loop with execution condition
(Abort possible)

bo
REPEAT Program loop with abort condition

CONTINUE Abort current loop pass


Loop aborts
EXIT @ Exit program loop

Block abort RETURN Exit the block


Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Control Instructions
m

These are used for changing the sequence in which the instructions are normally processed.
sa

A choice from the various alternatives in the program execution can be made with conditional
instructions (IF and CASE instructions).
ry

Loop instructions (FOR, WHILE, and REPEAT instructions) are used to repeatedly execute
instructions.
Jump instructions (CONTINUE, EXIT, and GOTO instructions) permit the sequence of
processing to be interrupted and to jump to a resumption point

FB and FC Calls
m
According to the principle of structured programming, other function blocks and functions can
co
also be called from an SCL block.
Callable blocks are:
n.

• Functions and function blocks that were created in SCL or in another STEP 7 language
(STL, LAD, etc.).
sa

• Standard functions and standard function blocks that are supplied with SCL.
• Instructions with and without instance.
ru
bo
@
sa
m
sa
ry

14-9 SITRAIN
SIMATIC programming 2 in the TIA Portal
Direct Addressing
14.6.4 Direct Addressing

om
Direct addressing (absolute and symbolic) for

.c
inputs, outputs, and memory bits is identical to LAD/FBD/STL!

an
Area Notation examples Examples

Bit %DBz.DBXy.x , %Iy.x %DB5.DBX0.7 , %I0.0

s
ru
Byte %DBz.DBBy , %MWy %DB5.DBB2 , %QB2
Absolute
Addressing

bo
Word %DBz.DBWy , %MWy %DB5.DBW4 , %MW20

Double-word %DBz.DBDy %DB5.DBD8

Symbolic
@ "<DB-Symbol>".<Variable-Name> "Motor".Setvalue

<Variable-Name>.%X<Bitnumber>
"Motor".Alarms.%X1
Addressing <Variable-Name>.%B<Bytenumber>
sa
(Bit 1 of the variable
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

<Variable-Name>.%W<Wordnumber>
"Alarms" in DB "Motor")
<Variable-Name>.%D<Doublewordnumber>
m
sa

Direct Addressing
In the statement section of a block, the actions are described that are to be executed with local
ry

operands (parameters or local variables) or global variables (PLC tags or variables in a global
data block). The global variables can be addressed either absolutely or symbolically.

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

14-10 SITRAIN
SIMATIC programming 2 in the TIA Portal
Indirect Addressing

om
14.6.5 Indirect Addressing

Indirect addressing, both for I/Q/M/Peripheral access,


and for variables in data blocks!

.c
Area Instruction Examples

an
Indirect PEEK_BOOL #OUT1 :=PEEK_BOOL(area:=#Memory _area,
Bit
Addressing POKE_BOOL dbNumber:=#DB_Number,

s
BYTE - PEEK byteOffset:=#Byte_addr,

ru
LWORD POKE
bitOffset:=Bit_addr);
WORD PEEK_WORD

bo
POKE(area:= Memory_area,
DWORD PEEK_DWORD
dbNumber:=#DB_Number,
LWORD PEEK_LWORD
byteOffset:=#Byte_addr,

Indexed
Access
Area
@ POKE_BLK

“<DB-
value:=w#16#12);

Array element Symbol>”.<Array- “Motor”.Value[#Index]


sa
Symbol>[Index]
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Indirect Addressing
sa

The instructions PEEK (read) and POKE (write) are used for indirect addressing.
Memory_area, DB_Number, Byte_addr, and Bit_addr are constants, at runtime, changeable
ry

variables, or expressions.
The following memory areas (area) can be addressed in this way:
• 16#81: Input
• 16#82: Output
• 16#83: Memory bit
• 16#84: DB

om
16#1: Peripheral input for PEEK or Peripheral output for POKE (only S7-1500)
If the memory area is not 16#84, then the DB_Number must be specified with 0.
c

Example Poke_BLK:
n.

POKE_BLK(AREA_SRC := "Tag_Source_Area", //Memory area Source


DBNUMBER_SRC := "Tag_Source_DBNumber", //DB-Number Source
a

BYTEOFFSET_SRC := "Tag_Source_Byte"), //Byte number Source


us

AREA_DEST := "Tag_Destination_Area", //Memory area Destination


DBNUMBER_DEST := "Tag_Destination_DBNumber", //DB-Number Destination
r
bo

BYTEOFFSET_DEST := "Tag_Destination_Byte", //Byte number Destination


COUNT := "Tag_Count"); //Number of bytes
@

Array Elements
Array elements can be addressed with a variable Index (Indexed access) at runtime.
sa
m
sa
ry

14-11 SITRAIN
SIMATIC programming 2 in the TIA Portal
Calling an SCL Block
14.6.6 Calling an SCL Block

om
Input parameters and In/Out parameters are identified with :=

.c
Output parameters with =>

an
FC Call FB Call

s
FBD

ru
bo
STL
@
SCL
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

Calling an SCL Block


sa

Depending on the task, SCL blocks can be created as FC or FB. According to the principle of
structured programming, other function blocks, functions, as well as instructions with and
ry

without instance can also be called from an SCL block. In that way, other functions and function
blocks that were created in SCL or in another STEP 7 language (STL, LAD, etc.) can be called.

Note
Functions usually calculate a return value / function value. This function value can be delivered
to the calling block via the output parameter RET_VAL. When a function which supplies a return
om
value / function value (RET_VAL) is called, this return value must be stored in an operand.
<Operand>:=<Function name> (Parameter list);
Functions with return value / function value can also be called directly in an expression. The
c

result of the expression is then formed with the calculated function value. For that reason, in
n.

SCL, the data type ANY is not permitted for the function value.
a
r us
bo
@
sa
m
sa
ry

14-12 SITRAIN
SIMATIC programming 2 in the TIA Portal

om
Useful Function Expansions
14.6.7 Useful Function Expansions

.c
Recursive block call in SCL

an
FC/FB

s
ru
Multiple assignment: Easy assignment of a value to any number of variables.

bo
Multilingual comment:
@
sa
New arithmetic functions:
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

• +=, -=, *=, /=


sa

• For S7-1200/1500
ry

Recursive Block Call


It is possible to call a block recursively. That means that a block can call itself again. Keep in
mind that the call depth is limited to 24 and that no multiple instances can be used.

Multiple Assignment
With the multiple assignment, you can assign the same value to several variables.

Multilingual Comments
By introducing multilingual comments, comments can also be translated with the project
language in SCL.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

14-13 SITRAIN
SIMATIC programming 2 in the TIA Portal
Monitoring SCL Blocks
14.6.8 Monitoring SCL Blocks

om
When a variable is selected, the value

.c
is displayed in the tooltip

an
Always the result of the instruction

s
ru
Not executed instructions are

bo
greyed-out

Display all values of the instruction


@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

When the line is selected, the values


are presented in a popup
sa

Monitoring an SCL Block


ry

Just as in all other programming languages, SCL blocks can be monitored. All values of control
operation instructions are displayed when these are "opened and revealed".
The values of not executed instructions are grayed out.

Special Features of Selected Variables:


In the online mode, a Tooltip displays the value of the variable.
The value of IN-OUT variables is displayed before and after the call of the function.
c om
a n.
r us
bo
@
sa
m
sa
ry

14-14 SITRAIN
SIMATIC programming 2 in the TIA Portal

14.7 Task Description: Initializing the "Store" and Calculating the

om
Task Description:
Statistic Managing
Values withWeight Values
SCL in Weight Store
Blocks
and Displaying Statistical Values

.c
san
ru
bo
346
237
@
144

#tempAutoLeftStop
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

© Siemens 2022 SITRAIN


Task Description
sa

The tasks of "FB_Weight" – to store the weight values of the transported parts in "DB_Weight",
to check whether the Weight storage is full, to calculate the minimum, the maximum, the
average weight, and the sum of all weights and initialize the data for "P_Operation" ON-OFF –
ry

is to be taken over by a function block written in SCL.

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

14-15 SITRAIN
SIMATIC programming 2 in the TIA Portal
Exercise 1: Copying1:the SCL Block
the from the Library

om
14.7.1 Exercise Copying SCL Block from the Library

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

You are to copy the prepared block "FB_Weight_SCL" from the "PRO2_Lib" global library into
your project.
ry

What to Do
1. From the "Master copies > Chapter14" folder of the "PRO2_LIB_Vxx" global library, copy
the "FB_Weight_SCL" block into your project using drag & drop.
2. Save your project.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

14-16 SITRAIN
SIMATIC programming 2 in the TIA Portal

om
Exercise 2:
14.7.2 Exchanging
Exercise the Call of "FB_Weight"
2: Exchanging with "FB_Weight_SCL"
the Call of "FB_Weight" with "FB_Weight_SCL"

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Task
sa

The new block "FB_Weight_SCL" fulfills the same function as "FB_Weight" did previously.
The block is now to be integrated into the program by you.
ry

What to Do
1. In "OB_Cycle", instead of "FB_Weight" call the new block "FB_Weight_SCL". For this, use
the "Change block call" function; by double-clicking on the name of the already called
"FB_Weight" block at the call location.
2. Change the instance via the context menu at the call and give the new instance block the
symbolic name "iDB_FB_Weight_SCL".
3. Compile the program and download all changes into the CPU.
om
4. Open "DB_Weight" and monitor whether all data is correctly written, calculated, and
initialized.
5. Save your project.
c
a n.
r us
bo
@
sa
m
sa
ry

14-17 SITRAIN
SIMATIC Programming 2 in the TIA Portal

15 Programming with S7-Graph

om
Learning objectives
15.1 Learning objectives

.c
an
• You know the application areas of S7-GRAPH

s
• You know the functional principle of S7-GRAPH

ru
• You know how to commission a given S7-GRAPH block

bo
@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m
sa
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

15-1 SITRAIN
SIMATIC Programming 2 in the TIA Portal
The Conveyor Model as Production Line
15.2 The Conveyor Model as Production Line

om
.c
Final Check
and Removal Milling Drilling Start

s an
ru
bo
@
sa
Step 7: Step 6: Step 5: Step 4: Step 3: Step 2: Step 1:
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Removal Transport 3s Milling Transport 3s Drilling Transport Start


m
sa

Task Description
When Automatic mode is switched on and the sequencer is activated, the conveyor model is no
ry

longer to transport parts from the light barrier bay to the next free bay. Instead, the conveyor
model is to transport parts in sequence to the Bays 3, 2, and 1. At each Bay, the parts are
machined for 3 seconds and then automatically transported further. The current part weight is
only passed to the weight store when the part has reached Bay 1 and is removed. As well, the
total quantity is no longer determined from the sum of the individual Bays but equals the number
of parts that arrive at Bay 1 (Final Check).
All other functions (indicator light control, statistics, Min., Max, Sum, and Average values of
weights) are to remain unchanged.
m
Parts Machining with Activated Sequencer
co

Each piece is mounted onto a tool holder at the Start bay (light barrier bay). After pressing the
associated bay pushbutton, the part is transported to the Drilling bay (Bay 3) and drilled for 3
n.

seconds, then transported to the Milling bay (Bay 2) and milled for 3 seconds and finally
transported to the Removal bay (Bay 1) where it can be removed from the production line and
sa

the weight is stored in the weight store.


ru

Sequential Control System


The process can be broken down into individual steps which are executed in a certain, timely
bo

sequence. Tasks of this kind are programmed as sequential control systems. The term
sequential control system therefore does not stand for a particular PLC operating mode but for a
kind of structuring and programming of the user program. Typical application examples where it
is advantageous to program them as sequential control systems are automatic assembly
@

machines, car washes, packaging machines, or traffic light systems – in other words, those
sequences that traditionally were solved with sequence processors.
sa
m
sa
ry

15-2 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
S7-Graph: Programming Sequential Function Operations
15.3 S7-Graph: Programming Sequential Function Operations

.c
Application: The sequence of a process can be broken down into consecutive or simultaneous steps.

an
A sequencer consists of a sequence of steps!

S1

s
Each sequencer has an initial step
Transport Step

ru
bo
T1 Transition = Condition for switching to next step
Transition
Trans

S2
Filling
Step
@ The actions are formulated in a step
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Each sequencer has a sequence end


m
sa

S7-GRAPH
ry

The S7-GRAPH programming language is used to control sequential sequences. The process is
split into single steps with their own function scope. The sequence is represented graphically
and can be documented with pictures and text.
The actions to be performed are defined in the single steps; the conditions for moving on to the
next step are defined by transitions. The definitions of these as well as interlocks and
supervisions are written in a subset of the STEP 7 programming languages LAD und FBD.

Sequencer
Steps and transitions form a sequencer. The sequencer is stored in an FB. An instance DB, that
m
contains the sequencer data, is assigned to this FB. At least three blocks are necessary for an
executable program:
co

• the FB, that contains the sequencer(s)


• an instance DB with the sequencer data
n.

• an organization block, a function block, or a function containing the FB call. The parameters
and the number of the instance DB are passed in the FB call.
sa
ru
bo
@
sa
m
sa
ry

15-3 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Interlock and Supervision
15.4 Interlock and Supervision

om
.c
Alarm

an
Interlock function for querying the
optional
conditions

s
Alarm

ru
Supervision function
for monitoring the step optional

bo
S2 @
Filling Step The actions are formulated in a step
Optional: Action is only executed if the
interlock condition is fulfilled.
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Interlock
An interlock is a programmable condition within a step. If the condition is fulfilled (true), this is
ry

the good case: There is no fault. A protective guard is closed, for example. If you have not
programmed an interlock in a step, this is handled as a good case. Then, an action that is linked
with the interlock is executed. The move to the next step occurs independently of the interlock.
When a step is deactivated, an existing interlock is automatically canceled.

Supervision
A supervision is a programmable condition within a step. For example, consider a container
om
emptying. If the condition is not fulfilled (false), this is the good case. If the condition is fulfilled
(true), the bad case has occurred, which means a fault has occurred. A fulfilled supervision
leads to a fault alarm. You can define the properties and contents of alarms in the "Alarms"
c

pane in the area navigation of the programming window.


The move to the next step only occurs if the supervision error no longer exists and the following
n.

transition is fulfilled. If a step is deactivated, the existing supervision error is automatically


canceled. With that, a step that is not active can also not be faulty.
a
r us
bo
@
sa
m
sa
ry

15-4 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
S7-Graph:S7-Graph:
15.5 Creating a Block
Creating a Block

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Creating an S7-GRAPH Block


S7-GRAPH blocks are created exactly like LAD/FBD/SCL blocks. However, S7-GRAPH blocks
ry

may only be created as FBs.

c om
n.
sa
ru
bo
@
sa
m
sa
ry

15-5 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Sequence View of an S7-GRAPH Block
15.5.1 Sequence View of an S7-GRAPH Block

.c
Sequence view

s an
Drag & drop
instructions

ru
bo
Instructions Symbol Shortcut

Step SHIFT+F5

@ Branch SHIFT+F9
sa
Jump SHIFT+F12
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Sequence end SHIFT+F7


sa

Overview
ry

In creating a sequencer, you are supported by functions for graphic programming. You can
easily create a sequencer’s structure without programming knowledge by arranging the S7-
GRAPH structure elements in such a way that a visual representation of the sequencer results.

Structure of a Sequencer
A sequencer consists of a sequence of steps and transitions. This sequence can be linear or
branched.
• In the steps, the commands to the system are formulated.
• The transitions contain the conditions for the switching from one step to the next.
m
The following symbols show the elements that can make up a sequencer. You can select these
symbols from the toolbar.
co
n.
sa
ru
bo
@
sa
m
sa
ry

15-6 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Programming Steps and Transitions
15.5.2 Programming Steps and Transitions

.c
s an
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

Interlock
The "actions" of a step can be interlocked with a higher-level condition.

Supervision
The actions of a step can be monitored for time. If the step is active longer than the monitoring
time, a fault signal is output and the actions of the step are ended.

Actions
The actions define what is to occur as long as the step is active.

Transition
m
A transition is the condition for switching to the next step. If these conditions are fulfilled, the
actions of the currently active step are deactivated and the actions of the following step are
co

activated.
n.
sa
ru
bo
@
sa
m
sa
ry

15-7 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Testing a Testing
15.6 Graph Sequencer
a Graph Sequencer

.c
Monitor

an
“Testing”
Overview

s
task card
in the
navigation

ru
bo
Track active step:
The active step is
automatically
displayed

Actions @ Additional
sa
Test settings
Logical link of
the transition
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Test Functions
• Display active steps or faulty steps
ry

• Status display and Modify variable


• Switch between the operating modes: Manual, Automatic, and Jog

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

15-8 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
The
15.7Conveyor
The Model as Production
Conveyor Model asLine
Production Line

.c
an
Final Check
and Removal Milling Drilling Start

s
ru
bo
Step 7: Step 6:
@
Step 5: Step 4: Step 3: Step 2: Step 1:
sa
Removal Transport 3s Milling Transport 3s Drilling Transport Start
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

© Siemens 2022 SITRAIN


sa
ry

om
.c
an
r us
bo
@
sa
m
sa
ry

15-9 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Exercise 1: Copying S7-GRAPH Blocks from the Library
15.7.1 Exercise 1: Copying the S7-Graph Block from the Library

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Task
ry

When "P_Operation" is switched on, the conveyor model is no longer to transport parts from the
light barrier bay to the next free bay. Instead, the conveyor model is to transport parts in
sequence to the Bays 3, 2, and 1. At each Bay, the parts are machined for 3 seconds and then
automatically transported further. The part weights are now only to be stored when the part has
reached Bay 1. As well, the total quantity is no longer determined from the sum of the individual
Bays but equals the number of parts that arrive at Bay 1 (Final Check).
All other functions (indicator light control, parts statistics, Min., Max, Sum, and Average values
of weights) are to remain unchanged.
For this, you are to copy the prepared block "FB_Sequencer" and the modified "FB_Statistic"
from the global library "PRO2_Lib" into your project.
om
What to Do
1. In order to save (backup) the current version of "FB_Statistic", copy it in your project library.
.c

2. In the global library "PRO2_Lib", open the folder Master copies > Chapter15.
an

3. Using drag & drop, copy the prepared block "FB_Sequencer" and the modified block
"FB_Statistic" into your project (see picture). In the process, overwrite the already existing
"FB_Statistic" block.
us

4. Save your project.


r
bo
@
sa
m
sa
ry

15-10 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Exercise
15.7.2 2: Commissioning
Exercise the S7-GRAPH
2: Commissioning Block
the S7-GRAPH block

om
.c
s an
ru
bo
-> Delete network,
since the transport
monitoring is
integrated in the
Graph block @
"FB_Statistic" "FB_Weight_SCL"
sa
Update call Adjust actual
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

parameters
m

Task
sa

The call of the "FB_Conveyor" block is replaced with the new "FB_Sequencer". The "FC_Fault"
block is no longer required since the transport monitoring is integrated in "FB_Sequencer". So
that the parts are only counted at Bay 1, in other words, at the end of the production line, the
ry

actual parameters of "FB_Weight_SCL" must also be adjusted.

What to Do
1. Exchange the call of "FB_Conveyor" with the call of "FB_Sequencer".
2. Change the instance of "FB_Sequencer" by creating an instance data block with the name
"iDB_FB_Sequencer" and assign the parameters with the operands shown in the picture.
m
3. In "OB_Cycle", delete the network with the call of "FB_Fault".
4. Adjust the assignment of the formal parameter "NewWeight" of the "FB_Weight_SCL" block
co

in such a way that only one new weight is reported when the conveyor stops at Bay 1 (see
picture).
n.
sa
ru
bo

5. Compile and download the change into the CPU and test the program function.
@

6. Save your project.


sa
m
sa
ry

15-11 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
AdditionalAdditional
15.7.3 Exercise: Returning
Exercise:Parts when Rejected
Returning weight is not OK
Parts

.c
an
Good parts: Rejected parts:
Removal Return 12V

s
ru
0V
Control:
Weight ok?
Part removed at Bay 1 100kg < Weight < 400kg ?

bo
"DB_Conveyor".WeightOK = 1
AND "conveyorIn". B_bay1
A 0.1
Weight: 0 ... 500kg:
Step 6:
„P_Operation"
Removal
at Bay 1
Step 5: Step 4: Step 3: Step 2: Step 1: Step 0:

Step 8:
Removal at
Bay3
OR
Step 7:
Transp to
Bay3
Transp
@ Milling

Milling 3s
Transp

"conveyorIn".b_Bay2
Drilling

Drilling 3s
Transp

"conveyorIn".b_Bay3
Start

"conveyorIn".S_bayLightBarrier
sa
"DB_Conveyor".WeightOK = 0 AND and part at light barrier bay
Part at bay3
"conveyorIn".B_bay1
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Part removed at bay 3


m

Function Up Until Now


sa

After Milling at Bay 2, the machined part is transported to Bay 1 for Removal (Removal at 1)
where it is weighed and removed from the production line – up until now regardless of the
ry

measured weight or the weight set on the simulator potentiometer.

Task
The function of the current program is to be expanded as follows:
Rejected parts, whose weight is less than 100kg or greater than 400kg, must be transported
back from Bay 1 to Bay 3 or to the proximity "ConveyorInput".B_Bay3 for scrapping and
removed there. Good parts with a valid weight remain at Bay 1 "ConveyorInput".B_Bay1" for
Removal.
m
What to Do
co

Expand "FB_Sequencer" with the additional steps. These steps are to be executed as
alternative steps to the already existing step "Removal" (Removal at 1) when the part weight is
not in the required range of 100 to 400kg.
n.
sa
ru
bo
@
sa
m
sa
ry

15-12 SITRAIN
SIMATIC Programming 2 in the TIA Portal

Instroduction STL

om
16

.c
LearningLearning
16.1 objectives objectives

an
• You know the selected STL bit instructions and how to use them

s
• You know the selected arithmetic instructions in STL and FBD and how to use them

ru
• You know the selected instructions for word processing of digital operands in

bo
STL and FBD and how to use them

• You know selected jump functions in STL and FBD and how to use them

@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

16-1 SITRAIN
SIMATIC Programming 2 in the TIA Portal
System Architecture of S7-1500
16.2 System Architecture of S7-1500

om
S7-300/400/WinAC S7-1500

.c
s an
LL DB I/Q/M/C/T L DB
I/Q/M/C/T DB classic non-optimized
non-optimized

ru
L optimized
DB optimized

bo
ACCU 1-4 DB1 / DB2 register ACCU 1-2 DB1 / DB2 register
RLO
OR
/FC
STA
@
AR1 / AR2 register RLO
OR
/FC
STA
AR1 / AR2 register

OV OS OV OS Emulated registers when


sa
CC1 CC0 CC1 CC0 STL is used!!!
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

BR BR
m
sa

Special Features of the Programming Language STL:


With the exception of S7-400 instructions which explicitly refer to ACCU 3/4 of the CPU, all STL
ry

instructions of S7-300/400 are supported by S7-1500.


During the execution of the STL instructions, the S7-300 CPU registers, exclusively necessary
for this programming language, are emulated.
No variables of the dimension 64 bits can be loaded into emulated registers. That means that
these variables cannot be processed with the elementary STL instructions. For this, blocks are
available in the Global library "Long Functions".
om
Note:
You will find the STL instructions in the "Instructions" task card in the "STL Mnemonic" folder.
You will find further information in the FAQ: 67655405 Migration of STL Programs.
c
a n.
r us
bo
@
sa
m
sa
ry

16-2 SITRAIN
SIMATIC Programming 2 in the TIA Portal

S7-1500:
16.3 Using an STL Network
S7-1500: Using in
anLAD/FBD Blocks
STL Network in LAD/FBD Blocks

om
.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

An STL network can be inserted anytime in a LAD or FBD block. For this, the function "Insert
ry

STL network" in the context menu of the instruction section is used (right-click in the instruction
section).

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

16-3 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Creating an STL Block
16.3.1 Creating an STL Block

om
.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Creating an STL Block


STL blocks are inserted in the same manner as blocks in the programming languages
LAD/FBD/SCL. Depending on the task, STL blocks can be of the OB, FC, or FB block type.
ry

The internal structure in the declaration and statement section is identical to the LAD/FBD/SCL
blocks:
Declaration Section:
The IN, OUT, and INOUT parameters as well as the local temporary and local static variables of
the block are declared in the declaration section of a block.
Statement Section:
m
The statement section contains the instructions that are executed after a code (logic) block (OB,
co

FB, FC) is called. These instructions are used to process data and operands.
n.
sa
ru
bo
@
sa
m
sa
ry

16-4 SITRAIN
SIMATIC Programming 2 in the TIA Portal
CSEF11

om
16.4 inBit
Bit Instructions InstructionsHardware
LAD/FBD/STL in LAD/FBD/STL
Sensors and Software Check
Symbols Hardware Sensors and Software Check Symbols

.c
an
Task: In all three examples, the light should be on when S1 is activated and S2 is not activated!
Hardware

s
S1 S2 S1 S2 S1 S2

ru
II1.0
1.0 I 1.1
I1.1 II1.0
1.0 I 1.1
I1.1 I I1.0
1.0 I 1.1
I1.1

bo
Automation system Automation system Automation system
Q 4.0 Q 4.0 Q 4.0

Light Light Light

Software I 1.0 I 1.1


@ Q 4.0 I 1.0 I 1.1 Q 4.0 I 1.0 I 1.1 Q 4.0
sa
LAD
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

& & &


I 1.0 I 1.0 I 1.0
FBD
sa

I 1.1 Q 4.0 I 1.1 Q 4.0 I 1.1 Q 4.0


ry

… I 1.0 … I 1.0 … I 1.0


STL … I 1.1 … I 1.1 … I 1.1
… Q 4.0 … Q 4.0 … Q 4.0

Hardware Sensors and Software Check Symbols in LAD/FBD or Check Operations in STL
The software check symbol "NO contact" represents a check for signal state or Status '1'. If the
checked operand has Status '1', the check supplies the check or result of logic operation (RLO)
'1'. For an operand Status '0', it supplies the RLO '0'.
The software check symbol "NC contact" represents a check for signal state or Status '0'. If the
m
checked operand has Status '0', the check supplies the check or result of logic operation (RLO)
'1'. For an operand Status '1', it supplies the RLO '0'.
co

The check symbols "NC contact" and "NO contact" programmed in the software or in the
program do not give any indication at which input channels of the digital input modules which
n.

type of sensor (NO contact or NC contact) is wired. Each wired NO contact-sensor can be
checked for signal state '0' in the program (with the software check symbol "NC contact" or the
sa

STL instruction "AN") or for signal state '1' (with the software check symbol "NO contact" or the
STL instruction "A").
The independence of the software check symbols "NC contact" and "NO contact" used in the
ru

program from the hardware-based wired NC and NO sensors is also demonstrated by the fact
that every binary operand, for example outputs, memory bits, and Boolean data block variables,
bo

can be checked for signal state '0' or '1' using the software check symbols "NC contact" and
"NO contact" or the STL instructions "AN" and "A".
@
sa
m
sa
ry

16-5 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
16.5 in STL:
Bit Instructions Bit Instructions in STL:
First Check, Signal First
State, Check,
Result Signaland
of Check, State, Result
Result of
of Logic
Operation Check, and Result of Logic Operation

.c
an
Example 1 Example 2 Example 3

Result of Logic Operation


Result of Logic Operation

Result of Logic Operation

Signal State (Status)


Signal State (Status)

Signal State (Status)


ru

Result of Check
Result of Check

Result of Check

First Check
First Check

First Check
bo
:
:
=
A
M 3.4
I 1.0 0
@ 1 1
sa
AN I 1.1 0 1 0
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

A M 4.0 0 1 1
sa

= Q 8.0
ry

= Q 8.1

A I 2.0 0 1 0

Signal State or Status


A logic operation is made up of a series of instructions to check (query) the states of signals
(inputs (I), outputs (Q), memory bits (M), timers (T), counters (C), or data bits (D) ) and
instructions to set Q,M,T,C or D.

Result of Check (Query)


m
When the program is executed, the result of check (query) is obtained. If the check condition is
co

fulfilled, the result of check is "1". If the check condition is not fulfilled, the result of check is "0".

First Check (Scan)


n.

The first check (scan) that follows an RLO limiting operation (such as S, R, CU, =, …) or the first
sa

check in a logic string is called a First Check (FC) since the result of this check - regardless of
the last RLO - is accepted as the new RLO.
ru

Result of Logic Operation


When the next check instructions are executed, the result of logic operation is gated with their
bo

result of check and a new RLO is obtained.


The RLO that is formed in this way is then assigned to an operand as signal state or status at
the end of a logic string, or it serves as the condition for the execution of a result of logic-
@

dependent operation such as Set ("S") or Reset ("R").

Note
sa

The result of a first check (scan) is stored as the result of logic operation (RLO) without further
gating. Therefore, it makes no difference whether you program the first check with an AND or an
m

OR instruction in STL.
sa
ry

16-6 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Digital Operations: Loading and Transferring Data
16.6 Digital Operations: Loading and Transferring Data

.c
s an
Accu 1 Accu 2

ru
XXXX YYYY
CAFE XXXX
CAFE XXXX

bo
CAFE XXXX

@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

MOVE (LAD/FBD)
If no condition is programmed at the input EN, the instruction is always executed.
If a condition is formulated at the input EN, the instruction is only executed if the condition is
fulfilled. The existing value at the input "IN" is then copied into the variable specified at the
output "OUT".
"ENO" is always assigned the same signal state as the one at "EN".

L and T (STL) / ACCU1


The Loading and Transferring of data occurs regardless of the result of logic operation (RLO)
and always refers to the accumulator ACCU1.
During loading with "L", data is loaded into ACCU1. During transferring with "T", the data from
m
ACCU1 is assigned completely or partially to a variable.
co

ACCU2
In the execution of the load instruction, the old content of ACCU1 is first moved into ACCU2;
n.

ACCU1 is deleted (reset to "0") and only then is the new value written in ACCU 1.
sa

Displays of "Value" and "Extra"


Depending of the type of STL instruction, the following is displayed when the test function
ru

"Monitor block" is activated:


The column "Value" shows
bo

• … the status of the operand for bit instructions


• … the content of ACCU 1 for word instructions
@

For word instructions, the column "Extra" can show the ACCU2 contents, address register
contents, DB-register contents, for memory-indirect addressing: the addresses included in the
variables, and, for arithmetic instructions: bits of the processor status word.
sa
m
sa
ry

16-7 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Data Storage in Accumulator 1
16.6.1 Data Storage in Accumulator 1

.c
an
Program Content of ACCU 1

31 23 15 7 0
L MB 0 000000000000000000000000 MB0

s
ru
31 23 15 7 0
Load L MW 0 0000000000000000 MB0 MB1

bo
31 23 15 7 0
L MD 0 MB0 MB1 MB2 MB3

T QD 4 @ QD 4
sa
Transfer T QW 4 QW 4
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

T QB 4 QB 4

General
ry

Accumulators are processor registers for the processing of word and double-word operands,
word logic operations and arithmetic instructions.
S7-1500 has no ACCUs whatsoever. During the execution of an STL program, the 32-bit
ACCUs of an S7-300 are emulated for the relevant STL instructions. For this reason, no
variables of the dimension 64 bit can be processed in the programming language STL.

Load
During loading, all 32 bits of ACCU 1 are always overwritten. The loaded data is always loaded
into ACCU 1 right-justified and the remaining positions are overwritten with ‘0’.
m
Transfer
During transferring, the data in ACCU 1 is copied to the specified target variable, leaving the
co

contents of ACCU 1 unchanged. For that reason, the contents of ACCU 1 can also be
transferred into several variables using successive transfer instructions.
n.

If the specified destination variable is of a dimension of less than 32 bit, the ACCU 1 content is
transferred beginning from the right (see picture).
sa
ru
bo
@
sa
m
sa
ry

16-8 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Swapping the Order of the Bytes in ACCU1
16.6.2 Swapping the Order of the Bytes in ACCU1

.c
an
CAW:
STL

ACCU1-HH ACCU1-HL ACCU1-LH ACCU1-LL

s
V4 V3 V2 V1

ru
bo
LAD / FBD
V4 V3 V1 V2

@
CAD:

V4 V3 V2 V1
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

V1 V2 V3 V4
sa

CAW / SWAP WORD


ry

With the CAW instruction, the bytes in the right data word of ACCU 1 are swapped. That is, the
contents of ACCU1-LH are transferred to ACCU1-LL and vice versa.
With this instruction it is possible to convert a 16-bit number format (INT and WORD) in the
SIMATIC programming language to the number format of the INTEL programming language
(data transfer to PCs).

CAD / SWAP DWORD


With the CAD instruction, the bytes in ACCU 1 are swapped. That is, the contents of ACCU1-
HH are transferred to ACCU1-LL and vice versa or the contents of ACCU1-HL to ACCU1-LH
and vice versa.
m
With this instruction it is possible to convert a 32-bit number format (DINT, DWORD, and REAL)
in the SIMATIC programming language to the number format of the INTEL programming
co

language (data transfer to PCs).


n.

SWAP LWORD
Swapping the bytes of an LWORD (64 bits)
sa
ru
bo
@
sa
m
sa
ry

16-9 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Shift Instructions (Contents of ACCU 1)
16.6.3 Shift Instructions (Contents of ACCU 1)

.c
SLW 2 (Shift left word by 2 positions):

an
0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 1 0 0

(ACCU 1 – H, unchanged) CC1 0 (ACCU 1 – L)

s
ru
0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 1 0 0 1 1 0 0 0 1 0 0

bo
STL LAD / FBD

@
sa
SLD 2 (Shift left double-word by 2 positions):
0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 1 0 0
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

CC1 0 (ACCU 1 – H) (ACCU 1 – L)


sa

1 1 0 0 0 1 0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 1 0 0
ry

SLW <const>, SRW <const>


The instructions Shift Left Word and Shift Right Word shift the contents of ACCU1-L bit-by-bit to
the left or to the right. The contents of ACCU1-H remain unchanged. The bit positions that
become empty are filled with zeroes. The last bit to be shifted out of ACCU1_L to the left or to
the right is loaded into status bit CC1.
The number of bit positions that are to be shifted is determined either as a constant <const> or
when no constant is specified by the value in ACCU2-LL. Values from 0 to 15 are good policy
since larger values always result in ACCU1_L = 0.
The status bits CC0 and OV are reset to "0" if <const> is greater than zero. When <const> is
equal to "0", the shift instructions have no effect (compare NOP 0).

SLD <const>, SRD <const>


m
The double-word shift instructions function like the comparable word instructions with the
co

difference that the entire ACCU1 contents are shifted. Furthermore, the number of bit positions
that are to be shifted may be 0 to 31.
n.

Note on the example shown:


sa

The variable #Sum loaded in ACCU 1 is of the data type INT. Since the value of the variable is
positive (bit no.15 of the variable is = 0), the shifting of the ACCU 1 contents by 2 positions to
the left represents a quadruplication. In the example, this quadrupled value is assigned to the
ru

variable #Sum*4.
bo

SHL / SHR
In the LAD and FBD languages, these functions can be realized with the instructions SHL and
SHR.
@
sa
m
sa
ry

16-10 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Shift Instruction: Example: Separating ColorCode by Shifting
Shift Instruction: Example: Separating ColorCode by Shifting

.c
#Code_Parts: e.g. W#16#A2B3

an
#ColorCode = B

s
ru
STL LAD

bo
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ACCU 2
L #Code_Parts 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 ACCU 1
(e.g. W#16#A2B3)

@
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ACCU 2
SLW 8 1 0 1 1 0 0 1 1 0 0 0 0 0 0 0 0 ACCU 1
sa
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ACCU 2

SRW 12 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 ACCU 1
m

T #Code_Color
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

Problem
ry

In a hexadecimal 4-digit #Code_Parts, one digit is the ColorCode of the part (in the example
= B). The task is now to separate this ColorCode and to assign it to the variable #Code_Color
which then, for example, is to be compared to ColorCode constants.
The problem here is that the ColorCode contained in #Code_Parts as well as every other digit of
the 4-digit #Code_Parts has a dimension of 4 bits which can be addressed neither symbolically
nor absolutely.

Solution:
With the instruction "L #Code_Parts", the entire code (16 bits) of a part is loaded right-justified
in ACCU 1, the left remaining positions of ACCU 1 (not shown in the picture) are overwritten
with ‘0’.
m
With the instruction "SLW 8", the right 16 bits of ACCU 1 are shifted by 8 positions to the left so
that the ColorCode contained in #Code_Parts and which is to be separated is at the extreme left
co

in the Low word of ACCU 1. Through this shifting by 8 positions to the left, all "disruptive" bits
which were to the left beside the ColorCode (that is to be separated) are "shifted out" of ACCU
n.

1.
Then, with the instruction "SRW 12", all "disruptive" bits to the right beside the ColorCode (to be
sa

separated) are "shifted out" and the ColorCode is now right-justified in ACCU 1.
With the instruction "T #Code_Color", the ColorCode which is right-justified in ACCU 1 is
ru

transferred into the destination variable #Code_Color.


bo
@
sa
m
sa
ry

16-11 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal
Digital Operations: Word Logic Operations
16.6.4 Digital Operations: Word Logic Operations

.c
s an
ACCU2 V2 V2

ru
ACCU1 V1 V2 op V1
before op: A.., O.., X.., after

bo
@
STL FBD / LAD
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

Word Logic Operations


Word logic operations gate the contents of ACCU 2 with the contents of ACCU 1 bit by bit (word
by word or double-word by double-word) and overwrite the contents of ACCU 1 with the result of
the logic operation. The contents of ACCU 2 (for S7-400 also the contents of ACCU3 and
ACCU4) remain unchanged.
The operations AND, OR, Exclusive OR (XOR) are available as logic operations.
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

16-12 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Word Logic Operations: Example: Separating ColorCode by Masking

om
Word Logic Operations: Example: Separating ColorCode by Masking

.c
#Code_Parts: e.g. W#16#A2B3

an
#ColorCode = B

s
STL

ru
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ACCU 2
L #Code_Parts LAD
1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 ACCU 1
(e.g. W#16#A2B3)

bo
1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 ACCU 2

L W#16#00F0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 ACCU 1

AW
@
1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 ACCU 2

0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 ACCU 1
sa
1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 ACCU 2
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

SRW 4 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 ACCU 1
m

T #Code_Color
sa

Problem
In a hexadecimal 4-digit #Code_Parts, one digit is the ColorCode of the part (in the example
ry

= B). The task is now to separate this ColorCode and to assign it to the variable #Code_Color
which thenis to be compared to ColorCode constants.
The problem here is that the ColorCode contained in #Code_Parts as well as every other digit of
the 4-digit #Code_Parts has a dimension of 4 bits which can be addressed neither symbolically
nor absolutely.

Solution:
The example shows how, in the first step, the contents of #Code_Color is gated word-by-word
according to AND with the constant W#16#00F0, which serves as a so-called "mask" here.
m
Through the structure of the "mask", all bit positions except those of the ColorCode are =0 in the
result of this AW operation. The ColorCode separated in this way must then only be shifted 4 bit
co

positions to the right before it is assigned to the variable #Code_Color by means of a transfer
instruction.
n.
sa
ru
bo
@
sa
m
sa
ry

16-13 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Word Logic Operations: Example: Word-by-word Edge Evaluation

om
Word Logic Operations: Example: Word-by-word Edge Evaluation

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ACCU 2

.c
L IW 10 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 ACCU 1
Current input statuses

an
0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 ACCU 2
Input statuses of
L MW 20 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 the last cycle

s
0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 ACCU 2

ru
XOW Inputs statuses which
0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0
: have changed

bo
1 0 0 1 ACCU 2 1 0 0 1

L MW 20 0 0 1 1 ACCU 1 L IW 10 1 0 1 0

1 0 0 1 ACCU 2 1 0 0 1

AW
:
@
T #edge_neg
0 0 0 1 ACCU 1 AW
:
1 0 0 0

T #edge_pos
sa
(all falling edges) (all rising edges)
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

L IW 10 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 Save current input statuses..

MW 20 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 … until next cycle


m

T
sa

Problem
An edge evaluation of all 16 bits of an input word is to be done. This is not to be programmed
ry

with 16 individual bit edge evaluations but with a word-by-word edge evaluation consisting of 8
word instructions (for double-word instructions, 32 edge evaluations would be done with these 8
instructions).

Function
With the last two instructions "L IW 10" and "T MW 20", the current input statuses (green) are
temporarily stored in MW20 until the next cycle, in which the current input statuses (green) and
those of the last cycle (gray) are loaded into the ACCUs 1 and 2 with the first two instructions
"L IW 10" and "L MW 20".
m
The result of the following Exclusive-ORing "XOW" (blue) shows which bits of IW10 have
co

changed from 0 to 1 or from 1 to 0 vis-à-vis the last cycle. Changed bits have the status 1 in the
XOW result.
Left Program Path (negative edge evaluation):
n.

The result of the XOW instruction (blue) is ANDed with the input statuses of the last cycle
sa

(MW 20, gray). The result of this ANDing (red) shows which bits of IW 10 have changed from '1'
to '0' (falling edge). Changed bits have the status 1 in the XOW result.
Right Program Path (positive edge evaluation):
ru

The result of the XOW instruction (blue) is ANDed with the input statuses of the current cycle
bo

(IW 10, green). The result of this ANDing (red) shows which bits of IW 10 have changed from '0'
to '1' (rising edge). Changed bits have the status 1 in the XOW result.
@
sa
m
sa
ry

16-14 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Arithmetic Instructions
16.7 Arithmetic Instructions

om
V = Value

.c
ACCU2 V2 V2

an
ACCU1 V1 V2 op V1
before op: +., -., *., /. after

s
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ACCU 2

ru
L #Minuend
0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 ACCU 1
(e.g. 36)

bo
0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 ACCU 2

L #Subtrahend 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 ACCU 1
(e.g. 11) @ 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 ACCU 2

-I (= 25) 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 ACCU 1
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa

0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 ACCU 2

T #Difference 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 1 ACCU 1
m

Arithmetic Instructions
sa

Arithmetic instructions process the value in ACCU 2 with the value in ACCU 1 (according to the
fundamental operations of arithmetic) and overwrite the contents of ACCU 1 with the result of
ry

the operation. The contents of ACCU 2 remain unchanged.


c om
a n.
r us
bo
@
sa
m
sa
ry

16-15 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Jump Functions
16.8 Jump Functions

.c
LAD STL
Jump within

an
a block

conditional

s
ru
absolute

bo
Return to calling block

@ (End execution of current


block)

conditional
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

absolute
sa

Jump Instructions JMP and JMPN


ry

With the jump instructions JMP (JU or JC) and JMPN (JCN) the linear execution of the program
can be interrupted within a block and continued in another network.
With the jump instruction, a Label is specified which also identifies the destination network
(destination instruction in STL). The specified label must be located in the same block and be
unique.
Each label can be jumped to from several locations. The jump can take place in networks with
higher (forwards) or lower numbers (backwards).

Return (End Block Execution) RET


m
With the instruction RET, the program execution of the entire block is ended. The program
execution is then continued in the calling block with the instruction that follows the call of this
co

block.
With the instruction it is specified which status is to be returned to the calling block via its own
n.

ENO output parameter:


• Ret: the current RLO (in the example the comparison result)
sa

• Ret True: always Status '1'


• Ret False: always Status '0'
ru

Absolute or Conditional Execution of the Instructions:


bo

Absolute means that the instruction (JU, BEU) is executed regardless of the current RLO, which
in LAD/FBD is also reflected in the fact that no condition is formulated at the input of the
instruction.
@

Conditional means that the instruction (JC, BEC) is executed only when RLO = '1' (JCN for RLO
= '0'). In LAD/FBD, the RLO is formed through the logic operation programmed at the input of
the instruction.
sa
m
sa
ry

16-16 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Program Loop in STL
16.8.1 Program Loop in STL

om
The way it works Program in STL

.c
Initialize LOOP counter

an
with number
of loop scans

Transfer to

s
BEG:
LOOP counter

ru
Code section to be
executed
several times

bo
Load LOOP counter Iteration
in ACCU1 (end-controlled)

Yes Decrement ACCU1


ACCU1 <> 0 ?
@ Abort
Code

LOOP BEG criterion


sa
fulfilled?
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

No

Continue
m
sa

Loop Instruction
The loop instruction LOOP simplifies the programming of program loops.
ry

For programming a loop instruction, the desired number of loop scans to be executed is loaded
into ACCU1-L. LOOP interprets the right word of Accumulator 1 as unsigned 16-bit number in
the range from 0 to 65535.
With every execution of the LOOP instruction, the value in ACCU1-L is decremented by one.
Subsequently, the value is compared to zero. If the value is unequal to zero, a jump takes place
to the label designated in the LOOP instruction. If the value is equal to zero no jump takes
place, and instead, the immediately following instruction is executed.
m
Note
co

The loop counter must not be initialized with 0, because this would cause the loop to be
executed 65535 times.
n.
sa
ru
bo
@
sa
m
sa
ry

16-17 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Jump List

om
16.8.2 Jump List

.c
s an
ru
bo
@
Alternative
#Bay_No
sa
=1 =2 =3 others
L …#Bay1_Quant L …#Bay2_Quant L …#Bay3_Quant L W#16#FFFF
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

T …#Display T …#Display T …#Display T …#Display


m
sa

Jump List
The JL jump list permits the targeted jumping to a program section in the block dependent on a
ry

jump number. The JL instruction works with a list of JU jump functions. This list follows
immediately after JL and can include a maximum of 256 entries. For JL there is a Label which
points to the end of the list, that is, to the first instruction after the list.
Only JU instructions can be placed between the JL <Label> and the <Label>: <Instruction>. If
"0" is located in the ACCU1-L-L, the first jump instruction is executed, with "1" the second, etc. If
the number is larger than the length of the list, JL branches to the end of the list.
The JL instruction is executed regardless of any conditions.
m
Note
Jumps can be made forward or backward. Jumps can only be executed within one block. That
co

is, the jump instruction and the jump destination must lie in the same block.
The jump destination ("Label") must only exist once within this block.
n.
sa
ru
bo
@
sa
m
sa
ry

16-18 SITRAIN
SIMATIC Programming 2 in the TIA Portal
Overview of the Accumulator Functions
16.8.3 Overview of the Accumulator Functions

om
Instructions that affect several Accumulators

.c
TAK: Toggle (swap) the contents of ACCU1 and ACCU2
• Arithmetic instructions and word logic operations

an
Instructions that only affect ACCU1

s
• INC: Increment the contents of ACCU1-LL

ru
• DEC: Decrement the contents of ACCU1-LL

bo
CAW: Reverse the order of the bytes in ACCU1-L
• CAD: Reverse the order of the bytes in ACCU1
• INVI, INVD: @ Form the ones complement
• NEGI, NEGD, NEGR: Form the twos complement (negation)
• SLW, SLD, SRW, SRD: Shift the contents of ACCU1 to the left or to the right

Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
RLD, RRD: Rotate the contents of ACCU1 to the left or to the right
• RLDA, RRDA: Rotate the contents of ACCU1 to the left or to the right using CC1
m
sa
ry

Accumulator Functions
In the execution of accumulator functions which only affect ACCU 1, ACCU 2 (for S7-400 also
the ACCUs 3 and 4) remains unaffected.
Accumulator functions which affect both ACCU 1 and ACCU 2 always process in the order of
ACCU 2 <operation> ACCU 1.
m
The execution of all accumulator functions occurs regardless of the result of logic operation.
co
For S7-1500, ACCUs 1 and 2 of an S7-300 are emulated. For this reason, in the programming
language STL, only variables of 32 bits or smaller can be processed with the ACCU functions.
n.
sa
ru
bo
@
sa
m
sa
ry

16-19 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal

17 Training and support

.c
an
17.1 Your current and attended trainings
17.1.1 MyTraining – Your personal learning overview

s
ru
The following actions are available to you in MyTraining:

bo
View current and attended training
• Download course materials
• Download certificates

@
• Give feedback
sa
You will find MyTraining at www.siemens.com/sitrain-mytraining.
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

Navigate between all


current and attended
training and qualifications
(e.g. certificates)

Available actions for the


respective training (e.g.
download certificate)
m
co
n.

To find out how to use MyTraining and what all you can do there, watch this video:
sa

www.siemens.com/sitrain-video-mytraining
ru
bo
@
sa
m
sa
ry

17-1 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
17.1.2 Annotating documents

During the training you can add notes to your course materials using a special program.

.c
Annotating documents
You will find this program at: www.siemens.com/sitrain-webannotator

san
www.siemens.com/sitrain-webannotator

ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

c om
a n.
r us
bo
@
sa

The document can only be annotated up to the end of the training. You must then download
your materials in order to hold onto them permanently. Once the document has been
m

Note
downloaded, it can no longer be annotated with the PDF Annotator.
sa
ry

For details on how to use the PDF Annotator, watch this video: www.siemens.com/sitrain-
video-annotations

17-2 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal

17.1.3 Downloading documents and materials

.c
To have your course materials permanently available, you need to download them at the end of
Downloading documents

an
the training. You download them in MyTraining:

s
ru
bo
@
sa
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
ry

m
The course documentation with your annotations is available to you for download for 30
Note
days with annotations and 365 days without annotations after the end of the course.
co
n.
sa
ru
bo
@
sa
m
sa
ry

17-3 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
17.1.4 Downloading certificates

.c
Downloading
You can certificates of participation
download your certificates and
after the end of the other
course certificates
in MyTraining, as well:

s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

17-4 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
17.2 Additional learning offers for advancing your knowledge
17.2.1 SITRAIN enables the learning of tomorrow – today!

.c
SITRAIN offers you a comprehensive range of knowledge on Siemens Industry products –

an
directly from the manufacturer, for all industry sectors and applications, and for beginners and
experts alike.

s
ru
You will find all the important information about our needs-based learning offer at
www.siemens.com/sitrain.

bo
Three learning formats to meet every need

Learning Journey
Die optimale Methodenkombination
@
Learning Membership
Sichern Sie Ihr Wissen ab, durch
Learning Event
Schnell, kompakt und geführt
für einen nachhaltigeren Lernerfolg eigenverantwortliches und Wissen aufbauen.
sa
kontinuierliches Lernen.
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

www.siemens.com/sitrain- www.siemens.com/sitrain- www.siemens.com/sitrain-


learning-journey learning-membership learning-event

© Siemens 20XX | SITRAIN | <Kapitelnummer und -titel>


om
Which learning format is right for you?
Feature Journey Membership Event
c

Typical duration Several weeks 1 year Several days


n.

Share of independent learning ++ +++ +


a

Share of guided learning with a ++ 0 +++


learning consultant
us

Individual coaching by a learning +++ 0 ++


consultant
r

Sustainability of what has been +++ ++ ++


bo

learned

Share devoted to exercises +++ + +++


@

Individual learning pace ++ +++ +

Integration into your work routine ++ +++ +


sa

Diversity of methods +++ + ++

On-demand knowledge availability +++ +++ +


m

Recommendation We recommend a We recommend a We recommend a


Learning Journey for Learning Membership Learning Event for
sa

customers who want for customers who customers who


to take advantage of want to learn especially value fast,
both independent and independently and guided knowledge
guided learning – for continuously. building.
ry

sustained learning
success.

17-5 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
17.2.2 Optimal preparation and follow-up for maximum learning success

.c
Optimal Apreparation andforfollow-up
Learning Membership for
SITRAIN allows youmaximum learning
to optimally prepare for your success
training and
consolidate and reinforce your knowledge afterward. Depending on the topic, you will find a vast

an
collection of E-Learnings here: www.siemens.com/sitrain-recommendations
www.siem
recommen

s
ns.com/sit

ru
recommen

bo
For more

@ advantage
Learning M
sa
www.siem
learning-m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

For more information on the advantages of a SITRAIN Learning Membership, go to:


www.siemens.com/sitrain-learning-membership
om
.c
an
r us
bo
@
sa
m
sa
ry

17-6 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
17.2.3 Finding learning offers

Searching for specific learning offers

.c
How to quickly find the SITRAIN offer that meets your learning needs:
Searching for specific learning offers
www.siemens.com/sitrain-search

s an
https://w
Search for a specific title

ru
learning.
Select learning format en/searc

bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Available dates and registration


sa

Comprehensive training on your


ry

Additional filters Siemens product

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

17-7 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Finding learning paths
With the help of the interactive learning paths, you can find the optimal comprehensive training

.c
Finding for
learning
your Digitalpaths
Industry product.

s an
ru
bo
Recommended

@ sequence for optimal


knowledge building
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

17-8 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Browsing topics
By browsing our learning offers by topic, you can find a wide range of training for your Siemens
product.

.c
Browsing topics

an
You access our learning offers by topic via the SITRAIN homepage. www.siemens.com/sitrain

s
www.siemens.com/sitrain

ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

c om
a n.
r us
bo
@
sa
m
sa
ry

17-9 SITRAIN
SIMATIC Programming 2 in the TIA Portal

17.2.4 Getting advice

om
If you have questions about our offer or about registration, feel free to contact our Customer
Have questions
Support: about the training offer and want advice?

.c
an
Contact form

s
ru
Phone/Email

bo
Regional contacts
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

c om
a n.
r us
bo
@
sa
m
sa
ry

17-10 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
17.2.5 Everything in the palm of your hand – the SITRAIN app

With the SITRAIN app, you have all the important information and functions for your learning
success in a single application.

.c
an
You can download the SITRAIN app for free in your operating system's app store.

s
ru
bo
erything in the palm of your hand – the SITRAIN app

@ Search bar for


Search
finding things
bar for finding
things
quickly quickly
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

Direct
Direct link tolink
the to the course
course overview
overview
for individual
for individual
product
product groupsgroups

Quick links
Quick links
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

17-11 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
17.3 Information and support for the industrial product portfolio
17.3.1 An answers to every question – the Industry Online Support

.c
an
The Industry Online Support provides you with technical information and solutions for all
Siemens industrial products.
Here you will find:

s
• Manuals

ru
• FAQs

bo
• Application examples
• Multimedia content
• Forum for exchanging information with the community
• @
Support Requests to Technical Support
sa
How to access the Industry Online Support: www.siemens.com/online-support
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

IndustryDetailed
Online Support
how-to videos demonstrating the benefits and use of the Industry Online Support can
be found here:
sa
ry

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

17-12 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
17.3.2 Highlights of the Industry Online Support

At a glance – complete product information

.c
Enter –
At a glance thethe complete
article product
number to obtain completeinformation
product information:

san
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

om
.c
an
r us
bo
@
sa
m
sa
ry

17-13 SITRAIN
SIMATIC Programming 2 in the TIA Portal

Your personal work area – MySupport

om
Your personal work
You will find – MySupport
areasettings
all personal and notifications in your MySupport area:

.c
s an
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

By setting up individual notifications and newsletters for yourself, you will stay up to date
regarding your Siemens products. The how-to videos of the Industry Online Support show
ry

Note
you how to store personal messages in MySupport.

m
co
n.
sa
ru
bo
@
sa
m
sa
ry

17-14 SITRAIN
SIMATIC Programming 2 in the TIA Portal

From user to user – the forum

om
In the Industry Online Support Forum, you can quickly access help from and engage in
exchange of information with other users of the industrial product and solution portfolio.
From user
You to find the–forum
canuser theat:forum
www.siemens.com/industry/forum

.c
s an
ru
bo
Simple direct search

@
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

sa
m

The forum provides you with a clear filter structure and many individual settings options, such as
personal notifications.
sa

Enable personal
ry

Search using the notifications


conference and product
tree
m
co
n.

Results list
sa
ru
bo

Personal favorites,
messages and settings
@
sa
m
sa
ry

17-15 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
Always the right software – the compatibility tool
With the compatibility tool, you can quickly and easily check the combinability of your Siemens
products.

.c
an
Always the right
You can software
find the – the compatibility tool
tool at: https://www.siemens.com/kompatool

s
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Manual check of
sa

compatibility using the


compatibility tool Automatic check of
installed products
ry

Operating system
compatibility
om
.c
an

Selected main product


us

Compatible software (hardware)


r
bo

You can find more information and explanatory videos on the compatibility tool in this entry:
@

https://support.industry.siemens.com/cs/ww/en/view/64847781
sa
m
sa
ry

17-16 SITRAIN
SIMATIC Programming 2 in the TIA Portal

17.3.3 Your personal problem solution – Technical Support

om
Have a problem or a question that you are unable to solve using our Industry Online Support
knowledge database? Our Technical Support is ready to help you.

.c
an
Simply send them a Support Request:

s
ru
bo
@
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa
ry

Pay attention to the following when creating your request:


• Is your problem already a known problem? Consult the Industry Online Support knowledge
database and the forum.
• Be precise when selecting your product and avoid choosing "Other".
• Describe your problem in as much detail as possible.
m
• Images and explanatory attachments help our team to better understand your problem.
co

• Check your contact information before sending.


n.
sa
ru
bo
@
sa
m
sa
ry

17-17 SITRAIN
SIMATIC Programming 2 in the TIA Portal

om
17.3.4 Support anywhere at any time – the Industry Online Support app

.c
The free Industry Online Support app is available in your operating system's app store:

s an
ru
bo
Examples of what's available in the app:
• A scan function for quickly capturing the product you are searching for
• Access to the global community for knowledge sharing

• A convenient way to send queries to Technical Support (Support Request)
pport anywhere at any time – the Industry Online Support app
@
A wide variety of entries and products available offline
sa
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

m
sa

Support Requests
Support Requests to to
ry

Technical Support
Technical Support

Search
Search function function

om
.c
an

Scan function
Scan function for for
Siemens products
Siemens products
r us
bo
@
sa
m
sa
ry

17-18 SITRAIN
om
SIMATIC Programming 2 in the TIA Portal

17.4 Links

.c
Here you will find all the relevant links for your learning success summarized in one place:

an
Table 17-1

s
What you need Where you can find it

ru
General overview of the SITRAIN offer SITRAIN – Digital Industry Academy
www.siemens.com/sitrain

bo
Your personal learning overview (including MyTraining
download of materials and certificates) www.siemens.com/sitrain-mytraining

@
Tool for annotating your course materials PDF Annotator
www.siemens.com/sitrain-webannotator
sa
Learning offers with sustained learning success SITRAIN Learning Journey
www.siemens.com/sitrain-learning-journey
m
Private copy for Recep Yigit Samsa, rysamsa@borusan.com

Continuous independent learning SITRAIN Learning Membership


sa

www.siemens.com/sitrain-learning-membership

Fast and concise learning SITRAIN Learning Events


ry

www.siemens.com/sitrain-learning-event

Offers for course preparation and follow-up SITRAIN recommendations


www.siemens.com/sitrain-recommendations

Find specific learning offers SITRAIN course program


https://www.sitrain-
learning.siemens.com/DE/en/search/index.do
Information and support for the industrial product Siemens Industry Online Support
portfolio of Siemens www.siemens.com/online-support

Personal support for your Siemens product Technical Support


https://www.siemens.com/industry/supportrequest
m
co
n.
sa
ru
bo
@
sa
m
sa
ry

17-19 SITRAIN

You might also like