This post try to explain a small application who you can use in Beckhoff PLC
The project is located in : https://github.com/iautomationeu/DBManager
The application can be used to share the data tag to a Database it´s very useful in monitoring applications.
DBManager can be read all tag located in the PLC and publish it in a Database server. I use PostgreSQL because is very light to install in a small machine and can be used in whatever (Linux host)
Because Beckhoff PLC only uses Windows Host I had to used a Net application to develop it.
Open DBManager Application with Visual Studio IDE.
Modify the parameters in the begining of DBManager.cs:
SET DATABASE IN:
//SQL server parameters //Connection Npgsql public string constr = "Server=127.0.0.1;Port=5432;Database=DB;User Id=postgres;Password=1;"; public string SchemaName = "stb"; public string TableRT = "\"LiveData\""; public string TableACCU = "\"TableACCU\"";
SET ADS NET ID:
//PLC address public string netidplc = "192.168.202.134.1.1";
You can add different times to publish into Database Server InitTimer(timer1.Interval = 10000; // in miliseconds)
The shared Tags in PLC project must have a specific structure in the global variables(like follow):
(symbol.Type.Contains(“SQL_SND”) && symbol.Name.Contains(“Val”))
TYPE ST_SQL : STRUCT Val : DINT; TagName : STRING ; Description : STRING ; END_STRUCT END_TYPE
The .Val tag is the value who is swap in the PostgreSQL Database
And finally the app is ready to use.
In the left part you can see the database connection logs and in the right shows the tag can be logged in the database