Академический Документы
Профессиональный Документы
Культура Документы
Creating User-defined
Web Pages on S7-1200 /
S7-1500
SIMATIC STEP 7 (TIA Portal), S7-1500
https://support.industry.siemens.com/cs/ww/de/view/68011496
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 2015 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.
Table of Contents
Warranty and Liability .............................................................................................. 2
1 Preface ............................................................................................................ 4
2 Automation Task ............................................................................................ 5
3 Automation Solution ...................................................................................... 6
3.1 General solution overview.................................................................. 6
3.2 Advantages and application options of web server applications.......... 7
3.3 Procedure for creating user-defined web pages at a glance ............... 8
3.4 Structure of the application ................................................................ 9
3.5 Hardware and software components ................................................ 10
4 Principles of Standard Web Pages .............................................................. 12
5 Functional Mechanisms of this Application ................................................ 13
5.1 Functional principle of the S7 program ............................................. 13
5.1.1 Startup (OB100) .............................................................................. 14
5.1.2 Main (OB1) ...................................................................................... 14
5.1.3 TankSimu (FB1) .............................................................................. 14
5.2 Functional principle of the HTML file ................................................ 16
5.2.1 AWP commands .............................................................................. 16
5.2.2 Outputting CPU variables ................................................................ 17
5.2.3 Outputting texts via enumerations .................................................... 17
Siemens AG 2015 All rights reserved
5.2.4 Setting variables in the CPU with value and button .......................... 17
5.2.5 Setting variables in the CPU via button only ..................................... 18
5.2.6 Logging on directly on user-definable web pages ............................. 19
5.2.7 Creating time-optimized HTML pages (optional) ............................... 21
5.2.8 Language switching ......................................................................... 24
6 Configuration and Settings .......................................................................... 25
6.1 Procedure for creating a web page .................................................. 25
6.2 Web server settings and generating of the data blocksWeb
server settings and generating of the data blocks............................. 25
6.3 Configuring the hardware ................................................................. 26
6.4 Creating the variables in the variable table or DB ............................. 29
6.5 Creating the HTML files ................................................................... 29
6.6 Web server settings and generating of the data blocks..................... 30
6.7 Creating, compiling and loading of the S7 program .......................... 32
7 Installation .................................................................................................... 34
7.1 Hardware and software installation .................................................. 34
7.2 Installation of the application example.............................................. 35
8 Operating the Application ............................................................................ 36
9 Related Literature ......................................................................................... 41
9.1 Bibliography..................................................................................... 41
9.2 Internet link specifications ................................................................ 41
10 History .......................................................................................................... 42
1 Preface
Objective of the application
The application on hand shows you how to simply and quickly create your own web
pages for S7-1500.
Advantages
Integrated web server
The standard web pages for simple display of services and diagnostic
information are activated with a click. Additionally, individually created, user-
defined web pages can be generated.
Location-independent
The web page can be called up world-wide via a standard internet browser.
Siemens AG 2015 All rights reserved
Application example
Universal usage of the application for all controllers
Benefits
No additional hardware and software required.
The access to the web server is possible across large distances via mobile
communication devices such as tablet PC, smart phone, etc..
Reduced working hours through simple activation of the web server
Time saving in planning and implementing your automation solution through
simple adaptation of the application on hand
Note The application example as well as the web server should not and cannot
replace an HMI system.
2 Automation Task
Overview of the automation task
Modern automation technology increasingly integrates internet technologies which
together with an integrated Ethernet-based communication enable, for
example, direct access to the system via the intranet. During the test and
commissioning phase, the commissioning engineer wants to have flexible access
to the CPU; individual data is to be visualized during operation for diagnostic
purposes.
For access mechanisms via the internet or intranet it is reasonable to use already
existing standards, such as, for example, http technology, standard web browsers
and common "languages" such as HTML (Hypertext Markup Language) or
JavaScript.
Remote access
Industrial Ethernet
Controller 2
Controller 1
Controller 3
3 Automation Solution
3.1 General solution overview
Schematic layout
SIMATIC CPUs with PROFINET interfaces provide the opportunity to access CPU
variables with the help of web pages provided by the system.
Access the web server of the CPU via a web browser. The web server contains
standard web pages, such as start page, identification, diagnostic buffer, module
status, messages, communication, topology and file browser. A detailed description
of the setup of the standard web pages is available in entry 59193560; it is not
subject of this application document. In addition to the standard web pages, you
can also design and call the web pages individually for your application case.
The web server with the web page is already integrated in the CPU.
To create your web page (user-defined web page), you can use any tools such as
Microsoft Frontpage, Notepad++, etc.. For designing your web page, you can use
all options provided to you by HTML, CSS (Cascading Style Sheets) and
JavaScript.
In addition, there is the Automation Web Programming (AWP) command for
directed communication with the CPU.
The following figure gives an overview of the implemented solution.
Siemens AG 2015 All rights reserved
Client with
webbrowser
Request PROFINET
Website Industrial
Ethernet
S7-Program
-blocks
-
STEP7 HTML-file
(TIA-Portal)
CPU 1511-1 PN/DP
as Webserver
HTML-Editor
- HTML-Datei
In this application example, the CPU simulates a tank which can be controlled
through the website.
However, due to the missing time deterministic of web applications, the use of the
web server is not a full-fledged substitute for an operator control and monitoring
system. The replacement of a HMI system is therefore not the aim of this
application!
Table 3-1
No. Instruction
1. With an HTML editor, you create the HTML file for the user-defined web page.
2. The web application can consist of various source files, e.g.: *.html, *.gif, *.js,
3. The HTML files with images etc. are stored in data blocks with SIMATIC STEP 7
V12. Call the WWW instruction in the S7 program
5. Open the web page of the CPU via a web browser. Accessing the web server of
the CPU can be irrespective of the configuration computer. Every output device
with access to the PN interface of the CPU can display the web page.
Delimitation
This application is an introduction to user-defined web pages for beginners. Shown
are simple methods for accessing the web page of a CPU with HTML and SIMATIC
STEP 7 V12.
This application does not include a complete description of HTML. To gain deeper
knowledge of HTML and JavaScript, please refer to the literature and internet
pages specified in Chapter 9 Related Literature.
Hardware components
Note For this application, you require the current firmware version of the CPU.
Depending on the CPU type, the following entries contain links to the
corresponding downloads:
S7-1500:
http://support.automation.siemens.com/WW/view/en/56926947/133200
S7-1200:
http://support.automation.siemens.com/WW/view/en/104546617/133200
Table 3-2
Component No. Order number Note
CPU 1516-3 PN/DP 1 6ES7516-3AN00-0AB0
or
Siemens AG 2015 All rights reserved
Software components
Table 3-3
Component No. Order number Note
SIMATIC STEP 7 V13 1 6ES7822-1A.03-.. -
SP1 Update 4
1)
The following web browsers were explicitly tested for communication with the
CPU:
Internet Explorer (version 11)
Mozilla Firefox (version 31.0)
Siemens AG 2015 All rights reserved
Note The application is optimized for Internet Explorer 11.0. For the use of other
browsers, adjustments may have to be made.
Log in
Siemens AG 2015 All rights reserved
The user with the name "Anybody" is the default setting in the user list. This user
has minimum access rights (read access to the intro and start page). The access
rights of user Everybody can be extended. User Everybody has been defined
without password.
In order to use the full functionality of the web pages, you need to be logged in.
Log on with a user name and password defined in the web configuration of
STEP 7. Then you can access the web pages enabled for this user with the
appropriate access rights.
The input fields for login can be found in the top left corner of each standard web
page.
A detailed description of the setup of the standard web pages is available in the
59193560; it is not subject of this application document.
Startup [OB100]
The following symbols and variables are used in the Web2Plc data block:
Siemens AG 2015 All rights reserved
In the Startup (OB100) OB, a start value for the Flowrate and the limit values
for the variables are stored.
In FB1, the filling or emptying of a tank is simulated, dependent on the flow rate
and the valve position.
The block is only run once every second.
The user can define the flow rate via the flowrate variable on the web page. The
tank filling level is increased or reduced with the flow rate when calling FB1. The
current filling level is stored in the tankLevel PLC variable.
Via the two PLC variables openValve and closeValve, the valve position is
read in and stored in the CPU in the statusValveCPU PLC variables.
Dependent on the tank filling level, the following heights are displayed:
Tank has been fully drained (TankLevelLack)
Tank filling level is at minimum (TankLevelMinimum)
Tank filling level is 50 % (TankLevelMidth)
Tank filling level is at maximum (TankLevelMaximum)
Tank is overflowing (TankLevelOverflow)
Via the alarm variable, the tank filling level is output in clear text (also as
enumeration)
StartStop status
Only when the startStop is set, the tank filling level changes and values are
entered in the ring buffer.
Valve status
Via the statusVentilCPU bit, the button pressed last (OpenValve or CloseValve)
is memorized.
Siemens AG 2015 All rights reserved
Alarm status
Subsequently, the tank filling level is compared with the specifications for the limit
values of the tank filling level.
Depending on the filling level reached, the values "0" to "5" are stored in the
alarm variable. With the value of the alarm variable, HTML texts (enumerations)
are stored, which display the filling level of the tank in clear text.
With the TimeToString function a time stamp is created as string from the local
time. With the CopyData function the value pairs are copied in the ring buffer.
Basics
AWP commands are inserted as HTML comments in HTML files. AWP commands
can be located at any position in the HTML file. However, for reasons of clarity it is
appropriate to list the central AWP commands at the beginning of the HTML file.
Explanations
Table 5-1
Code Explanation
<!-- AWP_In_Variable All variables transferred to the CPU must be
Name='"Web2Plc".start' --> identified as AWP_In_Variable.
Note: Keep in mind that the quotation marks are
nested. The variable is written between
quotation marks and framed by an inverted
comma (' " " ').
Explanations
Variables of the CPU are always displayed via the symbol name:
Figure 5-4 Representation of tags in the HTML file
Instead of TankLevel, always the current value from the CPU is output on the
web page.
Explanations
Via enumerations, texts can be allocated to the individual values of a CPU variable.
Figure 5-5 Representation of enumerations in the HTML file
Instead of the individual values of "Alarm", the previously assigned texts in HTML
are output. These texts stored as enum-type "AlarmValue" and are transferred to
Siemens AG 2015 All rights reserved
Basics
To be able to transfer variables to the CPU via the web page, you have to work
with forms and, for example, the "POST" method.
Explanations
Figure 5-6 Representation of entries in the HTML file
Table 5-2
Code Explanation
<form method="post" action="" Calling the form with the post method. Under
onsubmit="return check();"> action, no details are required since with
<input type="text" id="wert1" action the current page is called by default.
name='"Flowrate"' size="2" With the calling onsubmit event handler, the
style="height: 45px; width: 50px;
check() function is executed that is defines in the
font-size: 21px; text-align: center;
JS file. With a click on submit, the function
padding: 8px;">
checks whether the input is in the range of 1 to 10.
<input type="submit"
If this condition is met, the check() function
value="Set a new Flowrate"
reports back TRUE otherwise the return value is
style="height: 45px; width: 200px">
FALSE and an additional message is output.
</form>
With input type="text", an input field is
linked, whose content is sent to the web server of
the CPU with submit (only if check() = TRUE).
submit is controlled via a button called "Set a
new Flowrate".
Basics
To assign variables in the CPU a predefined value, you have to work with a form,
the "POST" method and a hidden value.
Explanations
Figure 5-7 Representation of buttons in the HTML file
Table 5-3
Code Explanation
<form method="post" action=""> Calling the form with the post method. Under
<input type="submit" action, no details are required since with
value="OpenValve"> action the current page is called by default.
<input type="hidden" With input type="hidden", the "OpenValve"
name='"OpenValve"' size="20px" variable is assigned the value 1, the "CloseValve"
value="1"> variable the value 0.
<input type="hidden" With submit, the values of the variables are sent
name='"CloseValve"' size="20px" to the web server of the CPU.
value="0">
</form>
<form method="post" action=""> Reverse action to the row above: calling the form
<input type="submit" to assign the value 1 to "CloseValve" and the
value="CloseValve"> value 0 to "OpenValve".
<input type="hidden"
name='"CloseValve"' size="20px"
value="1">
<input type="hidden"
name='"OpenValve"' size="20px"
value="0">
</form>
Siemens AG 2015 All rights reserved
Basics
In order to write variable to the CPU, you must generally be logged in at the web
server of the CPU. Login is not necessary if you wish to grant write rights to the
user-defined pages for user Everybody. However, this cannot be recommended
from the point of view of plant security. The login window is available in the top left
corner of the standard web pages. The login-window was integrated on the user-
defined web pages so you need not change to the standard web pages for the
login.
Explanations
Figure 5-8 Login on user-defined web pages in the HTML file
Siemens AG 2015 All rights reserved
Table 5-4
Code Explanation
Creating time-optimized HTML pages is not described in the manuals of the S7-
1500. The idea behind refreshing via JavaScript is that of a sub-web page being
integrated into the user-defined web page. This is done with a so-called inline
frame (iFrame). In order to fetch new values from the controller, not the complete
web page is reloaded but only the sub-web page in the inline frame. This has the
advantage that only few data needs to be called by the controller. If, for example,
pictures are used on the main page, they need not be requested from the controller
for each refreshing, which they do in both of the other introduced mechanisms.
Refreshing via JavaScript therefore causes a low data transmission which may
also have a positive effect on the network load as well as the cycle time of the
controller. The concept is displayed in the figure below.
Update_DataOpti.html
Read variable
Siemens AG 2015 All rights reserved
DataOpti.html
Start_Stop_buttons.html
Write variable
Table 5-5
No. Description
1. There is a user-defined HTML page (below called main page) to be displayed. In
this application this is the DataOpti.html HTML page. It is not refreshed.
2. This main page does not include variables. All control variables to be read or to
be written are packed in additional HTML files (here Update_DataOpti.html and
Start_Stop_buttons.html), which on their part are embedded as frames
(iframe) in the main page. Only the individual frames are refreshed.
3. The Update_DataOpti.html file contains two tables. In the second line of the first
table, the update time is given in milliseconds (e.g. 1000). From the second line
of the second table on, the left column contains AWP commands of the variable
to be read (e.g. :="Data_Buffer".Data[1].Data_Struct.TimeStamp:).
The right column contains the respective IDs (e.g. TimeId1). The IPs must be
unique. The main page DataOpti.html contains the entered IDs instead of the
AWP commands of the variable to be read. I.e., in order to use an element for
the update, the "ID" attributes must be entered and pre-assigned with the
respective ID name (e.g. id="TimeId1"). The separate HTML file
Update_DataOpti.html is embedded as frame (iframe, see point 2) in the
main page DataOpti.html. The respective syntax is as follows:
<iframe src="Update_DataOpti.html" style="display:none;" />
The display:none CSS property, noted for the frame, prevents its display on
Siemens AG 2015 All rights reserved
5. For input variables forms are inserted in separate HTML files. The HTML files are
embedded as frames in the main page. Several forms can be written in a HTML
file.
Note The Update_DataOpti.html file can be adapted to your application with little
effort. You only need to enter your variable with the respective ID into the second
table. On your main page you replace the variable with the respective ID. This
does not require any changes at JavaScript.
Further information on this topic is available at the following FAQ:
62543256
Table 5-6
Step Function
1.
2. The file lang.js has to be located in the scipt folder. This JavaScript
file contains the function DoLocalLanguageChange which controls the
language switching.
3.
These two lines can be found in the header of each visible HTML file.
Content-Language specifies which language is used.
The JavaScript file lang.js controls the language switching.
4.
4.
5. Creating, compiling and loading of the S7 program
Allow HTTP
Allow HTTPS
Siemens AG 2015 All rights reserved
Table 6-3
No. Action Comment
1. Create the HTML files with an Detailed information on the creation of the HTML file can be
editor. Save the HTML files with found in chapter 5.2 Functional principle of the HTML file.
the required images, style sheets
and scripts in the "\html"
directory.
Note:
When assigning read access to
user-defined pages for user
Everybody, then you can call
the user-defined pages directly
with your web browser, e.g.
http://192.168.0.1/awp/Applic
ationname/Start.html
of via the CP with
http://192.168.80.1/awp/Appli
cationname/Start.html.
Table 6-5
No. Action Comment
1. If you are using a CP module,
you have to log on to it first.
(Device configuration -> CP-
Modul -> Properties -> Security -
> User login)
Siemens AG 2015 All rights reserved
2. Compiling
User the mouse to right-click on
the CPU 1516-3 PN/DP and
select Compile > Hardware and
software (only changes).
3. Loading project The dialog window for setting the PG/PC interface is only
Right-click on the displayed during the first loading.
CPU 1516-3 PN/DP and select
Download to device > Hardware
and software (only changes).
Set your PG/PC interface in the
dialog window as follows:
PN/IE
<Network card>
(local) PN/IE
Select CPU 1516-3 PN/DP and
then click on Load.
Note If you want to use a different S7-1500, you have to exchange the CPU under
Devices & Networks. After the exchange, the web server has to be re-enabled
(see 6.6 Web server settings and generating of the data blocks).
Siemens AG 2015 All rights reserved
7 Installation
7.1 Hardware and software installation
Hardware installation
The figure below shows the hardware configuration of the sample application.
The PC with the web browser must be connected to the CPU via Industrial
Ethernet, e.g.
directly at the PN interface of the CPU
directly at communication module CP 1543-1
via a switch
Figure 7-1
PROFINET
Industrial Ethernet
Note Please observe the installation and connection guidelines from the
corresponding manuals.
Table 7-1
No. Action Comment
1. Install STEP 7 (TIA Portal).
Table 7-2
No. Action Comment
1. Unzip the 68011496_S7-
1500_Webserver_CODE_v10.zip file in your project
directory.
6. In the CPU properties, assign the IP address of your CPU Information in Section 6.3
to the Ethernet interface. Configuring the hardware
9. Start a web browser and call the web page of your CPU Information in Section 8 Operating
via the IP address. the Application
Operation
Table 8-1
No. Action Comment
1. Start a web browser, e.g.
the Internet Explorer. Enter
the IP address of the CPU
as the address, e.g.
http://192.168.0.1
or of the CP
http://192.168.80.1
The intro web page of the
CPU is opened.
Click on "ENTER".
Siemens AG 2015 All rights reserved
9 Related Literature
9.1 Bibliography
This table offers you a variety of pertinent literature.
Table 9-1
Topic Title
/1/ HTML HTML und CSS, Praxisrezepte fr Einsteiger
[HTML and CSS, practical recipes for beginners]
Robert R. Agular
mitp
ISBN 978-3-8266-1779-9
Christian Wenz
Galileo Press
ISBN 978-3-8362-1128-4
10 History
Table 10-1
Version Date Modifications
V1.0 02/2014 First version
V2.0 06/2015 The applications Creating and using user-defined web
pages on S7-1200 and Creating and using user-defined
web pages on S7-1500 were merged.
V2.1 10/2015 correction
Siemens AG 2015 All rights reserved