Log Buffered Data from a PLC or Controller

Getting Started-Data Logging 15

In some high speed systems data is buffered in the device.  OAS can log this buffered data in a wide table format to a database or CSV file.  The data can be organized into an array or individual items.

In this example we will focus on just one array of values in the controller to log, but you can define as many logging groups as you like to all run in parallel for multiple array data processing.

Step 1

In the controller or PLC define the following variables if they do not already exist.

  • Values: Array containing queued values to be logged. The data type of the array can be anything you desire including Double Float, Single Float, Long Integers, Integers, Short Integers, Booleans, or Strings.
  • Ready: Boolean variable that controller will set to true when the array values are all loaded and ready.
  • Confirmation: Boolean variable that will receive a confirmation that the values in the data array are received to be logged. When this value is set to true the controller will set this variable back to false, reset the array of values, and fill the array of the next set of data to be logged.
  • Error: Integer variable that will be set to an error code if there is a problem with the logging of data values.
  • Timeout: Internal time period the controller will wait for either the Confirmation bit or Error Integer after the Ready bit is set to true. If the time elapses without either Confirmation or Error after the Ready is set the controller will abort the logging and not reset the array and try the sequence again and post an error to the operator that logging has halted.

Create the following logic routines in the controller if they do not already exist.

  • Fill the Values array with the sequential values to be logged.
  • Set the Error integer to 0.
  • Set the Confirmation bit to false.
  • Set the Ready bit to true.
  • If the Confirmation bit goes to true.
    • Clear the Values array.
    • Return back to the first step
  • If the Error integer goes to non zero.
    • Inform operations that logging has halted.
    • Return back to the first step
  • If the Confirmation bit or Error integer are never received within the timeout period.
    • Inform operations that logging has halted.
    • Return back to the first step

Step 2

Getting Started-Tags 1Start Configure OAS application if it is not already running.

Select Configure-Tags.

Step 3

Select the Local OAS Service by selecting the Select button or the Local node in the service tree to the left.

Getting Started-Tags 3

Getting Started-Tags 4

Step 4

Create a Group with the name Array01.

Right click on the Group Array01 and Add the following Tags with the Data Source to OPC, OPC UA, or one of the controller drivers like Siemens, Modbus, AB, MQTT, OPTO, etc.  Define the appropriate device address in the controller for the variables created in step 1.

  • TagName: Ready
  • Data Type: Boolean
  • TagName: Values
  • Data Type: Object Type or one of the Array Types.
  • TagName: Confirmation
  • Data Type: Boolean
  • TagName: Error
  • Data Type: Integer

Step 5

Save the Tag configuration to file.

Use Configure-Options-Default Files to specify the default Tag configuration file.

Step 6

Select Configure – Data Logging.

Getting Started-Data Logging 1

Step 7

Select the Local OAS Service by selecting the Select button or the Local node in the service tree to the left.

Getting Started-Tags 3

Getting Started-Tags 4

Step 8

Enter the Logging Group Name of Array01 in the field in the upper right.

Check Logging Active in the Common Properties Tab.

Getting Started-Data Logging 3

Step 9

Set the Logging Type to Event Driven.

Step 10

Set the Trigger Tag to Array01.Ready.Value

Set the Confirmation Tag to Array01.Confirmation.Value

Set the Error Tag to Array01.Error.Value

Note: For the fastest transaction processing enable the property “Confirm With Success Immediately Before Database Write”.  This will send the confirmation back to the controller before logging the values to the database.  You can rely on the Data Buffer feature under Configure-Options to buffer the records to disk if there is a database engine error.

Step 11

Select the Tags Tab.

Modify Tag 1

Step 12

Select the Add Field button.

Getting Started-Data Logging 4

Step 13

Select the Tag Parameter browse button to select the Tag Parameter Array01.Values.Value.

Getting Started-Data Logging 5

Add [0] to the end of the tag name to log the first element.



Step 14

Change the field name in the next dialog to Array01_Values or to the database column name you desire to log all of the values to.


Step 15

Use the Add Tag button at the bottom of the dialog to add the additional elements within the array to log to the database field.  Specific array elements [1], [2], [3], etc.

Click OK when finished adding all of the elements of the array to log.

Note: You can optionally add additional Tags with Excel by right clicking on the database field list.

Step 16

Repeat steps 12 through 15 for any additional field and arrays of data you want to log.


Step 17

Select the Database Tab.

Getting Started-Data Logging 15

Step 18

Logging to SQL Server or SQL Server Express

Use the following configuration for SQL Server and SQL Server Express. The Database and Table will automatically be created for you.

Getting Started-Data Logging 9

The Server name may need to be adjusted from localhost to the proper Server name of the SQL Server engine you wish to log to. This Server name can be found when first bringing up the Connect dialog of the SQL Server Management Studio.

Also the login method can be with Windows Authentication or SQL Server mode. Contact your database administrator if you are unsure of what login type to use.

Getting Started-Data Logging 10

You can download a free version of SQL Server Express from www.microsoft.com.

Logging to Microsoft Azure

Use the SQL Server Provider and view the following guide to setup Microsoft Azure:


Logging to Oracle

If you are using Oracle you must first create the database. All other steps are the same as SQL Server except the provider should be set to Oracle.  Oracle does not create the database so you will have create the database manually.

If you do not have a TNSNAMES.ORA file or need to log to a remote database engine refer to the Frequently Asked Questions in this Data Logging topic.

Logging to mySQL

All steps are the same as using SQL Server except the provider should be set to mySQL.

Logging to Microsoft Access

If you prefer to use Microsoft Access instead of SQL Server use the following configuration for Microsoft Access. The Database and Table will be automatically created for you. Make sure to create the directory OPCSystemsDemo on your C drive or specify a different Database path that will exist.

Getting Started-Data Logging 11

Logging to Comma Separated Variable Files

Use the following configuration for CSV text logging.

Make sure to create the directory OPCSystemsDemo on your C drive or specify a different Database path that will exist.

Getting Started-Data Logging 12

Step 19

Select the Add button to add the Data Logging group.

Getting Started-Data Logging 13

Step 20

Select the Save button on the toolbar at the top.

Getting Started-Tags 19

Step 21

Save the file DemoLogging.DataLog in the directory OPCSystemsDemo.

Getting Started-Data Logging 14

Step 22

Go to Configure-Options and set the default Data Logging Configuration file to the file you just saved.

Step 23

Important: Enable Data Buffer To Disk under Configure-Options-Data Buffering on all data source Tag servers and data logging servers to retain data on a network failure or database engine failure.

After completing the above steps you can enable your controller logic view the data in your database or CSV file.

For more detailed information on each data logging parameter view the Data Logging section in this help file or simply select the property in the Configure OAS application and hit the F1 key or select the ? near the property.