Professional Documents
Culture Documents
SQL database to an
S7-1500 Software
Controller
Siemens
SIMATIC ODK 1500S-SQL-driver V3.1 Industry
Online
https://support.industry.siemens.com/cs/ww/en/view/109479140 Support
Warranty and liability
Note The Application Examples are not binding and do not claim to be complete
regarding the circuits shown, equipping and any eventuality. The Application
Examples do not represent customer-specific solutions. They are only intended
to provide support for typical applications. You are responsible for ensuring that
the described products are used correctly. These application examples do not
relieve you of the responsibility to use safe practices in application, installation,
operation and maintenance. When using these Application Examples, you
recognize that we cannot be made liable for any damage/claims beyond the
liability clause described. We reserve the right to make changes to these
Application Examples at any time without prior notice.
If there are any deviations between the recommendations provided in these
application examples and other Siemens publications – e.g. Catalogs – the
contents of the other documents have priority.
We do not accept any liability for the information contained in this document.
Any claims against us – based on whatever legal reason – resulting from the use of
the examples, information, programs, engineering and performance data etc.,
described in this Application Example shall be excluded. Such an exclusion shall
not apply in the case of mandatory liability, e.g. under the German Product Liability
Act (“Produkthaftungsgesetz”), in case of intent, gross negligence, or injury of life,
© Siemens AG 2020 All rights reserved
Security Siemens provides products and solutions with industrial security functions that
informa- support the secure operation of plants, solutions, machines, equipment and/or
tion networks. They are important components in a holistic industrial security
concept. With this in mind, Siemens’ products and solutions undergo continuous
development. Siemens recommends strongly that you regularly check for
product updates.
For the secure operation of Siemens products and solutions, it is necessary to
take suitable preventive action (e.g. cell protection concept) and integrate each
component into a holistic, state-of-the-art industrial security concept. Third-party
products that may be in use should also be considered. For more information
about industrial security, visit http://www.siemens.com/industrialsecurity.
To stay informed about product updates as they occur, sign up for a product-
specific newsletter. For more information, visit
http://support.industry.siemens.com.
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 2
Table of contents
Table of contents
Warranty and liability ................................................................................................... 2
1 Introduction ........................................................................................................ 5
2 Task ..................................................................................................................... 6
2.1 Overview............................................................................................... 6
3 Solution............................................................................................................... 7
3.1 Overview............................................................................................... 7
3.2 Description of the core functions .......................................................... 7
3.3 Hardware and software components ................................................... 7
3.3.1 Supported SQL databases ................................................................... 8
3.3.2 Supported SQL datatypes .................................................................... 9
3.3.3 Performance data ............................................................................... 11
3.3.4 Used components .............................................................................. 11
3.4 Versioning and update of the driver ................................................... 12
3.5 New features and changes ODK 1500S SQL driver V3 .................... 14
3.6 License mechanism ............................................................................ 14
4 Function mechanisms ..................................................................................... 16
4.1 Overview of the functional principle ................................................... 16
4.1.1 Write process data ............................................................................. 16
4.1.2 Universal SQL interface ..................................................................... 17
© Siemens AG 2020 All rights reserved
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 3
Table of contents
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 4
1 Introduction
1 Introduction
This document describes the connection of an S7-1500 Software Controller to an
SQL-database with ODK 1500S-SQL-driver.
Among others, you will find a description of how to send SQL-statements to an
SQL database and how to request data from an SQL database by means of the
driver or write data in a database from a data block.
© Siemens AG 2020 All rights reserved
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 5
2 Task
2.1 Overview
2 Task
2.1 Overview
Introduction
In the field of the automation technology, there is a great number of applications for
a database.
Databases permit a central, fast, structured and reliable data storage.
Programmable logic controllers, such as S7-1500 controllers, are used for the
control of machines and production plants but, however, are hardly suitable to store
large amounts of data that occur or are required during the production.
Thus, a connection of a database to a programmable logic controller offers a lot of
advantages and use cases.
For example, you can use databases to log machine data or messages during the
production. In this case, the controller transmits data to the database.
Another use case is that the controller reads out parameters, which are required to
produce a certain product series, from a central database.
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 6
3 Solution
3.1 Overview
3 Solution
3.1 Overview
It is not possible to connect a database to an S7-1500 controller by default.
To solve this problem, an SQL driver for the S7-1500 Software Controller has been
developed with the ODK 1500S (Open Development Kit). You can use the SQL
driver to transmit data from an S7-1500 Software Controller to an SQL database or
to read out data from an SQL database.
The connection to the database (local or remote) is established via the ODBC-
interface (open database connectivity).
The ODK 1500S-SQL driver consists of function blocks for the S7-user program as
well as of a Windows-DLL.
Required knowledge
Basic knowledge concerning SQL databases, SQL statements and TIA portal is
assumed.
Note The four mentioned SQL statements have been tested. In addition to these
statements, all other SQL statements can be empirically used, too (e.g. execute
statements for stored procedures), as the SQL driver transmits the SQL strings
and SQL arguments, which have been transferred by the user, directly to the
SQL database via the ODBC interface.
Due to the variety of the SQL statements as well as the possible combinations
not all variations can be tested. The use of SQL statements other than
mentioned above can be done on own responsibility.
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 7
3 Solution
3.3 Hardware and software components
The ODK1500S SQL driver has been tested with the following databases:
• Microsoft SQL 2014 Server Express
• MySQL Server 5.7
• Oracle Database 11g Express Edition
• MariaDB 10.3
• PostgreSQL 12
Empirically any database which offers an ODBC interface can be used with the
ODK1500S SQL driver. The usage of the ODK1500S SQL driver with databases
other than stated above can be done on own responsibility. There may be
restrictions especially for certain data types.
© Siemens AG 2020 All rights reserved
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 8
© Siemens AG 2020 All rights reserved
3 Solution
3.3 Hardware and software components
The SIMATIC ODK 1500S SQL driver supports the following SQL datatypes:
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 9
© Siemens AG 2020 All rights reserved
3 Solution
3.3 Hardware and software components
* Oracle: the time format has to be adapted to the ODBC standard e.g. via login trigger in database for current session:
NLS_DATE_FORMAT:YYYY-MM-DD; NLS_TIMESTAMP_FORMAT: YYYY-MM-DD HH24:MI:SS.FF
** The input parameter "EnableDatimeSupport" at the function block ODK1500_SQLV3_ExecuteStatement or
ODK1500_SQLV3_InsertUpdate has to be enabled
*** read only
**** write only
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 10
3 Solution
3.3 Hardware and software components
This application has been developed and tested with the following components:
Hardware components
Table 3-2
© Siemens AG 2020 All rights reserved
Software components
Newer versions than the above stated (e.g. TIA V16) can be used without any
restriction.
The ODK1500S SQL driver V3 has been developed and tested using the following
software components:
Table 3-3:
Component No. Order number Note
STEP 7 1
Professional V15
SP1
Microsoft SQL 2014 1 64 Bit - Version
Server Express
Edition
Microsoft ODBC 1 64 Bit - Version
Driver 17 for SQL
Server
MySQL Server 5.7 1 64 Bit - Version
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 11
3 Solution
3.4 Versioning and update of the driver
Component Note
ODK1500S-SQL-V3_1_x.zip This file includes
• STEP 7 V15 SP1 project
• SCL-sources
• SQL-driver-DLL
• License file
• SQL-script
„DEMO_MSSQL_V3.sql“
• ConfigDBCreator
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 12
3 Solution
3.4 Versioning and update of the driver
• A change of the MAJOR version number means that there are extensive
changes. Compatibility with earlier versions and firmware versions of the
CPU is usually lost. For upgrading, it is often necessary to update the
CPU-FW, as well as updating the driver FBs and replacing the driver DLL.
Figure 3-1 Properties of the driver DLL
© Siemens AG 2020 All rights reserved
NOTICE If the version of the installed DLL does not match the installed STEP 7 function
blocks, the following error code may returned:
0x8098 - ODK application could not be executed because the function is not
supported.
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 13
3 Solution
3.5 New features and changes ODK 1500S SQL driver V3
• Each driver FB is now multi instance capable. Thus, different SQL commands
can be executed in parallel or e.g. data can be written in parallel to different
databases.
• The connection information for the driver FBs is specified by the user in the
PLC program via a "Connection String" parameter. A separate
parameterization of the ODBC driver as well as the handling of the data base
connections in the PLC program (Connect / Disconnect) by the user is
therefore not necessary anymore.
• There is only one placeholder for the arguments. Instead of the different
placeholders (%d, %s, %t...) for different data types the universal placeholder
"?" is used.
• Simplified error handling: Error messages are mostly also output as plain text
on the FBs. In addition, the number of error codes has been reduced to the
essential.
© Siemens AG 2020 All rights reserved
The file can be viewed e.g. via a web browser to display information about the
expiration date of a trial license:
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 14
3 Solution
3.6 License mechanism
The file must not be changed. If the file is manipulated, the signature loses its
validity and the SQL driver can no longer be used.
Depending on the license file the driver behaves as follows:
© Siemens AG 2020 All rights reserved
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 15
4 Function mechanisms
4.1 Overview of the functional principle
4 Function mechanisms
This chapter describes the function principle and function blocks of the ODK 1500S
SQL driver. Furthermore, we go into details concerning the establishment of the
connection to the SQL data server and the possible functions.
For the application of an SQL database with an S7-1500 Software Controller, there
are in total five function blocks available. These function blocks make it possible to:
• Load the driver DLL
• Establish the connection to the SQL server
• Execute SQL statements (e.g. insert, update, execute, select…)
• Write data to an SQL-database
• Read data from an SQL-database
• Close the connection to the database
• Unload the driver DLL
Process data from a data block can be written to a database in a simple and high
performance manner using the block ODK1500S_SQL_V3_InsertUpdate. The
functional principle of this interface is shown in the following figure:
Figure 4-2: Functional principle FB ODK1500S_SQL_V3_InsertUpdate
The data, which shall be written in the database, can be provided to the FB as a
structure. Via input parameters it can be chosen whether data records shall be
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 16
4 Function mechanisms
4.2 Overview function blocks
overwritten (Update) or newly added to the database (Insert). In addition, the name
of the target table in the database can be parameterized.
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 17
4 Function mechanisms
4.2 Overview function blocks
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 18
4 Function mechanisms
4.3 Description of the function blocks
Before using the SQL driver, it is necessary to load the supplied DLL with the
ODK1500_SQL_V3_Load block. In the delivered example application, the block
will be executed automatically.
By changing the edge (from 0 to 1) at the input parameter "REQ", the function is
started.
Block parameter
© Siemens AG 2020 All rights reserved
4.3.2 ODK1500S_SQL_V3_Execute
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 19
4 Function mechanisms
4.3 Description of the function blocks
To prevent to convert the data (to be written into the database) to strings in the plc
program the actual data and the SQL statements can be passed separately to the
function block by using placeholders:
In this case the SQL statements of the application consist of two parts:
• SQL string: contains the SQL statement including placeholders for the SQL
arguments
• SQL argument: here, the actual data are defined
The block joins SQL string and SQL arguments and transmits the complete SQL
statement to the database.
The arguments are inserted for the place holders. Please consider with the
arguments that they should be in the same order as the place holders. The number
of arguments must match the number of placeholders.
The number of the place holders has to be equal to the number of the arguments.
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 20
4 Function mechanisms
4.3 Description of the function blocks
NOTE The data and the SQL statements don’t necessarily have to be passed
separately to the function block. Alternatively, you can also pass the whole SQL
statement including the data to the input parameter “sqlString”. In this case you
have to use random supported datatype with the name “NoArgument”.
Alternatively, the block ODK1500S_SQL_V3_ExecuteSimple can be used.
An SQL statement is executed with a rising edge at the input „REQ“. In case of a
SELECT statement, the data requested from the database are read in addition and
via in the InOut Parameter “sqlReceivedData” provided. The data in interconnected
recieve data block must be in the same order as the data provided by the function
block of the database. If not enough data types are provided, an error message will
be displayed.
Block parameter
Table 4-3: Parameter ODK1500S_SQL_V3_Execute
Type Name Data type Description
Input REQ BOOL A rising edge of this input value activates the execution of the
ODK function.
Input sqlConnectionSt STRING Contains the necessary information for establishing the
ring connection. The connection string usually contains the name
© Siemens AG 2020 All rights reserved
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 21
4 Function mechanisms
4.3 Description of the function blocks
4.3.3 ODK1500S_SQL_V3_ExecuteSimple
execute any SQL statements that don’t request data from the database.
Block parameter
Table 4-4: Parameter ODK1500S_SQL_V3_ExecuteStatmentSimple
Type Name Data type Description
Input REQ BOOL A rising edge of this input value activates the execution of the
ODK function.
Input sqlConnectionSt STRING Contains the necessary information for establishing the
ring connection. The connection string usually contains the name
of the ODBC driver, the IP address of the SQL server, the
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 22
4 Function mechanisms
4.3 Description of the function blocks
NOTE String data types must be formatted in the SQL-String with simple quotation
mark. This happens in the SQL-String with $'. For example: $'String$'
4.3.4 ODK1500S_SQL_V3_InsertUpdate
Data from a data block can be written to a database in a simple and high-
performance manner using the ODK1500S_SQL_V3_InsertUpdate block. The
block input parameters can be used to specify the table in the database in which
the data is to be written.
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 23
4 Function mechanisms
4.3 Description of the function blocks
The data is written to the database with a rising edge at the input "REQ".
CAUTION Since the addressing of the data in the database is done by name, the names of
the variables from the data block connected to the input parameter sqlArguments
must match the names of the data in the database.
If this is not accomplished, an error message will be displayed.
The variable names are limited to 25 characters.
Block parameter
Table 4-5: Parameter ODK1500S_SQL_V3_InsertUpdate
Type Name Data type Description
Input REQ BOOL A rising edge of this input value activates the execution of
the ODK function.
Input sqlConnectionSt STRING Contains the necessary information for establishing the
ring connection. The connection string usually contains the name
of the ODBC driver, the IP address of the SQL server, the
name of the database, the username and the password.
Examples for common databases are stored in the example
project.
Input writeMode BYTE 0: Insert – Data is added to the target table, 1: Update – Data
is overwritten in the target table
Input tableName STRING Name of the table in the database where the data has to be
written / updated
Input updateCondition STRING Allows to specify the records to be updated at writeMode=1
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 24
4 Function mechanisms
4.3 Description of the function blocks
4.3.5 ODK1500S_SQL_V3_Unload
This block makes it possible to manually unload the SQL driver DLL. Normally, this
is not necessary. Exception: If a new version of the SQL driver DLL shall be
installed, it must be unloaded before.
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 25
4 Function mechanisms
4.4 Create configuration data block
Block parameter
Table 4-6: Parameter ODK1500S_SQL_V3_Unload
Type Name Data Description
type
Input REQ BOOL A rising edge activates the loading of the SQL driver DLL.
Output DONE BOOL Indicates that the instruction to load the SQL driver DLL has
been terminated successfully.
Output BUSY BOOL Indicates that the SQL driver DLL is still being loaded.
Output ERROR BOOL Indicates that an error has occurred while loading the SQL driver
© Siemens AG 2020 All rights reserved
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 26
4 Function mechanisms
4.4 Create configuration data block
The configuration data are generated in each case as an array with 1025 elements
of the plc data type "ODK1500S_SQL_V3_typeConfigData".
The following figure shows various data, which shall be written into a database.
The data is summarized in a structure.
The tool ODK1500S ConfigDBCreator generates a data block based on the data
block above with the configuration data for the three contained data structures.
The configuration data contains the data type identifier as well as the name of the
variables.
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 27
4 Function mechanisms
4.4 Create configuration data block
Figure 4-12: Configuration data for the insert structure from figure 4-14
© Siemens AG 2020 All rights reserved
The following table shows the data type identifiers for the supported STEP 7 data
types:
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 28
4 Function mechanisms
4.4 Create configuration data block
The tool provides two ways to generate a configuration data block from the user
data (sqlArguments):
• Manual import and export of the data blocks
• Direct access to the TIA portal project using the ConfigDBCreator
• Generate configuration data block with the tool ConfigDBCreator (select the
exported data block as the DB source file and specify the destination path)
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 29
4 Function mechanisms
4.4 Create configuration data block
• Import the generated configuration data block via external sources in the TIA
portal and generate the data block:
After the configuration data block has been generated in the TIA portal, it is stored
in the Program blocks folder. The block always has the suffix "CFG". The
configuration data can then be interconnected with the input parameter
"sqlConfigData" from the block ODK1500S_SQLV3_ExecuteStatement or
ODK1500S_SQL_V3_InsertUpdate.
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 30
4 Function mechanisms
4.4 Create configuration data block
To use a TIA Portal Openness application the user has to be added once to the
"Siemens TIA Openness" user group:
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 31
4 Function mechanisms
4.4 Create configuration data block
After successful installation and configuration of TIA Openness, you can use the
ConfigDBCreator tool under the "TIA" tab to select a data block from which the
configuration data shall be created via the "Select project / block" button. After a
subsequent click on the "Create ConfigDB" button, a data block with the
configuration data will automatically be created in the actual opened TIA project.
Figure 4-18: GUI ConfigDBcreator with direct access to the TIA Project
© Siemens AG 2020 All rights reserved
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 32
4 Function mechanisms
4.4 Create configuration data block
The configuration data block is now located in the Program blocks folder. The block
always has the suffix "CFG". The configuration data can then be interconnected
with the input parameter "sqlConfigData" from the block
ODK1500S_SQL_V3_Execute or ODK1500S_SQL_V3_InsertUpdate.
© Siemens AG 2020 All rights reserved
The tool supports optimized as well as non-optimized data blocks. Within the data
blocks all STEP 7 data types, structures, PLC data types supported by the SQL
driver, as well as arrays of elementary data types can be used.
Requirement is that the data for writing into the database are defined in a structure.
The following constellations are not supported because they are not supported by
the databases:
• Array of plc data type
• Nested structures
• Global constants (not supported for manual import/export)
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 33
5 Installation and commissioning
5.1 Installation and commissioning of the MSSQL demo database
The database system “Microsoft SQL 2014 Server Express and Tools“ is installed
on the database server. To install the database, the file „SQLEXPRWT_x64_ENU“
is executed. The environment language of the operating system and the data
management system must match. Under the item installation a „New SQL Server
stand-alone installation“ is selected:
Figure 5-1: Installation center
© Siemens AG 2020 All rights reserved
The next steps are self-explanatory. Here, the license conditions have to be
accepted and you have to click continue until the item “feature selection”.
As demonstrated in the following figure, at least the following components have to
be selected:
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 34
5 Installation and commissioning
5.1 Installation and commissioning of the MSSQL demo database
With the server configuration, the network service is selected. For the sample
project, the SQL server service is sufficient:
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 35
5 Installation and commissioning
5.1 Installation and commissioning of the MSSQL demo database
Making a Windows and a server login possible, you have to select the mixed
service in the following figure during the configuration of the data blocks.
Furthermore, a server password as well as a server administration has to be
defined. The settings for errors and administration reports, which will be available
in the next window, are not used for this example. After the summary, the SQL
server is installed by pushing the key “install”.
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 36
5 Installation and commissioning
5.1 Installation and commissioning of the MSSQL demo database
After the SQL server has been installed, the communication to the runtime PC (S7-
Software Controller) has to be configured. For this, the SQL server configuration
manager has to be opened first. This is done via Start→Program→ Microsoft SQL
Server 2014 →configuration tools→ SQL Server configuration. After that, you can
see under the menu item SQL server services which services are executed. Doing
so, please consider that the SQL server service is active:
Figure 5-6: SQL server services
Then, the TCP/IP connection is activated and configured. Via SQL server network
configuration -> protocols for SQLEXPRESS -> TCP/IP -> right mouse key ->
properties, this step can be executed. Under the tab protocol, the TCP/IP
communication can be activated. Under IP addresses, a static IP address as well
as a port (for example 2301) has to be entered. After that, the service hast to be
started again.
© Siemens AG 2020 All rights reserved
Note The settings only become effective when the according service has been started
again.
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 37
5 Installation and commissioning
5.1 Installation and commissioning of the MSSQL demo database
NOTE Please note that you have to establish a connection to the server
“SQLEXPRESS” before executing the script.
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 38
5 Installation and commissioning
5.1 Installation and commissioning of the MSSQL demo database
After the commands were successfully completed the following components will be
created:
• DEMO_MSSQL_DATABASE: demo database with demo table
• User login: odk1500s with password 1234. The connection to the SQL
server can be realized via the Windows authentication or via an SQL
server authentication. For a remote connection via TCP/IP, the SQL server
authentication is required. For this, a user login has to be generated. After
the new login has been defines, you can choose between the Windows
and the SQL Server authentication by the next establishment of the
connection.
• User odk1500s for the demo database
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 39
5 Installation and commissioning
5.2 Installation and commissioning of the SQL driver on the runtime PC
The installation of the SQL driver for the SQL database connection is limited to the
execution of the Install_Odk1500S-SQL.bat file as administrator. During the
installation, the DLL has to be located in the same directory as the SQL_install.bat
file.
A 64-bit ODBC driver is required for the connection to the SQL database. This
driver must be installed on the runtime PC. It is recommended to use rather new
(e.g. latest release) ODBC drivers than older versions.
© Siemens AG 2020 All rights reserved
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 40
5 Installation and commissioning
5.2 Installation and commissioning of the SQL driver on the runtime PC
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 41
6 Operation of the application
6.1 Use of the example application
First, install and configure the demo database and the SQL driver as described in
chapter Installation and commissioning.
Dearchive the supplied STEP 7 sample project and adapt the hardware
configuration to your applied components and settings, if necessary. After that,
load the project to your controller.
© Siemens AG 2020 All rights reserved
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 42
6 Operation of the application
6.1 Use of the example application
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 43
6 Operation of the application
6.1 Use of the example application
Organization blocks
• Main (OB1): Call of the sql driver function blocks
Function blocks
• ODK1500S_SQL_V3_Load
• ODK1500S_SQL_V3_Execute
• ODK1500S_SQL_V3_ExecuteSimpel
• ODK1500S_SQL_V3_InsertUpdate
• ODK1500S_SQL_V3_Unload
Data blocks
• ODK1500S_SQL_V3_ConnectionsStrings: The connection information for
establishing a connection to the database is stored here
• ODK1500S_SQL_V3_ARGUMENTS: Here, the SQL arguments are indicated.
(Data, which hast to be written into the data base).
© Siemens AG 2020 All rights reserved
Watch table
• ODK1500S_SQL_V3_ControlTable: Watch table to control the example
application (contains variables from the DB
ODK1500S_SQL_V3_CONTROL_DB)
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 44
6 Operation of the application
6.1 Use of the example application
Before you can use the ODK1500S-SQL driver, it is necessary to load the SQL
driver DLL from the software controller.
The SQL driver DLL is automatically loaded in the sample project as soon as there
is a connection between the software controller and Windows OS.
For this purpose the block "GetWindowsDiag" is called in OB1. This provides the
state of the Windows operating system via an InOut structure. Within this structure,
the bit "WindowsIsRunning" is stored. This bit is connected to the "REQ" input of
the ODK1500S_SQL_V3_Load block.
Only when the SQL driver DLL shall be exchanged by a new version it might
become necessary to unload the loaded DLL, to install the new version of the DLL
and then manually load the new version.
To manually load the DLL, please proceed as follows:
• Open the watch table ODK1500S_V3_ControlTable
• Modify the bit
"ODK1500S_SQL_CONTROL_DB.ODK1500S_SQL_V3_Load.REQ“ to 1
The function block ODK1500S_SQL_V3_Load is called in the OB1.
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 45
6 Operation of the application
6.1 Use of the example application
For the example application, the SQL statements being defined in the data blocks
ODK1500S_SQL_V3_STRINGS and ODK1500S_SQL_V3_ARGUMENTS are
used.
Note For the correct functioning of the example application, please ensure that only
one SQL statement is selected in the watch table!
A manual unloading is only necessary in case of exchanging the DLL. Doing so,
please proceed as follows:
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 46
6 Operation of the application
6.2 Adaption of the example application to own requirements
If the execution of an SQL function block was not successful, the error codes which
are returned by the blocks, can be monitored online in the data block
SQL_CONTROL_DB.
For detailed information concerning the error codes, please refer to chapter 7.
NOTE Experienced STEP 7 programmers can alternatively use the provided SCL-
source file which contains the function blocks of the ODK 1500S SQL driver
instead of using the sample project.
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 47
6 Operation of the application
6.2 Adaption of the example application to own requirements
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 48
7 Status and Error codes
7.1 Status and Error Codes ODK1500S
0x7001
Execute the ODK driver
First call (asynchronous)
(Un)Load the ODK driver
(Un)Loading in progress, ongoing call
0x7002
Execute the ODK driver
Continuous call (asynchronous)
Load the ODK driver
0x7100
CPU function library is already loaded
Error Description
Codes
(HEX)
Load the ODK driver
CPU function library could not be loaded. An exception occurred during
execution of the "OnLoad()" function.
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 49
7 Status and Error codes
7.1 Status and Error Codes ODK1500S
CPU function library could not be loaded because the CPU function library could not be
found. Check the file name and path of the file.
Load the ODK driver
0x8094 CPU function library could not be loaded. The CPU function library was created for the
Windows user context, but no user is logged on.
Load the ODK driver
CPU function library could not be loaded due to the following reasons:
• The DLL file is not a CPU function library
• An attempt has been made to load a 64-bit application into a 32-bit
system
0x8095
• Dependencies on other Windows DLL files could not be resolved.
– Check that the release build of the CPU function library is used.
– Check whether the "Visual C++ Redistributables" are installed
for the Visual Studio version you are using.
• The CPU does not support the utilized ODK version.
Load the ODK driver
The CPU function library could not be loaded because the internal
identification is already being used by another loaded CPU function
library.
CPU function library was not loaded or unloading is not yet finished.
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 50
7 Status and Error codes
0
• OUT_DATA
Load the ODK driver
CPU function library could not be loaded.
Start the ODK service manually or restart Windows.
CPU function library could not be (un)loaded. There are currently not
enough resources available from Windows.
Reload the CPU function library after a few seconds.
0x80C2
Execute the ODK driver
CPU function library could not be executed. The CPU currently does
not have enough resources.
Execute the CPU function library again after a few seconds.
(Un)Load the ODK driver
CPU function library could not be (un)loaded. The CPU currently does
not have enough resources.
Reload the CPU function library after a few seconds.
0x80C3
Execute the ODK driver
CPU function library could not be executed. The CPU currently does
not have enough resources.
Execute the CPU function library again after a few seconds.
0xF000 Load the ODK driver
ODK1500S SQL driver license file is expired. Please purchase a full license
Load the ODK driver
0xF001
ODK1500S SQL driver license file is invalid. (The license file must not be manipulated!)
Load the ODK driver
0xFFFF
ODK1500S SQL driver license file does not exist in ODK1500S folder
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 51
7 Status and Error codes
7.2 Error Codes ODK1500S SQL driver
These messages describe errors in the ODK functions of the SQL driver. For
example if a data type in a data block does not match a value read from the
database. The error code is output at output "fctErrorCode". In case of an error the
output bit “fctError” is set.
sqlReceivedData.
9511 The data received from the database contains an unsupported data type.
An exception occurred when writing the received data (sqlReceivedData). For further
9512
information please check sqlErrorInfo.
An exception occurred while checking the length of the received data. For further
9513
information please check sqlErrorInfo.
9514 The length of the received blob data exceeds the maximum length of 65535 bytes.
The number of characters returned in a Sting from the database is greater than the
9515
maximum supported length of 254 characters.
An exception occurred while executing the SQL statement. For more information please
9520
check sqlErrorInfo.
9521 The parameter tableName must not be empty.
9530 Invalid value at parameter writeMode. Value must be 0 (Insert) or 1 (Update).
At the output sqlErrorInfo the error message is output as plain text. The error
messages may vary depending on the database and ODBC driver.
Warnings or hints are also output here. In this case, the output fctError is not set.
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 52
8 Output and display of log information
8.1
Operation
Copy the tool on the runtime computer (IPC running the S7-1500 Software
Controller) and start the tool with administrator rights.
To receive the log output from the SQL driver you have to define the log settings as
follows:
To get only log information from the SQL driver it is also recommended to set the
filter to the "ODK_Host_x64.exe" process via the filter button as follows:
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 53
8 Output and display of log information
8.1
Now, all SQL driver blocks will output log information for which the "enableLog"
© Siemens AG 2020 All rights reserved
parameter is activated. The log information is buffered in the SQL driver and is only
output when the processing of the function block is completed. This ensures that
the log information is consistent when SQL driver function blocks are executed in
parallel.
With the menu item File->SaveLog the log information can be saved to a file.
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 54
9 Related literature
9 Related literature
Table 9-1
Topic Title / Link
\1\ Siemens Industry http://support.industry.siemens.com
Online Support
\2\ Download page of https://support.industry.siemens.com/cs/ww/en/view/109479140
this entry
© Siemens AG 2020 All rights reserved
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 55
10 Contact partner
10 Contact partner
For questions about the ODK1500S SQL driver or problems with the application,
you can submit a support request via the following email address:
applications.aud.koe.nrh.rd@siemens.com
© Siemens AG 2020 All rights reserved
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 56
11 History
11 History
Table 11-1
Version Date Modifications
V1.0 08/2015 First version
V1.1 06/2016 Support of 64-bit floating point numbers
Direct input of SQL Statements possible (Separation
between data and string not necessary)
V2.0 06/2017 Implementation with ODK1500S V2
New user interface
New function block for writing process data without SQL
strings/statements
New function bock for executing SQL statements without
arguments
Support of optimized data blocks
Support for additional data types (datetime, bit…)
SQL statements with up to 16000 characters in the user
program
V2.1 08/2017 Support of unicode datatypes WString resp. nvarchar
Support of variable string length in read and write direction
Increased data interface from 8kByte to 265 kByte
(sqlArguments / sqlReceivedData)
© Siemens AG 2020 All rights reserved
ODK 1500S-SQL-driver
Entry-ID: 109479140, V3.1, 12/2020 57