Boss Mode: Siemens Web Server

This series will give you a foundation to build a fully functional, web-based system with HMI, reporting, recipe management, trending, and dashboard components using only an S7-1200 or S7-1500 PLC, some Javascript and jQuery libraries, and a web-browser. One assumption is you already have some experience with web development, or are willing to dive into a few potentially new concepts. We won’t be breaking down the fundamentals of web development here, just showing what you need to know to get data into the various formats required for the pages to work properly.

This article, the first of the series, will cover configuring the web server and show you how to implement trends in a custom web page using the S7-1200 and S7-1500’s built-in datalogs for historical data.

Why is this useful?

For many OEM systems, using a built-in web server in a PLC can save on hardware costs, software costs, and give you a flexible and powerful way to interact with your equipment. You can avoid the hassle of maintaining a database for storing historical data and still give your users access to the information they need to operate most effectively.

By using web-based development frameworks, you can quickly develop a state-of-the-art, eye-popping system to give you a huge head start on some of the other interface options available to you.


What is a web server?

A web server is simply software you can access with a web-browser. It acts as the gateway between your browser and any underlying systems such as a database, and returns information to you in the form of a web-site. When you access your favorite news site, their web server generates the articles and sends them to your browser. When you configure the web server in your S7-1200 or S7-1500 PLC, it will give you access to datalogs, custom configured web pages you can use for trends, HMI functionality, dashboards, or even recipes.

Let’s dive into the process of configuring the web server in your PLC and show you how to use it in some powerful ways.


Enabling the web server

The first step is to enable the web server. After opening your application, go to your PLC’s Device Configuration menu, select the Web server item in the tree, and check “Activate Web server on all modules on this device”. Compile your project and download to the processor:




After you have enabled the web server and downloaded to the PLC you can access the default page by navigating to your PLC’s IP address in your browser.


Using the default website, you can view the Diagnostic Buffer for your PLC:

and you can access any data log files you may have stored in the PLC:

The real power of the web server comes into play when you enable user pages, or custom HTML pages you can use to interact with your PLC data, and generate things like trends and dashboard controls for detailed data analysis in your browser.


Enabling user pages

The first thing you need to do is create a directory to hold your user pages. In this case we are using a folder called S7_1200_Web on the C:\ drive. Create an HTML file in this directory and put some HTML in so we can verify everything is working properly. For testing this can be the following:

Save the HTML file as index.html and go back to your project. Scroll about halfway down to the Web Server menu in the Device Configuration tab to “User-Defined Web Pages” and enter the directory where your user pages are stored. Also enter the name of the default page, in this case we will use index.html. You can also enter your application name which will become part of the URL used to access your user pages.

You will also need to add the file extensions we will be using to the “Advanced” section to enable to PLC to generate the proper program blocks so you can access your pages. Typically these will be either .htm or .html, for html pages and .js for javascript files. Enter these extensions in the “Files with dynamic content” box under “Advanced”

By default the PLC will use DB333 and DB334 and so on to store the contents of your user pages. As you add more pages to the directory it will increment the DB number as necessary. If you would like to use a different DB number you can configure these in the “Advanced” section of the Web server configuration, just below the “User Pages” section.

Once you have filled out these sections, click the “Generate Blocks” button to generate the program blocks the PLC will use to store the HTML from your user pages.


You will then see the program blocks created, in this case DB333 and DB334


The final step

The final step to enable user pages is to add the WWW function to your logic. Specify your Web DB number, in this case 333, and a tag for the return value, then compile and download to the processor.

Once you have downloaded your logic with the WWW function, you will see a link to the default user page under “User Pages” on the PLC’s default web page. You can also navigate to the page directly with the following URL format: http://{ip address of PLC}/awp/{Application Name}/{User Page}.html, or for our PLC

Navigating to the page will display the HTML page you requested, in this case we will see a basic trend configured based on a data log file in the PLC. This functionality will be covered later in this article.


Want more?

See the Ultimate MES Guide!

Plus check out Parts Two and Three.