Program example of WWW (S7-1200, S7-1500, S7-1200 G2) - STEP 7

Web server (S7-1200, S7-1500, S7-1200 G2)

ft:publication_title
Web server (S7-1200, S7-1500, S7-1200 G2)
Product
STEP 7
Version
V21
Publication date
11/2025
Language
en-US
Program example of WWW

Introduction

In the following example, you synchronize a user-defined Website with the program example in a CPU S7-1500 and test the program example via a Web server.

Requirement

Create nineteen tags in a global data block for storing the data.

Interconnect parameters - in FB “SLI_FB_www“

You create the following interconnections in an FB "SLI_FB_www": You call the FB in an OB1.

Network 1: Interconnect the parameters of the "WWW" instruction as follows.

Network 2: You create the program for the Website in the FC “SLI_FC_MainWebProg_www“. You then call the FC “SLI_FC_MainWebProg_www“ in network 2 of the FB.

Interconnecting parameters - in FC "SLI_FC_SetTOD_www"

In an FC “SLI_FC_SetTOD_www“ you create a program for using a time-of-day interrupt OB (OB11). You create the following interconnections:

Network 1: In the FC you interconnect the following local tags with the instructions “RD_SYS_T“ and “T_ADD“.

Network 2: This is followed by interconnecting the tags for setting the time-of-day interrupt OB.

The local tag “#startDateTime“ (data type “Date_And_Time”) transfers the start time to the time-of-day interrupt OB.

Network 3: This is followed by interconnecting the tags for activating the time-of-day interrupt OB.

Interconnecting parameters - in the OB “SLI_todOB_www“

In the time-of-day interrupt OB “SLI_todOB_www“ (OB11) you create the following interconnections for cyclic increasing of the tag “tankLevel“.

Interconnecting parameters - in FC "SLI_FC_MainWebProg_www"

You create the following interconnections in the FC "SLI_FC_MainWebProg_www“.

The program “SLI_FC_MainWebProg_www“ allows control of a motor, a valve and the tank filling. In addition to this the output of various interrupt statuses is made possible. The program is controlled via the Web server.

Network 1: You call the FC “SLI_FC_SetTOD_www“ in the FC “SLI_FC_MainWebProg_www“.

Network 2: This is followed by interconnecting the tags for opening the valve.

Network 3: This is followed by interconnecting the tags for starting the motor.

Network 4: This is followed by interconnecting the tags for querying the interrupt status “1“.

Networks 5 to 8: This is followed by interconnecting the tags for querying the interrupt status “2“.

Interconnect the tags for querying the other interrupt statuses in the same way.

Network 9: This is followed by interconnecting the tags for resetting the motor and the filling of the tank..

Network 10: This is followed by interconnecting the tags for resetting all the other values (BOOL).

Setting CPU properties

Make the following settings in the CPU properties:

  • Activate web server access under "... > PROFINET interface > Access to the web server".

  • In “CPU properties > Web server enable the Web server for the module,

  • In the section “User administration“ create a new user with read and write rights.

  • Make the following settings in the section "User pages":

    • You set the “HTML file path”.

      Note

      The storage path should be the same as the path of the Sample Library for Instructions (SLI). The folder name is “SLI_html“. For example: “C:\TIA\_library\SLI_html“.

    • Enter the text "index.html" for the Start HTML page.

    • For the application you enter the name “WWW sample“.

    • Click the "Create block" button. The Web DB (333) and the Fragment DB (334) are then created.

Result for WWW

If the normally open contact ("executeWWW") supplies the signal state "TRUE", the "WWW" instruction is executed. The number of the data block that describes user defined Website is stored via the input parameter CTRL_DB ("333"). The “WWW“ instruction initializes the user defined Website in the Web server of the CPU and immediately synchronizes the program example.

The output parameter RET_VAL ("returnValueWWW") indicates that the processing is running without errors.

Result for the Web server

You call the Web server via the “Internet browser > IP of the Web server”. You log in with your user name user name and -password.

In the Web server in “User pages” a link to the website defined by the user is displayed.

On the Website of the program example it is possible for you to output tags and transfer new values to the tags.

Functions used in the HTML document

Below you will see excerpts of the functions used in the program example with which the tags are transferred to the source code in the HTML document. For each function a tag is implemented via a call in the HTML document and at the relevant location in the HTML document is used with a further call.

Function

To call in the HTML document

To output in the HTML element

Data output:

<!-- AWP_In_Variable Name='"SLI_gDB_www".tankLevel' -->

:="SLI_gDB_www".tankLevel:

Enumeration (value replacement):

<!-- AWP_Enum_Def Name="OpValvValue" Values='0:"Closed", 1:"Opened"' -->

<!-- AWP_Enum_Ref Name='"SLI_gDB_www".valveOutput' Enum="OpValvValue" -->:="SLI_gDB_www".valveOutput:

Value change (from INT):

<!-- AWP_In_Variable Name='"SLI_gDB_www".flowrate' -->

<form method="post" action="" onsubmit="return check();">

<input type="text" name='"SLI_gDB_www".flowrate' size="10px"/>

<input class="button1" type="submit" value="Set flowrate"/>

</form>

Value change (from BOOL):

<!-- AWP_Enum_Def Name="ResetValue" Values='0:"Off", 1:"On"' -->

<form method="post" action="">

<input class="button1" type="submit" value="Reset"/>

<input type="hidden" name='"SLI_gDB_www".reset' size="34px" value="1"/>

</form>