Professional Documents
Culture Documents
SCE EN 030-030 R1209 Datenbausteine PDF
SCE EN 030-030 R1209 Datenbausteine PDF
SCE EN 030-030 R1209 Datenbausteine PDF
SCE Training Curriculum Page 1 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
Please note that these trainer packages may be replaced by successor trainer packages.
An overview of the currently available SCE packages is provided under: siemens.com/sce/tp
Advanced training
Please get in touch with your regional SCE contact for information on regional Siemens SCE advanced training
siemens.com/sce/contact
This training curriculum for the end-to-end automation solution Totally Integrated Automation (TIA) was
prepared for the program "Siemens Automation Cooperates with Education (SCE)“ specifically for training
purposes for public educational facilities and R&D facilities. Siemens AG does not make any guarantee
regarding its contents.
This training curriculum may only be used for initial training on Siemens products/systems. That is, it may be
copied in whole or in part and handed out to trainees for use within the context of their training. Distribution and
reproduction of this document and disclosure of its contents are permitted within public education and further
education facilities for educational purposes.
Any exceptions require written consent from the Siemens AG contact person: Mr. Roland Scheuerer
roland.scheuerer@siemens.com.
Offenders will be liable for damages. All rights reserved, including those relating to translation and in particular
those rights created as a result of a patent being granted or utility model being registered.
Use for industry customers is expressly prohibited. We do not consent to any commercial use of the training
curriculum.
We would like to thank Michael Dziallas Engineering and all those involved for their support in creating this
training curriculum.
SCE Training Curriculum Page 2 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
PAGE:
1. Preface............................................................................................................................................................. 4
2. Notes on programming for SIMATIC S7-300................................................................................................... 6
2.1 SIMATIC S7-300 automation system ......................................................................................................... 6
2.2 STEP 7 Professional V11 (TIA Portal V11) programming software ........................................................... 6
3. Data Blocks of SIMATIC S7-300 ..................................................................................................................... 7
4. Example task for display of storage system stock ........................................................................................... 9
5. Programming the stock display for SIMATIC S7-300 .................................................................................... 10
SCE Training Curriculum Page 3 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
1. Preface
The SCE_EN_030-030 module contents form part of the ‘Advanced functions for PLC programming’
training unit and explain the use of data blocks in SIMATIC S7.
Basics of PLC
programming
Module 10, Module 20
Learning objective:
In this module, the reader will become acquainted with data blocks and create a global data block to
save data in an example project. The TIA Portal will be used for the SIMATIC S7 programming.
Requirements:
SCE Training Curriculum Page 4 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
1 PC Pentium 4, 1.7 GHz 1 (XP) – 2 (Vista) GB RAM, approx. 2 GB of free hard disk space
Operating system Windows XP Professional SP3 / Windows 7 Professional / Windows 7
Enterprise / Windows 7 Ultimate / Windows 2003 Server R2 / Windows Server 2008 Premium SP1,
Business SP1, Ultimate SP1
2 Software: STEP 7 Professional V11 (Totally Integrated Automation (TIA) Portal V11)
3 Ethernet connection between the PC and CPU 315F-2 PN/DP
4 SIMATIC S7-300 PLC, e.g., CPU 315F-2PN/DP with 16DI/16DO signal module. The inputs must
be fed out to a control panel.
2 STEP 7 Professional
1 PC
V11 (TIA Portal)
3 Ethernet connection
4 S7-300 with
CPU 315F 2 PN/DP
SCE Training Curriculum Page 5 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
The SIMATIC S7-300 automation system is a modular microcontroller system for the low and medium
performance range. A comprehensive range of modules is available to optimally adapt the system to the
automation task The S7 controller consists of a power supply, a CPU, and input and output modules for
digital and analog signals. If necessary, communication processors and function modules are also
used for special tasks such as stepper motor control.
The programmable logic controller (PLC) uses the S7 program to monitor and control a machine or a
process. The S7 program scans the I/O modules via input addresses (%I) and addresses their output
addresses (%Q).
The STEP 7 Professional V11 (TIA Portal V11) software is the programming tool for the following
automation systems:
- SIMATIC S7-1200
- SIMATIC S7-300
- SIMATIC S7-400
- SIMATIC WinAC
STEP 7 Professional V11 provides the following functions for plant automation:
- Configuration and parameter assignment of the hardware
- Specification of the communication
- Programming
- Testing, commissioning, and servicing with operational/diagnostic functions
- Documentation
- Creation of visualizations for the SIMATIC Basic Panels using the integrated WinCC Basic
software.
- Visualization solutions for PCs and other panels can also be created with other WinCC software
packages
SCE Training Curriculum Page 6 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
In contrast to code blocks, data blocks contain no instructions. Rather, they serve as memory for
user data.
Data blocks thus contain variable data used by the user program.
Global data blocks store data that can be used by all other blocks.
The maximum size of data blocks varies depending on the CPU. You can define the structure of
global data blocks as required.
Every function block, every function, and every organization block can read the data from a global
data block or write data to a global data block.
The call of a function block is referred to as an instance. An instance data block is assigned to
every call of a function block that transfers parameters. This instance data block serves as a data
memory. It stores the actual parameters and the static data of the function block.
The maximum size of instance data blocks varies depending on the CPU. The tags declared in the
function block determine the structure of the instance data block.
A global data block and an instance data block can be open at the same time.
Different data types (e.g., BOOL or WORD) can be saved in the DBs in any order.
SCE Training Curriculum Page 7 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
Global DB for
all
FBs
BE FCs
OBs
Instance DB
Local data
only FB1
BE
OB = Organization block
FB = Function block
FC = Function
BE DB = Data block
SCE Training Curriculum Page 8 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
Firstly, a global data block ‘DB_stock allocation’ will be created for a small storage system with 8 bin
locations.
In the structure of this global DB, each of the 8 bin locations will be assigned a word. Information
about the contents in the respective bin location will be coded in this word.
Code 0 – Bin location is empty.
Code 1 - Bin location contains black workpiece.
Code 2 - Bin location contains white workpiece.
Code 4 - Bin location contains red workpiece.
The following is preassigned for our ‘DB_stock allocation’:
Bin location 1 == Code 4
Bin location 2 == Code 4
Bin location 3 == Code 2
Bin location 4 == Code 2
Bin location 5 == Code 1
Bin location 6 == Code 1
Bin location 7 == Code 0
Bin location 8 == Code 0
It will then be possible within a program to display the values in this data block at output word ‘P0’ by
selecting the 'S1_LP1' to 'S8_LP8' buttons.
Only one value can be displayed at a time. If more than one button is pressed at the same time,
highest priority is given to displaying the value for switch ‘S8_LP8’ and lowest priority for switch
‘S1_LP1’.
Assignment list:
SCE Training Curriculum Page 9 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
The ‘Totally Integrated Automation Portal’ software is used for project management and
programming.
Components such as control, visualization, and networking of the automation solution are created,
assigned parameters, and programmed here using a standard interface.
Online tools are available for the error diagnostics.
The following steps enable you to create a project for the SIMATIC S7-300 and to program the
solution for the task:
1. The central tool is the ‘Totally Integrated Automation Portal’, which is opened here with a
double-click. ( TIA Portal V11)
2. Programs for the SIMATIC S7-300 are managed in projects. Start by creating a project in the
portal view ( Create new project DB_Storage Create).
SCE Training Curriculum Page 10 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
3. ‘First steps’ for configuring are now suggested. We want to start with ‘Configure a device’.
( First steps Configure a device)
4. Next, we will ‘Add a new device’. Choose the ‘CPU 315F-2 PN/DP’ with the appropriate order
number from the catalog.
( Add new device Program_belt CPU 315F-2 PN/DP 6ES7 ……. Add)
SCE Training Curriculum Page 11 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
5. The software now switches automatically to the project view containing the opened hardware
configuration. Additional modules can now be added from the hardware catalog (on the right!)
and the addresses of the inputs/outputs can be set in the ‘Device overview’. Here, there is one
I/O module with 16 inputs (addresses %I0.0 - %I1.7) and 16 outputs (addresses %Q0.0 -
%Q1.7). ( Device overview DI/DO DI16/DO16 x 24V/0.5A 6ES7 323-1BL00-0AA0
I address: 0…1 Q address: 0…1)
SCE Training Curriculum Page 12 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
6. To ensure that the software will access the correct CPU later, the IP address and the subnet
mask of the CPU must be set. ( Properties General PROFINET interface [X2]
Ethernet addresses IP protocol IP address: 192.168.0.1 Subnet mask: 255.255.255.0)
(see also: SCE_EN_030-010 module on setting the programming interface.)
SCE Training Curriculum Page 13 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
7. Because modern programming uses tags and not absolute addresses, the global PLC tags
must be defined here.
These global PLC tags are descriptive names with a comment for each input and output used in the
program. The global PLC tags can then be accessed later during programming via their names.
These global tags can be used in all blocks anywhere in the program.
In the project tree, select ‘PLC_1 [CPU 315F-2 PN/DP]’ and then ‘PLC tags’. Double-click the
‘default tag table’ to open it, and enter the names for the inputs and outputs as shown below.
( PLC_1 [CPU315F-2 PN/DP] PLC tags default tag table)
SCE Training Curriculum Page 14 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
8. To create the ‘DB_stock allocation’ data block, select ‘PLC_1 [CPU 315F-2 PN/DP]’ and then
‘Program blocks’ in the project tree. Then, double-click ‘Add new block’.
( PLC_1 [CPU315F-2 PN/DP] Program blocks Add new block)
SCE Training Curriculum Page 15 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
9. Select ‘Data block (DB)’ and assign the name ‘DB_stock allocation’. Specify ‘Global DB’ as
the type. The numbering will be automatic. Click ‘OK’ to accept your entries. ( Data block
(DB1) DB_stock allocation Global DB OK)
SCE Training Curriculum Page 16 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
10. Data in a data block must be defined by data types. The following are some of the standard
data types defined in the SIMATIC S7-300:
SCE Training Curriculum Page 17 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
11. The data block is created by entering a symbolic ‘Name’, the ‘Data type’, a ‘Start value’, and a
‘Comment’ for each data element. The ‘Retain’ and ‘Visible in HMI’ characteristics (for
operator systems) can also be selected. The address ‘Offset’ is generated automatically and
cannot be changed.
For our ‘DB_stock allocation’ data block, the following structure applies. This can be entered
directly in a table or in the properties under ‘General’.
Note: Read or write access to the individual data elements of this data block takes place
symbolically using the name of the data block and the name of the data element, separated by a
period. (Example: “DB_stock allocation.LP4”)
SCE Training Curriculum Page 18 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
12. Here we want to create the ‘FC_Display Stock’ function that accesses the data in the
‘DB_stock allocation’ data block. In the project tree, select the ‘PLC_1 [CPU 315F-2 PN/DP]’
and then ‘Program blocks’. Double-click ‘Add new block’. ( PLC_1 [CPU315F-2 PN/DP]
Program blocks Add new block)
SCE Training Curriculum Page 19 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
13. Select ‘Function (FC)’ and assign the name ‘FC_Display Stock’. Specify the ‘FBD’ function
block diagram as programming language. The numbering will be automatic. Since this FC1 will
be called using its symbolic name later, the number does not play an important role. Click ‘OK’
to accept your entries. ( Function (FC1) FC_Display Stock FBD OK)
SCE Training Curriculum Page 20 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
14. The ‘FC_Display Stock [FC1]’ block then opens automatically. The interface of the block must
be declared before the program can be written. In the interface declaration, the local tags
known only in this block are defined.
Block parameters that form the block interface for the call in the program.
SCE Training Curriculum Page 21 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
15. In this example, the tags shown here are specified in the declaration of the local tags. All local
tags should also be provided with a sufficiently descriptive comment for better understanding.
SCE Training Curriculum Page 22 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
16. For programming, we need the ‘MOVE’ instruction from the ‘Move’ folder in the function block
diagram (FBD). Drag this into the desired network. ( Move MOVE)
17. Because the local tags have already been declared, the program can now be entered
completely using the tag names. (Tags are marked by the ‘#’ symbol.) This could appear as
follows for our FBD example.
SCE Training Curriculum Page 23 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
SCE Training Curriculum Page 24 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
18. The next step is to select the ‘Properties’ of the cyclically processed ‘Main [OB1]’ block.
( Main [OB1] Properties)
19. For the ‘Language’, choose the ‘FBD’ function block diagram programming language.
( FBD OK)
SCE Training Curriculum Page 25 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
20. The “FC_Display Stock” block must now be called from the Main [OB1] program block. Double-
click ‘Main [OB1]’ to open this block. ( Main [OB1])
21. The ‘FC_Display Stock [FC1]” block can then be moved into Network 1 of the Main [OB1]
block using a drag-and-drop operation. Don't forget to document the networks in the Main [OB1]
block. ( FC_Display Stock [FC1])
SCE Training Curriculum Page 26 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
22. Now, interconnect the input tags and the output tag with the PLC tags shown here in OB1. The
data elements of the ‘DB_stock allocation’ global data block can be accessed for this using their
SCE Training Curriculum Page 27 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
23. To load your entire program to the CPU, first select the ‘PLC_1 [CPU 315F-2 PN/DP]’ folder
and click the Download to device icon . ( Program_belt )
SCE Training Curriculum Page 28 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
24. In the following dialog, select ‘PN/IE’ as the PG/PC interface type and then a suitable network
card as the PG/PC interface. After a ‘Refresh’ of the accessible devices, you should see your
‘CPU 315F-2 PN/DP’ with address 192.168.0.1 and be able to select this CPU as the target
device. Then, click ‘Load’. ( Type of the PG/PC interface: PN/IE PG/PC interface: ……
Refresh CPU 315F-2 PN/DP Load)
Note: Details on setting the PG/PC interface can be found in the SCE_EN_020-010 module.
SCE Training Curriculum Page 29 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
25. Click ‘Load’ again. The status of the load operation will be displayed in a window. ( Load)
26. The successful load result is now displayed in a window. To place the CPU315F-2 PN/DP back
in RUN mode, click ‘Start all’ and then ‘Finish’. ( Start all Finish)
SCE Training Curriculum Page 30 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300
Industry Sector, IA&DT
27. Click the Monitor all icon to monitor the state of the data elements in the ‘DB_stock
allocation’ data block in the Monitor value column when testing the program.
SCE Training Curriculum Page 31 of 31 To be used only at Educational and R&D Facilities
TIA Portal Module 030-030, Edition 03/2013 © Siemens AG 2013. All Rights Reserved
SCE_EN_030-030_R1209_Data blocks of SIMATIC S7-300