Overview
The TwinCAT Database Server enables data exchange between the TwinCAT system and various database systems. For small applications it can be used via a configurator, without intervention in the existing program code. For complex tasks the Database Server offers a large library of PLC function blocks for maximum flexibility. SQL commands such as Insert or Select can be used directly from the PLC, for example. To take load off the PLC, if required, procedures can be stored (Stored Procedures) and then called up from the databases. In this case the parameters transferred by the corresponding PLC function block are used by the database in conjunction with the Stored Procedure, and results can be returned to the controller.
The TwinCAT Database Server supports a wide range or different database systems, MS SQL, MS SQL Compact, MS Access, MySQL, PostgreSQL, DB2, Oracle, Interbase, Firebird, ASCII (e.g. .txt or .csv) and XML files, now also including NoSQL databases, based on support of MongoDB. (See also: Declaration of the different database types)
Components
- TwinCAT Database Server: The service is started and stopped together with TwinCAT. It forms the link between the TwinCAT system and the database.
- Configurator: The TwinCAT Database Server Configurator facilitates visual setting of the database parameters required for basic communication with the respective database.
- PLC library: The PLC library includes various function blocks. They enable establishment of a database connection, creation of a new table, writing of data into any table structure using Insert commands, and reading via Select commands. It is also possible to update or delete database entries and trigger stored procedures. NoSQL databases have their own function blocks that are optimized for handling flexible JSON documents in the PLC, for example. The principle of operation is identical.
Principle of operation
Within the TwinCAT system the Database Server communicates via ADS. Externally it links to the respective configured database. Possible network topologies can be found in section "Areas of application and network technologies".