Configure mode
This chapter is a compilation of all the information required for using the Configure mode of the TwinCAT Database Server. It deals with the following topics:
- Creating a project
- Creating and setting up a database configuration
- Creating and setting up AutoLog groups
- Activating a Database Server project
- Monitoring and controlling automatic logging
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.
Build Project
The TwinCAT Connectivity extension for Visual Studio provides a new project template. When a new project is created, the TwinCAT Connectivity Project category appears as an option.
To create a new TwinCAT Connectivity project, select Empty TwinCAT Connectivity Project, specify the project name and the storage location and click OK to add it to the solution. In this way, TwinCAT Connectivity projects or TwinCAT Database Server projects can conveniently be created in parallel with TwinCAT or other Visual Studio projects.

A new project node appears in the solution. Below the Connectivity project node you can add subprojects for the supported connectivity functions.
Use Add to add a new TwinCAT Database Server project to the TwinCAT Connectivity project. The TwinCAT Database Server project can be found in the list of existing Item Templates.

A new TwinCAT Database Server project is created under the TwinCAT Connectivity node.
This is now used as the basis for the pending configuration of a TwinCAT Database Server. The document can be edited either via the Properties window or via an editor.
A Connectivity project can be associated with any number of TwinCAT Database Server projects or other projects, and it may therefore contain several configurations.
Editor for server settings
The Server Settings editor can be used to edit the settings for the TwinCAT Database Server. These are general settings relating to the corresponding server. In the drop-down menu (1) you can select the target system via the Ams NetID. To this end you have to create a route to the target system via TwinCAT. When a finished configuration is transferred, the settings are stored in the TwinCAT Database Server for this target system.
The settings for logging faults or errors can be configured under Log settings. In the event of a fault or error, the Database Server generates a detailed entry in a log file. The log file can be read with the Information Log Viewer. Under Log Settings you can specify a path to the file location and the maximum file size. You can also influence the accuracy of the log. For performance reasons we recommend that logging is deactivated again after the error analysis, once it is no longer required.
For network access to file-based databases such as Access or SQL Compact, the Impersonate option must be set, so that the TwinCAT Database Server can connect to this network drive. This feature is currently not supported in Windows CE.
Further configuration settings are available to control the read process from the database. These settings refer to the TwinCAT Database Server on the target system:
MaxStringLength | Maximum string length of the variables in the PLC |
MaxByteArrayLength | Maximum byte array length of the variables in the PLC |
DBNullAllowed | Indicates whether ZERO values are accepted in the TwinCAT Database Server. |
DBConnectionTimeout | Indicates the time after which the TwinCAT Database Server assumes a connection error while attempts are made to establish a connection. |
DBCommandTimeout | Indicates the time after which the TwinCAT Database Server assumes a connection fault when a command was sent. If large data quantities are involved, processing of a command may take quite some time, depending on the database and the infrastructure. |
Supported database types
The installed database types can be selected in the server settings. All installed databases are selected by default. The TwinCAT 3 Database Server will load the corresponding database interfaces. In this way, unused databases on the target system can be deselected.
Adding a new database configuration
The database configuration is required for furnishing the Database Server with all the information required for the database connection.
A new database configuration can be added via the command Add New Database in the context menu of a Database Server project or via the corresponding command in the toolbar.
A new database configuration is added in the form of a file in the project folder and integrated in the project. As with all Visual Studio projects, the information on the new files is stored in the Connectivity project.
Editor for database configurations

The database ID, which is required for some function blocks in the PLC, is shown in the upper part of the editor (1). The database types of the target database can be selected from the drop-down menu (2). Another option is the ODBC interface for a database, although this is not yet supported. Note that not all functions of the TwinCAT Database Server can be guaranteed, depending on the database.
As a further option you can select a so-called failover database (3), which is triggered when an error is encountered in Configure mode. In the event of a network disconnection, this feature can automatically ensure that data are stored elsewhere and not lost.
For each database additional adjustable parameters are available. Depending on the database a connection string (5) is created, which describes the connection to the database. The intention is to make the parameters you have set more transparent.
The CREATE (4) button can be used to create a new database. This function is only displayed if the respective database supports it.

Unknown databases can be configured via an ODBC interface. In the ODBC Type drop-down list select "Unknown Database" and add parameters via the commands in the context menu. They may contain passwords, which are stored in encrypted form. The required connection string can be assembled from these parameters. Note that only limited functions of the TwinCAT Database Server can be used. Only the explicit function blocks of the SQL Expert mode are supported.
![]() | Failover database The TwinCAT 3 Database Server has a failover database function. This function offers an option to switch to another database in the event of a connection loss or other problems with the database that was set up, in order to avoid possible data loss. This function is only supported by the Configure mode. In the case of automatic writing, the corresponding alternative database is used in the event of an error. The table of the first database must match the second. |
Adding a new AutoLog group
The AutoLog groups contain information on which variables of the PLC are to be synchronized with which variables from the databases. In addition, information about the synchronization times and the type of synchronization are stored here.
A new AutoLog group for the database configuration can be added via the command Add New AutologGroup in the context menu of a database configuration or via the toolbar. These AutoLog groups refer to the parent database.
A new AutoLog group and the corresponding components are added as files to the project folder and integrated in the project. They include the ADS device, the symbol groups and the table settings. In order to save these files in the project, you should save the TwinCAT Connectivity project file. The files can then be edited in editors or in the Properties window.

StartUp |
AutoLog mode can be enabled manually (with a command in the PLC or from the configurator) or automatically during system startup. |
Direction |
The set ADS device is used as data target or data source. |
Write mode |
The data can appended in a database line-by-line, held in a ring buffer on a temporal or quantitative basis, or simply be updated at the corresponding position. |
Ring buffer parameter |
Depending on the setting this parameter represent the time or the cycles after which the ring buffer is updated. |
Log mode |
The variable is written either after a certain cycle time or when a change occurs. |
Cycle Time |
Cycle time after which the variable is written. |
Configuring the ADS device
The ADS device is automatically created under an AutoLog group. In the most frequent use case the ADS device is the PLC runtime. The following parameters can be set in the editor:

ADS Device | Name of the ADS target device. |
AMS NetID | Address of the target device in the TwinCAT network. |
AMS Port | Port of the target device in the TwinCAT network. |
Timeout | Time after which it is assumed that the connection to the target device is lost. |
Connection Type | bySymbolName: Connection is established based on the symbol name. byIndexGroup: Connection is established based on the memory index. |
Configuring symbols
The symbols you set here are written to or read from the database, depending on whether the ADS device is the data target or the data source. The TwinCAT Target browser can be used for convenient access. Here you can search for the symbols on the target and communicate between the two tools via drag & drop.
Symbols can also be added manually to symbol groups or edited. The information that is required varies, depending on whether in the ADS device the connection type was selected via the symbol name or the index groups. The starting point is always the ADS device.
SymbolName | The symbol is addressed based on the set ADS device |
Symbol database name | Name of the variable in the database table |
DataType | PLC data type of the symbol |
BitSize | Bit size of the symbols (set automatically for the data types) |
IndexGroup | Index group in the TwinCAT system |
IndexOffset | Index offset in the TwinCAT system |
Configuring a table
The table in a database can be based on a standard table structure or on an individual structure.
The corresponding table can be selected from a list of possible tables. If the table does not yet exist, you can create it via the SQL Query Editor. If you select the standard table structure, a blue tick indicates whether the selected table corresponds to this structure.

The specific table type offers the option to distribute the individual symbols that were set in the symbol group to the table columns in the database as required. When a data set is written to the database in AutoLog mode, the current values of the symbol group at the sampling time are saved in the corresponding table column.
Activating a project
To activate a configured project on the TwinCAT Database Server, use the command Activate Configuration in the context menu of the TwinCAT Database Server project.
Logging of the variable starts when the TwinCAT system starts, depending on which startup behavior was specified in the AutoLog group. The mode can be started manually via the following AutoLog Viewer or with the corresponding function block from the PLC.
AutoLog Viewer
The AutoLog Viewer of the TwinCAT Database Server is a tool for controlling and monitoring the AutoLog mode. You can log into a target system, similar to the TwinCAT PLC. In logged-in state the AutoLog mode can be started or stopped. Information on the current state of the logging is shown in the lower part of the window. When an AutoLog group is selected, further information is displayed via the logged symbols.

ID | Name | Function |
---|---|---|
1 | Target system | Choose Target System with installed TwinCAT Database Server |
2 | Start | Manual start of the AutoLog mode |
3 | Login | Logging into the active AutoLog process |
4 | Logout | Logging out of the active AutoLog process |
5 | Stop | Manual stop of the AutoLog mode |
6 | AutoLog groups | List of configured AutoLog groups on the target system |
7 | Symbols | List of configured symbols for the selected AutoLog group |
The AutoLog Viewer can be used to start and monitor the configured application. Depending on setting, after login and startup the incrementing cycle counter of the AutoLog group is visible according to the update times. Update errors are also shown here. For more detailed handling we recommend the InformationLog View.
More detailed error handling with the InformationLog View
InformationLog View is a tool for reading log files from the TwinCAT Database Server. Recorded information is displayed with a timestamp, IDs and error messages in plain text.
The log files can not only be viewed or emptied via direct file access, but also directly via the target. This is particularly advantageous with distributed Database Servers in a network, for quick and easy access to the log file. For this access a route to the target device must exist.
