Basic concept
The TwinCAT Database Server is designed to enable a database connection to the controller for all TwinCAT users, and as conveniently as possible. Notwithstanding the required simplicity, the full flexibility is to be retained, which is why the TwinCAT Database Server offers four basic categories:
- Configure mode: pure configuration solution
Database connections for simple applications based on graphical configurations without code implementation. - PLC Expert mode: programming solution for conventional PLC programmers
Database connection for simple or complex applications based on PLC function blocks, in which the database commands are largely generated automatically by the Database Server. - SQL Expert mode: programming solution for conventional PLC programmers and database experts
Database connection for simple or complex applications based on PLC function blocks and C++ interfaces, in which the database commands are assembled automatically during program execution. For maximum flexibility. - NoSQL Expert mode: programming solution for PLC programmers and NoSQL database experts
Database connection for simple to complex applications with PLC function blocks, in which NoSQL commands can be created and sent within the program sequence.
Naturally, all four categories can be combined within an application.
The TwinCAT Database Server can be set up via a graphical configurator. The configuration is written to an XML file, which can then be downloaded to the target system.
On non-Windows CE devices the configuration file is in folder C:\TwinCAT\3.1\Boot, on Windows CE devices in folder \Hard Disk\TwinCAT\ 3.1\Boot.
Read and write access are available for the different database systems. Deselectable database extensions are available for this purpose. The supported databases are described in section "Databases".
The TwinCAT Database Server service is started together with the TwinCAT system on the respective control computer. It is the link between the PLC and the database.
Configure Mode
In Configure mode, the bulk of the work is done in the configurator. The configuration has to be set up for the required database and for the AutoLog group. The target browser can be used for configuring the AutoLog group, for online access to a target system, and for selecting the variables to be communicated. If the AutoStart option is used, the communication with the configured database is established directly when TwinCAT system starts up. If the Manual option is selected, the communication has to be enabled via the function block FB_PLCDBAutoLog or for AutoLog view.
PLC Expert mode
In PLC Expert mode only the database configuration is set in the configurator. Further functionalities are implemented in the PLC code of the application. With the function block FB_PLCDBCreate it is possible to dispense with the configurator and even configure the database itself from the PLC. Function blocks for reading and writing are available, if required. The function block FB_PLCDBCmd forms the transition between PLC Expert mode and SQL Expert mode. Here, table structures can easily be mapped as PLC structures, and an SQL command with placeholders for the current structure values can be transferred to the TwinCAT Database Server. The TwinCAT Database Server then inserts all values automatically and sends the command to the database.
SQL Expert Mode
In SQL Expert mode users can assemble the SQL commands for Insert, Select or Update, for example, in the PLC and send them to the database via the TwinCAT Database Server. This is a very flexible and powerful option. Stored Procedures - in database - can also be called from the PLC.
Logging of structures Note the corresponding byte alignment when logging structures. |
NoSql Expert Mode
In NoSQL Expert mode, the user can compile NoSQL queries such as Insert or Find and many other database-specific queries and send them to the database via the TwinCAT Database Server. New and more flexible data schemas, such as hierarchical structures and arrays, are supported.