DAQ and OPC System

Development of DAQ and OPC System using OPC DA and OPC UA

1 Introduction

Introduction (Video) + Assignment (PDF)

Make sure to fulfill the Checklist (PDF) when you work with the assignment and the technical report.

In this assignment we will create an DAQ and OPC System. We will use an OPC DA Server from Matrikon. We will create different OPC DA clients. We will use LabVIEW to read temperature data from a NI USB-TC01 Thermocouple Measurement Device and send the values to the OPC Server. In addition we will use Visual Studio and C#, and an add-in called Measurement Studio for getting data from the OPC Server. In addition, we will also use LabVIEW to create an OPC UA Server and different OPC UA clients from scratch. More Videos.

 

Use Case Scenario

Here you see a typical Use Case scenario for the DAQ and OPC System:

 

1.1 Topics

The following topics are covered in this assignment:

1.2 Hardware

You will need the following hardware:

 

1.3 Software

You will need the following software:

One ore more of these software packages:

 

 

2 LabVIEW

LabVIEW is a graphical programming language, and it has powerful features for simulation, control and DAQ applications.

Typically engineers often create simple LabVIEW VIs that eventually grow out of control, because they don't have the proper structure and best practices. The solution to this problem is organizing your code and data in a way that enables modularity, readability, and reuse. 

Some examples are:

 

Note! Make sure to use LabVIEW 32bit version (even if you have 64bit operating system) because some features and toolboxes are only supported by the 32 bit version of LabVIEW.

 

Resources:

LabVIEW Fundamentals (Website)

LabVIEW Programming Guidelines (YouTube) + PowerPoint (PDF)

LabVIEW State Machine (YouTube) + PowerPoint (PDF) + Download Code

LabVIEW in Automation (Website)

 

 

3 Data Acquisition (DAQ)

Data Acquisition (DAQ) is the process of collection data from different sensors into a computer. A DAQ System consists of 4 parts: Physical input/output signals, sensors, DAQ device/hardware, driver software and your software application (Application software).

To use the TC-01 Thermocouple device or the USB-6008 DAQ from National Instruments, you need to install the NI-DAQmx driver.

Here you find information about the TC-01 specifications. Here you find the TC-01 User Guide.

Here are some resources for the USB-6008: User Guide and Specifications for USB-6008 and USB-6008 Pinout.

 

3.1 DAQ with LabVIEW

LabVIEW is a powerful tool for making Data Acquisition applications. Below you find some useful resources.

LabVIEW DAQ Resources:

DAQmx in LabVIEW (YouTube) + PowerPoint (PDF) - Communicate with NI DAQ Devices in LabVIEW. The tutorial shows different ways to use the DAQmx functionality in LabVIEW with practical LabVIEW examples.

 

TC-01 Thermocouple Temperature Device in LabVIEW (YouTube) + PowerPoint (PDF)

 

DAQ and I/O Modules in LabVIEW - Introduction (YouTube) + PowerPoint (PDF) - Here we use the USB-6008 DAQ device

DAQ and I/O Modules in LabVIEW - Analog Output (YouTube)

DAQ and I/O Modules in LabVIEW - Analog Input (YouTube)

DAQ and I/O Modules in LabVIEW - Digital Output (YouTube)

DAQ and I/O Modules in LabVIEW - Digital Input (YouTube)

 

Temperature Sensors:

TMP36 Temperature Sensor Overview

Thermistor Temperature Sensor Overview

TMP36 Temperature Sensor in LabVIEW (YouTube) + PowerPoint (PDF)

Thermistor Temperature Sensor in LabVIEW (YouTube) + PowerPoint (PDF)

Read Temperature Data with Lowpass Filter in LabVIEW (YouTube) + PowerPoint (PDF)

Logging Temperature Data to Text File in LabVIEW (YouTube) + PowerPoint (PDF)

Logging Data from Multiple Sensors to a Text File in LabVIEW (PDF)

 

3.2 DAQ with Visual Studio/C#

In Visual Studio/C# you can use the most of the DAQ hardware from NI since the DAQmx driver also supports Visual Studio/C# programming.

To use the USB-6008 DAQ from National Instruments in Visual Studio/C#, you need to install the NI-DAQmx driver.

Note! The NI-DAQmx driver do not support the newer .NET Core or .NET 5/6/7, only NET Framework 4.x. Make sure to select "NI-DAQmx Support for .NET Framework 4.x" and "NI-DAQmx Support for Visual Studio 20xx" during the installation of DAQmx. When creating a new project in Visual Studio, make sure to select the template called "Windows Forms App (.NET Framework)".

Make sure to read the User Guide and Specifications for USB-6008 and USB-6008 Pinout.

 

Visual Studio/C# DAQ Resources:

Visual Studio/C# and DAQ - Exemplified using DAQ hardware and DAQmx from NI

 

 

4 OPC

OPC is a standard that defines the communication of data between devices from different manufactures.

OPC requires an OPC server that communicates with one or more OPC clients. OPC allows “plug-and-play”, gives benefits as reduces installation time and the opportunity to choose products from different manufactures.

We have different OPC standards:

Below you see a typical OPC scenario with an OPC Server and different OPC Clients:

We will focus on OPC DA and OPC UA. The organization OPC Foundation maintains the OPC standards.

 

Resources:

OPC with Practical Examples (YouTube) + PowerPoint (PDF)

 

You find more OPC DA and OPC UA resources below.

 

 

5 OPC DA

 

5.1 MatrikonOPC Simulation Server

MatrikonOPC Simulation Server is free and can be used for testing OPC DA.

Download MatrikonOPC Simulation Server

Problems with installing or using the software?

 

Resources:

OPC DA in LabVIEW (YouTube) + PowerPoint (PDF) - LabVIEW has built-in support for OPC DA using the DataSocket palette.

Note! Make sure to use LabVIEW 32bit version (even if you have 64bit operating system) because the DataSocket feature is only supported by the 32 bit version of LabVIEW.

 

Below, some alternatives to the MatrikonOPC Simulation Server are presented. If you for some reason are not able to install or have other issues with MatrikonOPC Simulation Server, may can use "OPC Server Simulators" by Integration Objects or "NI OPC Servers" instead. See below.

 

5.2 OPC Server Simulators

"OPC Server Simulators" by Integration Objects are free OPC server test tools. They allow end-users, developers and integrators to conduct tests with any third party OPC client software. The package consists of an OPC DA/HDA Server and an OPC A&E Server.

Download OPC Server Simulators

 

5.3 NI OPC Servers

A Demo version of "NI OPC Servers" is included with "LabVIEW DSC Module" or "LabVIEW Real-Time module" (so you may already have it installed on your PC). This one can also be downloaded separately, see below.

Download NI OPC Servers

 

Resources:

LabVIEW OPC with NI OPC Servers (PDF)

 

 

6 OPC UA

OPC UA (Unified Architecture) is the Next Generation OPC. It is Cross Platform. "Classic" OPC works only for Windows based systems. OPC UA uses a modern Software/Network Architecture (No DCOM problems!) and it makes it easier to transmit and receive data in a modern data network/Internet.

 

6.1 OPC UA Server Simulator

OPC UA Server Simulator may be a good option when developing and testing OPC UA solutions. This free OPC UA Server tool supports data access and historical access information models of OPC UA. It is also practical to have a OPC UA Client for test purposes. OPC UA Client is a free client tool that supports the main OPC Unified Architecture information models.

 

Resources:

OPC UA Server Simulator (YouTube) + PowerPoint (PDF)

 

6.2 UaExpert

UaExpert is an OPC UA Client from Unified Automation. You may use it to test communication with different OPC servers, etc.

UaExpert OPC UA Client (YouTube) + PowerPoint (PDF)

 

6.3 LabVIEW OPC UA Toolkit

LabVIEW has built-in support for OPC DA using the DataSocket palette. For OPC UA you need the LabVIEW OPC UA Toolkit.

 

Resources:

LabVIEW OPC UA (YouTube) + PowerPoint (PDF)

 

 

7 OPC in MATLAB

MATLAB is a tool for technical computing, computation and visualization in an integrated environment. MATLAB is an abbreviation for MATrix LABoratory, so it is well suited for matrix manipulation and problem solving related to Linear Algebra, Modelling, Simulation and Control applications, etc. MATLAB is developed by MathWorks.

In MATLAB you can use the Industrial Communication Toolbox in order to communicate with an OPC Server. The Industrial Communication Toolbox supports both OPC DA and OPC UA.

The “Industrial Communication Toolbox” is a new Toolbox that is included in “MATLAB R2022a” and newer versions of MATLAB.

The previous name was "MATLAB OPC Toolbox", but they have now combined different communication protocols like OPC, Modbus and MQTT into one new Toolbox.

 

Resources:

OPC with MATLAB using Industrial Communication Toolbox (YouTube) + PowerPoint (PDF) - Tutorial with OPC DA and OPC UA Examples

MATLAB OPC Toolbox (YouTube) + PowerPoint (PDF) - Tutorial with OPC DA Examples

OPC UA Server Simulator (YouTube) + PowerPoint (PDF) - Tutorial with OPC UA Examples

Note! The Toolbox has changed name from "MATLAB OPC Toolbox" to Industrial Communication Toolbox. The principles and the functionality are more or less the same.

 

 

8 OPC in Visual Studio and C#

Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft. It can be used to develop console and graphical user interface applications along with Windows Forms applications, web sites, web applications, and web services in both native code together with managed code for all platforms supported by Microsoft Windows.

Visual Studio don't have any built-in support for OPC. This means you typically need to use a 3.party package from another vendor. Some of these packages are shown below with some practical examples.

C# Tutorial (w3schools.com) (Website)

 

Resources:

OPC DA in Visual Studion/C#:

OPC in Visual Studio 2019 and Measurement Studio 2019 (YouTube) + PowerPoint (PDF)

Distributed System Manager - Workaround (YouTube) + PowerPoint (PDF)

 

OPC UA in Visual Studion/C#:

OPC UA with Visual Studio and C# (YouTube) + PowerPoint (PDF)

 

 

9 OPC in Python

Python is an open source and cross-platform programming language, that has become increasingly popular over the last ten years. It was first released in 1991.

Python is a mult-purpose programming languages (due to its many extensions), examples are scientific computing and calculations, simulations, web development (using, eg., the Django Web framework), etc.

 

Lots of different packages and libraries exist for both OPC DA and OPC UA in Python.