Recipes With S7-1200
Recipes With S7-1200
Recipes With S7-1200
http://support.automation.siemens.com/WW/view/en/94681612
Warranty and Liability
We do not accept any liability for the information contained in this document.
Any claims against us – based on whatever legal reason – resulting from the use of
the examples, information, programs, engineering and performance data etc.,
described in this application example will be excluded. Such an exclusion will not
apply in the case of mandatory liability, e.g. under the German Product Liability Act
(“Produkthaftungsgesetz”), in case of intent, gross negligence, or injury of life, body
or health, guarantee for the quality of a product, fraudulent concealment of a
deficiency or breach of a condition which goes to the root of the contract
Siemens AG 2014 All rights reserved
Security Siemens provides products and solutions with industrial security functions that
informa- support the secure operation of plants, solutions, machines, equipment and/or
tion networks. They are important components in a holistic industrial security
concept. With this in mind, Siemens’ products and solutions undergo continuous
development. Siemens recommends strongly that you regularly check for
product updates.
For the secure operation of Siemens products and solutions, it is necessary to
take suitable preventive action (e.g. cell protection concept) and integrate each
component into a holistic, state-of-the-art industrial security concept. Third-party
products that may be in use should also be considered. For more information
about industrial security, visit http://www.siemens.com/industrialsecurity.
To stay informed about product updates as they occur, sign up for a product-
specific newsletter. For more information, visit
http://support.automation.siemens.com.
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 2
Table of Contents
Table of Contents
Warranty and Liability ................................................................................................. 2
1 Task ..................................................................................................................... 5
2 Solution............................................................................................................... 6
2.1 Overview............................................................................................... 6
2.2 Hardware and software components ................................................... 7
2.2.1 Validity .................................................................................................. 7
2.2.2 Components used ................................................................................ 7
3 Basics ................................................................................................................. 9
3.1 Structure of the memory ....................................................................... 9
3.2 Creating user-defined web pages (AWP)........................................... 10
3.2.1 Basic steps ......................................................................................... 10
3.2.2 Preconditions ...................................................................................... 11
3.2.3 Instruction in HTML code / AWP commands ..................................... 11
3.2.4 Instruction in HTML code / typical instructions ................................... 13
4 Function Principle ........................................................................................... 14
4.1 Program overview .............................................................................. 14
4.1.1 System function SFC 99 “WWW” ....................................................... 15
4.1.2 Function block FB 5 “Filling“ ............................................................... 15
4.1.3 System function block SFB 1003 “RecipeExport” .............................. 16
4.1.4 System function SFC 83 “READ_DBL” .............................................. 18
Siemens AG 2014 All rights reserved
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 3
Table of Contents
10 History............................................................................................................... 47
Siemens AG 2014 All rights reserved
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 4
1 Task
1 Task
Overview of the automation task
In production or process automation, the application of recipes is useful wherever
different variants or compositions of a product shall be produced. The application is
therefore not restricted to the different composition of various content materials.
Recipes can, for example, also be applied to different production processes. For
example, product A is shrink wrapped, strapped and labelled, product B is
packaged, printed on and shrink wrapped.
The application shall illustrate a simplified filling process and work with a recipe
management. Furthermore, the user shall be able to observe the process.
The integration into an existing infrastructure shall be possible without greater
expenses.
The figure below shows a bottling plant:
Figure 1-1
Siemens AG 2014 All rights reserved
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 5
2 Solution
2.1 Overview
2 Solution
2.1 Overview
Schematic layout
The figure below shows a schematic overview of the most important components of
the solution:
Figure 2-1
Siemens AG 2014 All rights reserved
Advantages
The solution presented here offers you the following advantages:
Time and cost saving by simple configuration via TIA Portal and use of already
existing hardware
Expandability
Easy integration into existing systems
Comfortable option to gain an overview of the application or even implement
control functions
Access to the CPU via standard mechanisms, especially relating to the plant -
each CPU can obtain its own page, if required
Access protection for the web server by means of user management
Operating personnel without any automation knowledge is also provided
simple access to the CPU
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 6
2 Solution
2.2 Hardware and software components
Delimitation
This application does not contain a description of recipes with a visualization
system, e.g. WinCC or WinCCFlex
Assumed knowledge
Basic knowledge of S7-1200 and STEP 7 (TIA Portal) is assumed.
Hardware components
Table 2-1
Component No. Article number Note
Power supply PM1207 1 6EP1332-1SH71 Supplies the
components with 24V
DC
CPU 1212C 1 6ES7212-1AE40-0XB0 Alternatively, any other
DC/DC/DC S7-1200 CPU with
Firmware V4.0 firmware 4.0 can be
used
PG/PC with an Ethernet 1 - -
interface
Top hat rail 1 6ES5710-8MA11 483mm
SIMATIC NET, IND. 1 6XV1870-3Q… Ethernet cable
ETHERNET TP CORD
RJ45/RJ45, CAT 6,
TP CABLE 4X2,
PREASSEMBLED
WITH 2 RJ45
CONNECTORS, … …E50
0.5M …H10
1M …H20
2M …H60
6M …N10
10M
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 7
2 Solution
2.2 Hardware and software components
Software components
Table 2-2
Component No. Article number Note
SIMATIC (TIA Portal) V13 1 6ES7822-1AA03-0YA5 Configuration and
STEP 7 Professional/ / programming of the
Basic 6ES7822-0AA03-0YA5 S7-1200
\5\ \6\
Microsoft Excel/ Windows - - Open or change the
Notepad CSV file
Table 2-3
Component Note
94681612_S7- This zip file contains the STEP 7 (TIA
1200_Recipe_CODE_v10.zip Portal) project.
94681612_ S7- This document
1200_Recipe_DOKU_v10_en.pdf
Siemens AG 2014 All rights reserved
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 8
3 Basics
3.1 Structure of the memory
3 Basics
3.1 Structure of the memory
Figure 3-1
Siemens AG 2014 All rights reserved
An S7-1200 is internally equipped with a memory. This is divided into the load and
the work memory. With the CPU 1212C used in the application example, it is
divided into the 50 Kbyte work memory and the 1 Mbyte load memory. To prevent
unnecessary load on the work memory, recipe data are stored in the load memory
whenever possible. With a SIMATIC memory card (SMC) it can be expanded by up
to 2GB on demand. In the example, 2 data blocks are used. The “Active_Recipe”
DB is located in the work memory (contains only one recipe data record), the
recipe DB on the other hand is located in the load memory and contains several
recipe data records. The data is written to a CSV file via the export function and
loaded back into the controller via the import function and there copied internally
with “READ_DBL”.
Note Apart from the “READ_DBL” function there is also the “WRIT_DBL” function
which makes it possible to copy data from a DB in the work memory into a DB in
the load memory.
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 9
3 Basics
3.2 Creating user-defined web pages (AWP)
The following basic steps must be run through to be able to call the AWP via the
menu of the standard web pages:
Note STEP 7 does not perform a verification of the HTML source code!
The maximum file size for HTML files with AWP commands is 64 KB. The size of
your files must not exceed this limit value.
Further notes on the subject of “user-defined web pages” are available in the
“Automation System S7-1200” \3\ manual in chapter 11.6 as well as in the
application example “Creating and using user-defined web pages for S7-1200”
\4\
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 10
3 Basics
3.2 Creating user-defined web pages (AWP)
3.2.2 Preconditions
The following requirements must be met for accessing variables on the web page:
Each variable must be assigned a symbolic name. The variable can only
be displayed on the web page or written to via symbolic names.
The “WWW” (SFC99) instruction must be called (if variables are pre-
processed in the S7 program, a cyclic call is possible)
For variables the standard data types (“DTL” is not displayed), user-
created PLC data types, and structures are permitted.
In the STEP 7 program no further programming is necessary except for the call of
block “WWW”.
Table 3-1
Command Remarks
Siemens AG 2014 All rights reserved
:="Active_Recipe".product.water:
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 11
3 Basics
3.2 Creating user-defined web pages (AWP)
Command Remarks
Writing und General syntax:
sending a
variable <!-- AWP_In_Variable Name='"Variable"' -->
Call:
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 12
3 Basics
3.2 Creating user-defined web pages (AWP)
Table 3-2
Command Remarks
<!-- … --> Comments or AWP command
<form> … </form> Defines a form
<h1> … </h1> Text heading
<input> Creates a form element
<p> … </p> Text paragraph
<script> … Defines an area for scripts (e.g. JavaScript)
</script>
<table> … </table> Table
<tr> … </tr> Table row
<td> … </td> Table column
<br> Line break
Note A previously created HMT(L) page exists for the project in the “Webpage_V10”
folder.
Siemens AG 2014 All rights reserved
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 13
4 Function Principle
4.1 Program overview
4 Function Principle
4.1 Program overview
The call structure for the application example looks as follows:
Figure 4-1
Siemens AG 2014 All rights reserved
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 14
4 Function Principle
4.1 Program overview
The SFC “WWW” is called at the beginning of the user program in OB1 and is used
for initializing the web server. In addition, another (maximal) 3 data blocks DB333 -
DB335 are necessary which are automatically created by the system.
Figure 4-2
Table 4-1
Name Data type Description
Input CTRL_DB DB_WWW Data block, which writes to user-
defined web pages (web control DB)
Output RET_VAL Int Error information
Siemens AG 2014 All rights reserved
FB “Filling” is the processing block of the actual application and is called in OB1.
Figure 4-3
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 15
4 Function Principle
4.1 Program overview
SFB “RecipeExport” can be used for copying the recipe data block into a CSV file
via the user program. This file is then located on the web server and available for
further use.
Figure 4-4
Table 4-2
Siemens AG 2014 All rights reserved
SFB “RecipeImport” enables importing recipes located in a SCV file (on the web
server). The recipes are imported into a DB which is only located in the load
memory of the CPU (internal or SIMATIC memory card).
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 16
4 Function Principle
4.1 Program overview
Figure 4-5
Table 4-3
Name Data type Description
Input REQ Bool Control parameter, activates the
import at rising edge
Siemens AG 2014 All rights reserved
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 17
4 Function Principle
4.1 Program overview
After the import process, the recipes are located in a DB in the load memory. The
user program cannot access these elements. It is therefore necessary to copy the
required information into the main memory. SFC “READ_DBL” realizes this very
process. Only one recipe set can be copied with one call. In this application
example only one active recipe set each is used. This set is then located in DB
“Active_Recipe”. The “Recipe_DB”.products[“GLOB_VAR”.Recipe_no] tag at input
“SRCBLK” is an indirect assignment of the respective recipe set. This notation
enables selecting “Recipe_no” via the HTML page.
Figure 4-6
Siemens AG 2014 All rights reserved
Table 4-4
Name Data type Description
Input REQ Bool 1=read request
SRCBLK VARIANT Pointer to the data block read from, in
the load memory
Output RET_VAL WORD Error information
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 18
4 Function Principle
4.1 Program overview
Data type “Beverage” is a user-created data type and consists of the following
structure.
Figure 4-7
Siemens AG 2014 All rights reserved
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 19
4 Function Principle
4.1 Program overview
Data block “Recipe_DB” is the basis for the application. In this DB, 10 recipe sets
(PLC data type “Beverage”) are continued. At the beginning of the application, only
the first 4 sets are assigned, all of the others contain “0” values. All sets can be
filled up as desired by the user.
The respective recipe values are defined as start values of the elements.
Figure 4-8
Siemens AG 2014 All rights reserved
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 20
4 Function Principle
4.1 Program overview
Data block “Active_Recipe” contains a PLC data type “Beverage” recipe set which
the user (as well as user-defined web pages) accesses or can access respectively.
Figure 4-9
Siemens AG 2014 All rights reserved
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 21
4 Function Principle
4.1 Program overview
Figure 4-10
Table 4-5
Siemens AG 2014 All rights reserved
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 22
4 Function Principle
4.1 Program overview
The “STEP” function realizes the transfer to the next step. Each element is filled
individually and represents one step.
Figure 4-11
Table 4-6
Name Data type Description
Input beverage Uint Amount of the current element
done_seq Bool 1=current step run through?
seq_compare Uint Current step of the sequence
Siemens AG 2014 All rights reserved
Function block “CHECK” checks whether a new recipe set was added on the HTML
page and then automatically triggers the copying process. Copying is necessary to
receive the correct recipe set in DB “Active_Recipe”. The IN/OUT parameter
“new_recipe” shows with “1”, that a new recipe set has been selected. This bit is
processed further in the program.
Figure 4-12
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 23
4 Function Principle
4.2 Functionality of the HMT(L) file
Table 4-7
Button Description
Start export When pressing these buttons, the “RecipeExport” function is
started in the user program. This process exports the content of the
“Recipe_DB” into a CSV file which is then located in the web server
of the CPU
Start import Clicking this button starts the “RecipeImport” function. The entire
content of the CSV file is imported into the “Recipe_DB”. When
changing the SCV file you need to make sure that not more recipe
sets exist than available in the DB.
Start copy When changing the recipe set, manual copying becomes
necessary.
Send recipe set Select the suitable recipe set to be copied from DB “Recipe_DB”
into DB “Active_Recipe”. To do this, enter the appropriate number
in the field before the button. Pressing the button then sends the
value.
Figure 4-13
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 24
5 Configuration and Settings
5.1 Configuring the S7-1200
4. Select the suitable CPU and drag it into your project via “drag & drop”.
Please note, that this application example requires a CPU firmware equal to or
higher than V4.0 to be able to use the described functions.
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 25
5 Configuration and Settings
5.1 Configuring the S7-1200
No. Action
5. In the CPU properties you select the settings of the web server and activate the
web server with via the check box “Activate web server on this module”.
Siemens AG 2014 All rights reserved
Note: you can define several users with different rights to implement different
access stages. The user “Everybody” is created automatically and has the default
access level “minimal”.
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 26
5 Configuration and Settings
5.1 Configuring the S7-1200
No. Action
7. In menu item “User-defined Web pages” you create the “HTML directory” in which
the AWP is located and in “Default HTML page” the file itself.
Important: for the language “German” you select the HTML “Start_de.htm”, for
English the “Start_en.htm”.
Press the “Generate blocks” button to create the data blocks required for the
Siemens AG 2014 All rights reserved
control. These are available in the project under the system blocks in the
“Webserver” folder.
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 27
5 Configuration and Settings
5.2 Configuring the network connection
Table 5-2
No. Action Note
1. Open the network
connections via “Start
> Control Panel>
Network and Sharing
> Change adapter
settings”.
2. Select the suitable
network adapter and
right-click to call its
properties.
Siemens AG 2014 All rights reserved
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 28
5 Configuration and Settings
5.3 Setting PG/PC interface
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 29
6 Installation and Commissioning
6.1 Installing the hardware
Figure 6-1
Siemens AG 2014 All rights reserved
Table 6-1
No. Action
1. Mount the power supply and the CPU on a top hat rail.
2. Connect the CPU to the 24 V DC supply voltage of the power supply.
3. Establish the bus connection (Ethernet) between CPU and PG / PC.
4. Connect all the protective earth connections (PE) with the protective conductor.
5. Connect the voltage supply (L1, N) with the power supply (230V~).
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 30
6 Installation and Commissioning
6.2 Installing and commissioning the software
Note At this point, it is assumed that the necessary software has already been
installed on your computer and that you are already familiar with handling the
software.
Table 6-2
No. Action Remarks
1. Download the project
“94681612_S7-1200Recipe_
CODE_v10.zip” for this
documentation and unzip it.
2. Open the contained project
“94681612_S7-1200Recipe_
CODE_v10_e.ap13” with
STEP 7 (TIA Portal) V13.
3. In the project navigation you
select the CPU
“PLC1212C_Recipe” and click on
the “Download to Device” button
for download into the CPU.
Siemens AG 2014 All rights reserved
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 31
6 Installation and Commissioning
6.2 Installing and commissioning the software
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 32
6 Installation and Commissioning
6.2 Installing and commissioning the software
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 33
7 Operating the Application
7.1 Calling the web page via the browser
Important:
Calling the user-defined web page is not possible without logging
Siemens AG 2014 All rights reserved
in.
3. Log in at the web server of
the CPU. Several users are
available. For access to the
user-defined web page as
well, type in the user
“siemens” with the password
“siemens”.
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 34
7 Operating the Application
7.1 Calling the web page via the browser
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 35
7 Operating the Application
7.1 Calling the web page via the browser
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 36
7 Operating the Application
7.2 Exporting the recipes in a CSV file
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 37
7 Operating the Application
7.2 Exporting the recipes in a CSV file
During an export, the system always files the CSV file with
the same name on the web server.
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 38
7 Operating the Application
7.3 Changing the CSV file
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 39
7 Operating the Application
7.4 Importing the recipes from the CSV file
4. Click on “Upload file”. This process loads the CSV file into the web server.
5. In the AWP you now click on
the “Start Import” button.
Note: the new values are currently still located in the load
memory and can therefore still not be accessed in the program.
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 40
7 Operating the Application
7.5 Copy a recipe set from “Recipe_DB” in “Active_Recipe” DB
Table 7-5
No. Action Remarks
1. Open the AWP and click on
“Start Copy”.
The program uses SFB “READ_DBL” for this. With this function,
only one recipe set from the “Recipe_DB” is copied to
“Active_Recipe” DB. See chapter 4.1.5.
Siemens AG 2014 All rights reserved
Now you can view the changed values in the bottom part of the
AWP.
Note In connection with the “READ_DBL” function, note the following entry in the
Support Portal: http://support.automation.siemens.com/WW/view/en/51434747.
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 41
7 Operating the Application
7.6 Selecting the recipe set
Note: it is only possible to change the recipe set when the filling
process is not active.
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 42
7 Operating the Application
7.7 Starting and running the filling process
Note The filling process shown in the application is simplified and not represented
correctly.
Table 7-7
No. Action Remarks
1. Select the recipe set as The respective recipe set contains a “setpoint” which specifies
described in chapter 7.6. how many bottles shall be filled.
find the value of the already filled bottles in the “actual value”
field.
3. You can view the current
status in the “Status” field.
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 43
7 Operating the Application
7.8 End of the filling process
The filling process runs automatically after the start. Each recipe set consists of
several elements. For each of these elements a maximum of 100 units is
considered. 10 units correspond to 1 second. In total, the total value of the recipe
set must not exceed 100 (verified in the program). For one bottle, the filling process
corresponds to maximal 10 seconds. The user can “monitor” each valve – an
opened valve corresponds to the value “1”.
Example of recipe set 1:
The elements used here are “water” and “cola”. “Water” has 60 units assigned to it
(corresponds to 6 seconds) and “cola” 40 units (corresponds to 4 seconds). The
total passage would then be 10 seconds. After a passage the number increases by
1 up to the “setpoint”.
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 44
8 Further Notes
8 Further Notes
8.1 Updating the web page
The browser updates web pages automatically. This does not apply to user-defined
web pages.
The refresh time of the web pages depends on the number of tags used.
A manual refreshing can be performed by pressing the “F5” button. In this example,
automatic refreshing of 6 seconds was implemented as follows:
Increasing the resources for the communication in the settings of the CPU may
cause a reduction of the update time.
Figure 8-1
Siemens AG 2014 All rights reserved
Note The refresh time must not be selected to small since otherwise write commands
to tags might not be executed.
For more information, please refer to the application document “Creating and using
user-defined web pages for SIMATIC S7-1200” \4\.
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 45
8 Further Notes
If after entering the IP address of the CPU the message “There is a problem with
this website's security certificate” appears, go to the "Introduction" page and
download the Siemens security certificate, for example for the Internet Explorer, as
follows:
Table 8-1
No. Action
1. Click the "download certificate" link on the introductory page. The dialog window
“File Download – Security Warning” opens.
2. Click the “Open” button in the dialog window “File Download – Security Warning”
to open the file. The dialog window “Certificate” opens.
3. Click the "Install Certificate" button in the "Certificate" dialog, to call the assistant
for importing the certificate.
4. Follow the dialog instructions of the “Certificate Import Wizard” to import the
certificate. Select the "Trustworthy root certificate authorities" certification
storage.
Siemens AG 2014 All rights reserved
The differences between the S7-1200 and the HMI systems are given below.
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 46
9 Related Literature
9 Related Literature
Table 9-1
Topic Title
\1\ Siemens Industry http://support.automation.siemens.com
Online Support
\2\ Download page of http://support.automation.siemens.com/WW/view/de/94681612
the entry
\3\ S7-1200 manual http://support.automation.siemens.com/WW/view/en/91696622
Automation system
\4\ Application http://support.automation.siemens.com/WW/view/en/58862931
“Creating and using
user-defined web
pages for S7-1200”
\5\ TIA Portal STEP7 http://support.automation.siemens.com/WW/view/en/78793685
V13 Trial
\6\ UPD3 for STEP 7 http://support.automation.siemens.com/WW/view/en/90467259
(TIA Portal) V13 and
WinCC
\7\ Application http://support.automation.siemens.com/WW/view/en/82454336
“Quality Assurance
Siemens AG 2014 All rights reserved
by means of
Weighing, Control
and Logging with
the SIMATIC
S7-1200” (set 6)
\8\ STEP7 SIMATIC Automating with SIMATIC S7-1200
S7-1200 Author: Hans Berger
Publicis Corporate Publishing
ISBN: 978-3-89578-384-5
\9\ SELF HTML http://de.selfhtml.org
http://wiki.selfhtml.org/wiki/startseite
10 History
Table 10-1
Version Date Modifications
V1.0 09/2014 First version
S7-1200 Recipes
Entry ID: 94681612, V1.0, 09/2014 47