How to Log Modbus Alarms to a Database

How to Log Modbus Alarms to a Database


Open Automation Software Tags can be defined to connect directly to Modbus slave devices or host data to Modbus masters with the built in Modbus Driver Interface. This tutorial walks you though downloading and installing OAS, configuring a Modbus driver, configuring tags, configuring alarm limits and logging alarms to a database. Supported databases include SQL Server, Oracle, Access, PostgreSQL, Cassandra, MongoDB, MariaDB, SQLite, InfluxDB, MySQL, SQL Azure, Amazon Aurora, Amazon RDS, and CSV files.

Step 1. Download and Install the Open Automation Software and Start the OAS Service

If you have not already done so, you will need to download and install the OAS platform.  Fully functional trial versions of the software are available for Windows, Windows IoT Core, Linux, Raspberry Pi and Docker on our downloads page.

On Windows run the downloaded Setup.exe file to install one or more of the Open Automation Software features. Select the default Typical installation if you are not sure what features to use or the Custom installation if you want to save disk space on the target system.  When prompted agree to the End User License Agreement to continue the installation.

For more detailed instructions and video tutorials, visit the installation guide for your system:
Windows Installation | Linux Installation | Raspberry Pi Installation | Dockers Installation

When the installation is finished the OAS Service Control application will appear.  Use this application to start the 4 Services. If this is the first time installing the software it will automatically enter Runtime with an example Tag Configuration.


Step 2. Configure Your Modbus Data Source

  1. First, you will need to open the Configure OAS application from the program group Open Automation Software.

  2. Select Configure >> License from the top menu and verify that Modbus is one of the available Drivers in the lower left of the form. The demo license will have this by default. If you do not see Modbus available, contact support@openautomationsoftware.com to update your license.

  3. Select Configure >> Drivers from the top menu.


  4. Select localhost or the remote service you wish to modify with the Select button to the right of the Network Node list.


  5. The Configure Drivers Screen will appear. Select Modbus from the Driver dropdown box.


  6. Enter a meaningful Driver Interface Name that you will refer to this physical connection when defining Tags with a Modbus Data Source.

  7. Specify the Connection as Ethernet or Serial.

  8. Specify the Modbus Type as Master or Slave. Master will be used when communicating to a Modbus device. Slave will be used when other Modbus masters will be communicating to OAS.

  9. When setting up a Slave interface over Ethernet set the IP Address to the computer IPv4 IP address or network node name if the master is on a remote PC. You can also use 127.0.0.1 or localhost if the Modbus master will be on the same computer.

For more detailed instructions on configuring your Modbus data source, click here to see our Getting Started Modbus tutorial or watch the video tutorial below:


Step 3. Configure Your Tags

OAS provides multiple ways to add and define tags:

To add a Tag manually:

  1. In the OAS Configure Application, select Configure >> Tags from the top menu.


  2. Select localhost or the remote service you wish to modify with the Select button to the right of the Network Node list.


  3. Click on the Add Tag button located at the top of the Tag browser on the left portion of the screen.


  4. A dialog box will appear. Enter a name for your new tag and click ok.

  5. A configuration screen will appear for your new tag. Select your data source type in in the Data Source dropdown box.


  6. Specify the correct data type in the Data Type dropdown box.

  7. Click Apply Changes at the bottom right of the window.

For more detailed instructions on configuring your tags, click here to see our Getting Started Tags tutorial.


Step 4. Configure Alarm Limits

  1. In the OAS Configure Application, select Configure >> Tags from the top menu.


  2. Select localhost or the remote service you wish to modify with the Select button to the right of the Network Node list.


  3. Select the tag you wish to set alarm limits for from the tag browser on the left.

  4. Use the tabs at the top of the tag properties window to configure alarm limits for your tag based on type: High High, High, Low, Low Low, Digital and Rate of Change.


  5. Check the Enable Alarm checkbox to enabling your alarm limit; alternately, you can use he Enable with Tag…checkbox.


  6. Set your Alarm Limit Source with the dropdown box. If you choose Value, enter the value in the provided text field.

  7. When you have finished configuring your alarm limits, click Apply Changes in the bottom right of the properties window.

For More detailed instructions on Configuring Alarm Limits, visit our Alarm Limits tutorial or watch the video below:


Step 5. Configure Alarm Logging

  1. In the OAS Configure Application, select Configure >> Alarm Logging from the top menu.


  2. Select localhost or the remote service you wish to log alarms from with the Select button to the right of the Network Node list.


  3. A Logging Group screen will appear.


  4. In the Common tab, check the Logging Active checkbox to enable your group. Alternately, you can activate logging with a tag by checking that box.

  5. Use the Filters tab to select which alarms you wish to log with your group. Filtering can be done by alarm state, alarm limit, priority, groups and alarm type.

  6. In the Database tab, you will select what type of database you will be logging to and enter the connection parameters. OAS can log to SQL Server, Oracle, Access, PostgreSQL, Cassandra, MongoDB, MariaDB, SQLite, InfluxDB, and MySQL.

  7. If you wish to log to CSV, you would configure that in the CVS Logging tab.

  8. When you have finished configuring your logging group, click Add Group in the left panel to add your new group to the service.

For more detailed instructions on Configuring Alarm Logging, visit our Getting Started – Alarm Logging tutorial or watch the video below:


Frequently Asked Questions – Alarm Logging

MS Access Error microsoft.ace.oledb.12.0 provider is not registered
MS Access Class not Registered System Error

For Office 2010, the following update will correct this issue.

https://www.microsoft.com/en-us/download/details.aspx?id=39664

For Office 365 (please note, by default Office365 installs the 32-bit version regardless of your system), use:

https://www.microsoft.com/en-us/download/details.aspx?id=54920

Security Login Error occurs with Open or Create routines.
View the Database Security Login topic on how to setup security logins and access writes to create, open, and read and write to the database.
The database engine language is different than the Regional Language settings of the Data Logging and / Alarm Logging Service. Data Logging updates, Alarm Logging updates, trend history, and / alarm history is not working due to invalid date format.
Go to Configure-Options-History and Enable History Date Format. Examples: yyyy-MM-dd HH:mm:ss MM/dd/yyyy HH:mm:ss

Videos – Alarm Logging

Alarm Logging

Log alarms to SQL Server, Oracle, Access, mySQL, SQL Azure, PostrgreSQL, MongoDB, MariaDB, Cassandra, and SQLite.

Alarm Limits

How to setup alarm limits in real-time tag configuration.

Alarm Logging

How to setup alarm logging to SQL Server, Oracle, Access, and mySQL.

  • 00:00 – Log alarms to a database
  • 00:15 – Configure App
  • 02:05 – Database Format
  • 03:41 – Alarm visualization
  • 04:06 – More Questions

Getting Started – Alarm Logging

To open a new window for Alarm Logging modification, select Configure-Alarm Logging.

Select a Windows Service to modify, the node with the green arrow is the current Service being modified. Refer to Selecting Service for more information on selecting an OAS Service.

In order to log alarms to a database you must first define the Tag Alarm Limits as described in Configure Tags of this Quick Start section.

For a complete list of all Alarm Logging properties refer to the OAS Configuration – Alarm Logging section in this help file.

Step 1

OASStart the Configure OAS application if it is not already running.

 

 

Step 2

Select Configure-Alarm Logging.

Alarm Logging

Step 3

Select the Local OAS Service by selecting the Select button next to the Network Node.

Network Node

Note: The Configure application can be used to connect to remote systems using the network node name or IP address of the remote node the OAS Service is running on.  Simply enter the IP Address or network node name of the remote OAS Service you wish to connect to and click on the Select key.

Step 4

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

Logging Group Name

Step 5

Check Logging Active in the Common Properties Tab.

Logging Active

Step 6

Select the Database Tab.

Database Tab

Step 7

Logging to SQL Server

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

Database Configuration

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:

Windows Azure Setup

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.

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 PostgreSQL

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

Logging to Cassandra

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

Logging to MongoDB

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

Logging to MariaDB

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

Logging to SQLite

All steps are the same as using SQL Server except the provider should be set to SQLite and the File Path should be set to the directory and file name to log to.

Logging to Microsoft Access

Use the following configuration for Microsoft Access. The Database and Table will be automatically created for you.
When logging to MS Access 2007 or greater use the extension .accdb, use .mdb for the older versions of versions of Access.

Access Configuration

Use the following configuration for CSV text logging:

Note: There is no historical replay to alarm windows with CSV logging.

CSV Configuration

Step 8

Select the Add Group button to add the Alarm Logging group.

Add Group

Step 9

Select the Save button on the toolbar at the top.

Save Button

Step 10

Save the file DemoAlarmLogging.AlarmLog in the directory C:\OAS\OASDemo\.

Save Log

You can specify for this configuration to load automatically when the Service starts using Configure-Options which is described also in this Training Guide.

Overview – Alarm Logging

You can log alarms to SQL Server, Oracle, Access, mySQL, PostgreSQL, Cassandra, MongoDB, MariaDB, SQLite, SQL Azure, Amazon Aurora, Amazon RDS, and CSV files based on event.

By using the product Alarm .NET or Web Alarm this is easy to setup.

View the following for a quick tutorial on alarm logging: Videos – Alarm Logging