Skip to content

xavierflorensa/Optix_OPC_UA_to_SQL

Repository files navigation

OPC UA to SQL with FactoryTalk Optix

Contents

1. OPC UA Client

2. Writing to an SQL database

3. Creating a OPC UA to SQL converter

1. OPC UA Client

Let’s create a new OPC Client

https://www.rockwellautomation.com/docs/en/factorytalk-optix/1-00/contents-ditamap/using-the-software/opc-ua/manage-the-opc-ua-client.html

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 001

Change the address and port of the OPC UA server

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 002

For instance with FT Kepserver Enterprise, port number is 49370

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 003

Right click to add a new OPCUA Tag Importer

Then double click on it

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 004

Click on the Button to go online with the OPC server

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 005

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 006

Click on apply

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 007

On Objects you will see this

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 008

Now let’s create a texbox that points to the data

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 009

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 010

That’s all

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 011

Let’s add a label

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 012

2. Writing to an SQL database

Let’s write to an SQL database from Optix

First just read from a Database

https://www.rockwellautomation.com/docs/en/factorytalk-optix/1-00/contents-ditamap/using-the-software/datastore-database.html

Add a Database object

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 013

Be sure to have an SQL working database, with user, password, access thru TCP/IP, etc.

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 014

Complete database properties click on Table + and Column + to match our Database

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 015

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 016

If you do not add a column here you will have errors when drag and drop to the Table1 to the data grid (Unable to insert a empty table to the datagrid)

Display Database data

https://www.rockwellautomation.com/docs/en/factorytalk-optix/1-00/contents-ditamap/using-the-software/datastore-database/display-database-table-data.html

Just click on the + on Tables to create a new table (even thought it already exists on the MS database)

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 017

Do not forget to add a column minimum

Drag and Drop

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 018

It works!!

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 019

Now let’s try to write a variable on the database

Using this example

https://www.rockwellautomation.com/docs/en/factorytalk-optix/1-00/contents-ditamap/developing-solutions/application-examples/logger-tutorial/develop-a-data-logger-with-odbc-data-store.html

Download a sample project: [DataLoggerODBC.zip](C:\Program Files\Rockwell Automation\FactoryTalk Optix\Studio\Help\en\downloads\DataLoggerODBC.zip)

https://www.rockwellautomation.com/content/dam/dita/en/factorytalk-optix/1-00/downloads/DataLoggerODBC.zip

To see how it is made.

But let’s start creating a complete new project

For instance sql_datalogger_optix_v2

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 020

But first let’s create a database without a Table (Optix and The Datalogger function will create the Table)

For instance let’s create a new database Optix2

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 021

Just give a name, that’s all

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 022

There are no user tables

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 023

Now Let’s go to Optix

Add a variable to work with

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 024

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 025

Add a Slider to enter values to such variable

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 026

Next create the Database instance on Optix

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 027

Point to the existing database, but do not create any Table on Optix

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 028

Then create a new DataLogger

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 029

And select the variable to log and the destination, just the database

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 030

If we now open the ODBC object, surprise, a new Table an columns have been created for us

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 031

If we take a look at the database:

You have to disconnect and connect again to see the changes

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 032

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 033

Still nothing

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 034

Until you run the Optix Runtime

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 035

Give some values to the gauge dropping the index

Then go to the Database, and …voilà

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 036

Now let’s look at the data, this is working fine

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 037

Now let’s add a Datagrid on the Optix Project

Drag and drop the table to the Datagrid

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 038

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 039

Let’s test it. It works! That’s all

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 040

3. Creating a OPC UA to SQL converter

Take last SQL project and delete the gauge.

Then add the OPC UA client like in previous sections.

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 041

Now we have access to IoT_data Tag

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 042

First of all test that we are reading OPC UA data

Yes

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 043

Then let’s erase the data on the database from previous chapter.

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 044

Verify that the data is erased from Optix

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 045

Now just change the source of data on the datalogger Object

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 046

Let’s test The Optix Runtime

It takes a while until the values are logged. I have also restarted the OPC UA server.

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 047

Clear the Table again

First time we see nothing on the Optix runtime datagrid window

Let’s close the runtime and open it again

Now it works

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 048

Let’s put an autorefresh to the datagrid and sort ascending, descending to see it live!

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 049

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 050

As you can see on this video

https://www.youtube.com/watch?v=irL_CHUZaHY

Aspose Words 9a4ef72d-2c56-4e38-8555-c09687483f0d 051

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published