How to publish to HMI Server
Beckhoff HMI/SCADA project is built with Microsoft Visual Studio. We shall describe how to publish the project to the remote server so any client from anywhere can access the HMI/SCADA. We need to install the TF2000 | TC3 HMI Server from the Beckhoff web page. We shall follow the following steps for publishing data to the HMI/SCADA server.
There are two variations of the server:
For non development environment (only the server)
For development environment
We can have some basic information about the client server before publishing the HMI to the server. HMI Server is a program that can manage many clients (depending on the licensing model) in TwinCAT. We as a developer, develop the HMI and then finally push the contents to the server from where a different client can access the content. The general idea is shown in the following picture.
Figure 1: HMI big picture
We must install the license for the server. Beckhoff allows every 7 days a free development license, so for test and development purposes, we can use it conveniently. For the actual product, we must buy the license from Beckhoff. But how to activate the 7 days free license on the server? We shall describe these steps here. One easy way to create a small Beckfoff PLC project and activate the necessary license for 7 days. We can create the project on the server or our client’s computer and push it to the server. In the visual studio project, under license, we can select “Manage License” tab and select all the features we need. After this, we activate the 7 days trial license.
Figure 2: 7 days trial license
=> Install the HMI Server to the remote computer (where we want to run the HMI).
=>Make the HMI Server auto startable by following steps
=> Click Start→All Programs
=> Right-click the Startup folder and click Open. (C:\Users\mylogin_name\AppData\Roaming\Microsoft\Windows\StartMenu\Progras\Startup)
=> Right-click Start and choose Open Windows Explorer.
=> Locate the program (TF2000-HMI-Server) we want to start when we start Windows, then drag it into the startup folder
=> Click the Close button in the upper-right corner of both Explorer windows to close them.
=> Type ‘run’ in the search box, it will pop a dialog where you can insert what to open or run
=> Type shell:startup, this will pop up or open a startup folder
=> Now you can drag and drop the TF2000-HMI-Server shortcut
Now every time when the server computer starts then the Beckhoff HMI/SCADA server starts. If the HMI server does not run in the remote server, we can’t push or upload our project there.
Another way to make the server auto restart is to use the server register as a service (C:\TwinCAT\Functions\TF2000-HMI-Server\register_service), execute this command as admin in the command line.
For a development environment we can use the following server found in the following folder:
This server is started when we lunch an HMI from visual studio. Following image shows the startup folder:
Figure 3: HMI server installation
When we are developing then we need to view the UI frequently for checking how it looks and feels. If we press on the live view as shown in the following image.
Figure 4: HMI live view
When we are happy with step 2 then we can check our HMI by publishing it to the local server. Whenever we have installed the TwinCAT 3 Engineering then by default a local server is launched when we lunch the application. We can test almost all our functionalities by using the development HMI server as shown in the following image. We need to configure the debugger to Google chrome.
Application running, lunched with Visual Studio
Figure 5: Running HMI in chrome
It is the final step about publishing the contents to the server. If we want to publish our application to a local machine (IP: 127.0.0.1) or a remote machine 192.x.x.x/10.x.x.x, in either case, we must have a running server there. To run the server, put a shortcut of the server to the startup folder or run the batch file from the command line.
Figure 6: Installing HMI server as service
=> Now the HMI server will be up and running and we can publish the contents to the server
=> Select TWINCAT HMI Menu in Visual Studio | Publish to TwinCAT HMI Server, we see the following dialog. Press next.
Figure 7: Publishing HMI to HMI server
This step is very important. We need to put the Server IP address and the port. We need to make sure that the used port is free. We might need to change some TCP/IP related settings for the port as shown in the following image. If we are publishing for the first time then it will ask for the password. This password will be asked when the client wants to connect to the server. The connection can be tested by pressing on validate Connection. If the connection is OK then we can finish by pressing on publish button.
If we want to publish the HMI to a local machine, then we use the server address 127.0.0.1
If we want to publish to the remote machine (it must have an HMI server running) then we use the IP address (x.x.x.x) of the server
Figure 8: Checking connection to HMI server
Now we are ready to connect the HMI server to use our HMI. Point to the address https://xx.xx.xx.xx:1020 in Chrome. It will show a login page. We just insert the password and we are in.
Figure 9: Log in to HMI server
Finally we have the HMI running.
Figure 10: Log in to HMI server
We can log in to the localhost of the HMI server and access the config page of the HMI. To do this, we click on the server icon (bottom right corner of the server computer) and then we access the config page. We can do lots of useful configurations there. One of the configurations is how to avoid login names as shown in the following diagram. Authentication required Combobox there are 3 options, if we select none then it will not ask the password. If we select always authenticate then it will ask for the password.
Figure 11: Authentication to HMI
If we are not using SSL then we remove the check from the check box.
Figure 12: HMI port configuration
The configuration, which is transferred to the remote server, can be selected during the publish process. Two configurations are supplied by default:
Default Configuration: Local configuration that is loaded from the Engineering Server (valid in LiveView and when transferred to the Engineering Server).
Remote configuration: Configuration that is transferred to the remote server when publishing.
Tips 00 : Page has been published but variables are not read by the HMI Server
The HMI has been published to the server and all looks fine. But my HMI does not read the variables or does not make any decision based on the PLC data. Here we can have 2 problems and it’s solution.
=> Add the route to the server as described in the page https://www.hemelix.com/automation/structured-text/
=> Enable ADS in the HMI Server as shown in the following image.
=> Login as administrator account
Configure the AmsNetId in the server setting and accept the settings.
Figure 13: Setting AMS Net ID
As we see in the following screenshot that ADS version and Device name are missing. This will not work as I see the AMS Net Id is wrong.
Figure 14: Setting AMS Net ID in the server side
Actual AMS Net Id should be used 192.168.12.56 and press accept. After that we see that ADS version and name has been updated. Learn more about AMS Net Id at https://www.hemelix.com/automation/structured-text-how-to-change-ams-net-id/
Figure 15: Correct view in the Server config mode
We can add an IP address directly to the Webserver settings page as shown in the following screenshot.
Figure 16: Additional address adding to the HMI server
After this our HMI should be able to work properly
01: Make sure that the server in the target computer is running
02: If you are using 7 days license then make sure it is valid
03: Make sure you can ping the server
04: If you are publishing sometimes the visual studio may not show the progress of publishing, in that case, if you press again (assuming it has not started) then the publishing will not work. Be patient and try again.
05: When publishing HMI with extension project then all the dependency DLL will publish to the HMI server without any extra efforts.
06: Starting the HMI Server, we can start the HMI server by putting a short cut of HMIServer.exe to this folder: C:\Users\USER_NAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup, the problem with this is if we login to the server it will have the effect of restarting the server again. To avoid this, run the bat file as admin C:\TwinCAT\Functions\TF2000-HMI-Server\register_service.bat. This will create a windows service that will start when windows start.
07: HMI-Server and HMI Engineering server is different, if we use the service registration batch file then we have to careful as there are 64 bit and 32-bit versions. I noticed at least a 32-bit version worked for me.
08: Check that Windows FireWall is OFF, if you want to keep it ON then you have to open a certain port. When there is Firewall ON then we can see the following dialog when we press on the Check connection button. If we want to keep the firewall ON then we must open the port through Firewall.
Figure 17: When fire wall is ON then we see this dialog when we press on check connection
09: We must have all the necessary license especially if we want to publish an extension module
Figure 18: Necessary licenses for HMI project
We may see the following error code when we have issue with license:
Error User Extension "ServerExtensionCSharp1" is not licensed.
A licence for "TF2200 | TC3 HMI Extension SDK" is required on the remote system to execute user extensions. TcHmiProject1 C:\TwinCAT\Functions\TE2000-HMI-Engineering\MSBuild\Beckhoff.TwinCAT.HMI.targets 42
We need the above license if we want to run and publish to a remote server (for example to a CX device where we want to run HMI and our PLC program etc). We need to activate the license by using VS and the PLC program. Once the PLC program is running with the required license then we can publish the contents to the server as usual way.
10: When we publish content to a remote server especially with an extension, we may see INVALID_SYMBOL or similar error, somehow the TwinCAT server becomes messy, one solution helps if we just restart the HMI server in the remote machine.
11: If there are problems to publish the contents, we can delete the profile and make a new one. That may help to publish when there are confusing cases.
12: It looks like we can’t put 2 PLC addresses in the interface, if there are extra then the unused one can be removed.
13: We can see the following note when we try to publish, we can delete the profile, add route and check if we have duplicate AMS net ID.
Figure 19: Possible errors for publishing the project
14: We can see sometimes the following error at the end of publishing. This is due to that the PLC in config mode. Change mode to run mode and try.
Error Cleanup of extensions ‘MyServerExtensionName’ (MyServerExtensionName) failed. Error cleaning up target server extension configuration, Command Error: Code:265, Message: FILESYSTEM, Reason: Filesystem error
15: We can have errors sometimes that indicate that config file version mismatches, in this case, we can’t publish the extension. See the following screenshot, where our module name is ServerExtensionCSharpOne and the config file is ServerExtensionCSharp:Config. The solution is, we can change the version number in the config file and try again.
There is another way to solve this problem as well.
=> Go to HMI Server’s config page
=> Press on TcHmiSrv tab on the configuration page
=> Press on Extensions, then the extension in questions and delete (upper right corner cross)
=> Publish it again, boom!
16: Sometimes you are publishing HMI correctly but you see ADS can’t read data from the PLC. Your HMI can’t display data though everything works in the engineering environment. If you have added noncompatible PLC run time in your system it may cause this (in this case you have 1 compatible and other non-compatible run time version to the HMI). Need to find the reason ! you can post your findings in the Google groups.
17: Many times, I have seen after publishing the content, the page does not take us to the content page, instead it take to a page where it shows config page. Check if the extension module is activated!
Figure 20: If the extension is not enabled then the HMI will not work.
18: Sometimes, we see after publishing the contents, system does not bring the login page or the desktop view but it shows the following page. It looks if I restart the remote HMI server then it works again, sometimes we need to reboot the HMI server computer. Also if you want to load new HMI by replacing existing HMI, good to restart the HMI server.
=>We can have the following publishing options as shown in the right side
=>Re activate the PLC program
=>Restart the HMI server
Figure 21: After publishing the contents, it shows the login page, HMI server restart helps (somewhere there is bug)
19: After publishing the contents, it may shows it can’t create virtual directory, one way it is possible to make it working by selecting all options and restarting the HMI server.
Figure 22: Virtual directory creation failed, select the options as shows in this image
20: If we have extension for example, C# extension then that must be enabled. If it is not enabled then we see the following error.
Figure 23: Error message when extension is not enabled
21: If you have transition between PLC program (one program to another program in the PLC) then we have a situation like right side (wrong state). Solution to this is that we need to activate the new program again in the PLC
Figure 24: If the we see server status in server like right side, we need to activate the program again.
Download the sample from the link given above.
Next, let’s try to understand how the animation works at https://www.hemelix.com/scada-hmi/twincat-hmi/animation-in-twincat-hmi/
Ask questions related to Hemelix sample code and design at Google group https://groups.google.com/g/hemelix