Remote training of programming of PLC with embedded web server

The paper considers a system for remote teaching of PLC programming using virtual controlled objects and controllerembedded web server. The study describes the architecture and capacities of the system and demonstrates examples of virtual lab workbenches. The system can be used to train students and staff.


Introduction
Production automation systems of all kinds find a wide use in today's industry. Most controlling devices in industrial automation systems are represented by programmable logic controllers (PLCs). Therefore, the skill of controller programming is of great importance for specialists in charge of automation, mechatronics, and electrical engineering. As any other skill, this one can be mastered only through some practical activities.

Remote and virtual labs -state of the art
Most universities and professional advancement centers teach to program and maintain PLCs with training workbenches including PLCs and real controlled objects or their physical models. Ural Federal University is no exception. In teaching mechatronics, electrical engineering, and industrial automation, the authors have been using training workbenches based on Simatic S7-300 and S7-1200 PLCs. The workbenches include electric drives, pneumatic drives, hydraulic drives, various analog and digital sensors, and physical models of production mechanisms (such as CNC-machine, distribution conveyor, rotary transfer mechanism, pump station etc.) In terms of teaching quality, it is surely the best option since many even most minute details of equipment can be perceived only through practice. Students also learn installation, commissioning, and diagnostics of automation equipment.
However, such workbenches require considerable costs and room. Some controlled objects there may get depreciated by frequent use or damaged by a wrong control program. Beginning students often have insufficient understanding how certain controlled objects operate, so they may often make critical errors. Every faulty controlled object has to be replaced, since even one invalid element may often prevent starting the entire workbench and proceeding with the lesson.
The fact that maintenance staff have to check the equipment and replace faulty parts means extra costs. The result is extremely high price of training on real equipment. Thus a typical course of PLC programming at a Siemensauthorized training center costs about €1000 excluding travel costs. On top of it is limited throughput capacity of a single workbench and weak opportunities for remote teaching. Though remote access to real equipment is possible [1,2,3,4,5], it needs a webcam to watch the process at least, and permanent attendance of service staff and assistants at most.

EAI Endorsed Transactions
In the meantime, teaching of PLC programming can also rely on virtual training workbenches based on virtual PLCs [6,7,8]. For example, a simulator of Simatic controller PLCSim [7] makes it possible to imitate input signals, debug programs, and display program output. There are two principal advantages: training needs nothing but a properlylicensed controller programming environment (for Simatic, it is Step 7 or TIA Portal); both classroom and remote trainings are possible. However, in this case, the controlled object exists only in a student's mind which is to compare the input/output values of the simulator to the real parameters of the process. A beginning programmer often has trouble deriving such a correlation, especially when a student has no experience in working at a real industrial facility. PLC simulator is rather a tool of an experience developer who prefers creating a program while sitting in a comfortable conditions without having to spend much time at the facility when they have to commission the system stooping over a laptop. Of course, simulator is not a real PLC, so many aspects related, for example, to PLC cycle timing will be omitted.
Mixed architecture of training workbench is also available:  -a PLC simulator combined with real or virtual controlled objects [8];  -a real PLC combined with virtual controlled objects [9,10,11].
The first option features almost the same advantages and drawbacks as a sole simulator, except that a program running is visualized due to a real or virtual controlled object. As for real controlled objects, they show the disadvantages of the classic training workbenches as mentioned above. The second option deals with a real PLC and all its properties. Training is instructive and allows remote access. Therefore, remote training complexes including virtual models of controlled objects and real PLCs provide great reduction of costs: there is no need to purchase and maintain lab workbenches or organize remote access [11]. As a result, teaching of PLC programming becomes more affordable for people.
Of course, it is nothing new. In particular, the authors have had experience of teaching with some Russian solutions (SAU-MAKS [9] and Cosim [10]) that bound a real PLC to a virtual controlled object. However, both complexes were not quite suitable for remote teaching, since they required some software installed on a local PC which had to be connected to the PLC through COM port. Purchasing these complexes is feasible only as an extra option to automation training kits.
Proceeding from the available experience and the analysis of possible options, we set the goal of the project -to create a training complex suitable for remote training with the highest possible realism.
We have selected the system based on a real PLC working with virtual controlled objects. To enable remote training, a PLC-embedded web server was used. What new in this solution is that when using a web server, one does not have to purchase or develop extra soft for data exchange among the PLC, the virtual controlled object, and the user PC. Our solution requires minimum software on the client's side, since all they need to communicate with the system is a web browser.

Implementation
The test model of the system was based on a Siemens S7-1200 PLC that we had in stock.
All Siemens S7-1200 PLCs, v2.0 and higher, have an embedded web server with its own interface capable of remote diagnosing of PLCs by means of a regular web browser. Web server supports both standard and userconfigured pages.
Standard html pages allow access to:  information about the available PLC modules;  information about network addresses, physical properties of communication interfaces, network statistics;  diagnosing message buffer;  data registration files saved to the CPU memory or a memory card;  the update center of the OSs and embedded software of the modules. The embedded interface allows to read and edit PLC variables. This function is of great value because a mindlessly edited variable may cause an equipment breakdown. For security reasons, unauthorized users are not allowed to edit variables. Standard web interface is displayed on tablets and smartphones with no problem.
To handle tasks not supported by standard pages, custom pages can be added. HTML, JavaScript, CSS are all supported. On custom pages, a user can read and even edit PLC variables.
In CPU Settings, enable web server and add calling WWW-function to the project. WWW-function is shown in Fig. 2. The tutorial [12] describes how to set up S7-1200 PLC web server.
After that, a user can call PLC variables with special commands.
With the PLC-embedded web interface, a user can cope with most tasks from any remote device having a web browser. It greatly facilitates PLC operation and enables remote activities.  In developing a remote training system, we set the following goals:  to create logic models of actuators and sensors;  to create animated films showing changes in the state of the created models;  to create virtual training workbenches based on the created logic models and animation films;  to connect the created virtual training workbenches to PLC via the embedded web server;  to create tasks to the virtual models and teaching guidelines to them.
Each virtual training workbench consists of multiple virtual objects (button switches, toggles, drives, sensors, signal lamps etc.) interacting with each other and the PLC. The behavior model of a virtual controlled object, being similar to that of a real processing object, gets animated to monitor changes. The virtual workbench reads PLC output signals and, proceeding from the readings, changes the state of the virtual objects. Virtual objects can change the PLC output signal values, so the PLC can detect when the virtual sensors are triggered. Virtual models use the following algorithm: in infinite cycle, PLC output variables are read with a certain periodicity; then, depending on those readings, the system changes the parameters indicating the state of the virtual actuators; the system checks if the virtual sensors have been triggered; if necessary, their state is changed and the new outputs are overwritten to the output PLC variables; then the new states of the virtual controlled objects are displayed. The flow diagram of this process is given in Fig. 3.
The system has been developed in html, javascript, and CSS and with the use of jQuery. A file of minified/normal jQuery version is too big to be downloaded to the PLC, so we used a special packed version of this library. Virtual objects were visualized with HTML5 canvas that redrew an object every 40 ms to afford smooth animation.
A web page with training workbench downloaded to the PLC has access to the values of the PLC output/input variables.

Figure 2. WWW function
Since virtual workbenches involve only such memory segments as process-input image and process-output image, the physical PLC inputs/outputs are not involved. Therefore, the web server and the entire system need only PLC CPU module, no extension signal modules. A cheapest CPU, like 1211 C, is enough for that. This feature can be used to build sophisticated virtual workbenches requiring many input/output channels.
To edit variables through web page, a user needs to log in to the web server. Output PLC variables cannot be changed directly. To do it, the system needs to create intermediate variables and change their values using web interface. After that, the values of these variables are assigned to the values of the PLC output variables. In our project, intermediate variables are stored in a special data block (named "WD").
For update of variable values without page reloaded, each variable should have its own page from which its values will be read with Ajax technology.
The functions assigning values to input variables and the WWW-function linking the web page to the PLC are detached to a separate function block, WWW-BLOCK. WD and WWW_BLOCK are protected with password, so a student will not change them, either voluntary or accidentally.
On each workbench, a virtual PLC reads, with a certain periodicity, values of the output variables of a real PLC and records them as its own properties. At a high reader frequency, the PLC receives too many calls; it fails to process them and consequently enqueues them. Then data is delayed, and such a delay gets longer with each new reading iteration. The numerous features introduced when developing the program reduced undelayed reading periodicity from 1 s to 70 ms. The project used a reading periodicity of 80 ms that was quite appropriate.
The following virtual training lab workbenches were created  pneumatic drives;  carriage with reversible electric drive;  rotary workbench;  pump station;  tank with level sensor;  distribution station;  mechanic arm;  press with auxiliary mechanisms;  sorting conveyor;  processing center.  Fig. 4 is a sorting conveyer. This workbench uses two monostable pneumatic drives of the pushers, two bistable pneumatic drives of the pushers, and one non-reversible electric drive of the conveyer. The workbench is equipped with digital sensors at the end points of each pusher, an analog sensor of part dimensions, part proximity sensors for each of the four positions, toggles and buttons. On the conveyer, a user can feed parts of various dimensions. The task is to write a program for coordinated control of the pushers and the conveyer resulting in sorting of parts by a predefined parameter (for example, sorting out by dimensions, or sorting out every Xth part).
Another training workbench is based on processing center. This workbench uses a step electric drive to rotate the table, two monostable pneumatic drives of the pusher, a reversible electric drive of the press and a reversible electric drive of the drilling machine. The workbench contains digital sensors at the end points of each pusher, the press, and the drilling machine; part proximity sensors for each of the four positions on the rotary table and in the initial position; toggles and buttons. A user can feed a part to the initial position. The task is to write a program for coordinated control of the pushers, the rotary table, the press, and the drilling machine to provide sequential processing of parts.

Application
A student works in a preconfigured TIA Portal project containing web pages of training workbenches and blocks required for interaction with them. A student has to supplement the existing project with a program to operate a selected virtual controlled object and to upload this project to the PLC. A user's PC can be directly connected to the PLC if in the institute lab or if a user has access to their own PLC (as often happens when factory staff is trained) For remote training, a student accesses the PC with TIA Portal installed via the Internet. However, if a user has their own software, the program can be downloaded from a user's PC to the PLC directly.
To evaluate the program output, a student (either from PC or with remote access) uses a web browser to connect the PLC web server with static IP. Then they log in, open the page of the necessary training workbench and watch the results of their program running. Now, we are testing the teaching system and collecting feedback from our students. Even now, it can be preliminarily concluded that a remote access system is a good option because that students can access real equipment only for limited time.

Conclusions
The proposed remote training system based on Simatic S7-1200 PLC and virtual controlled objects can be used to teach specialists in industrial automation, mechatronics and electrical engineering. Among the prospects for further development, we regard: -creation the editor for teacher to make virtual workbenches of standard components without participation of the system developers; -development of procedures for automated check of task completion on virtual workbenches.
The product has been developed according to the CDIO project education technologies at Nizhny Tagil Technological Institute of Ural Federal University.