NI USB-TC01 Thermocouple Measurement Device

Similar documents
NI mydaq HANS-PETTER HALVORSEN, Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics

NI Vision System HANS- PETTER HALVORSEN,

Data Acquisition HANS-PETTER HALVORSEN,

Datalogging in LabVIEW

Virtual Instruments with LabVIEW

Wireless DAQ using ZigBee

Høgskolen i Telemark Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics.

Datalogging and Monitoring

DAQ in MATLAB HANS-PETTER HALVORSEN,

Solutions. Discretization HANS-PETTER HALVORSEN,

Control and Simulation in. LabVIEW

State Estimation with Observers

Faculty of Technology, Department of Electrical Engineering, Information Technology and Cybernetics. SCADA System

You can call the project anything you like I will be calling this one project slide show.

Laboratory System. 1 Introduction

Data Acquisition in LabVIEW

Wireless DAQ System. In this project you are going to create a Wireless DAQ System, see Figure 1-1. Figure 1-1: Wireless DAQ system

Weather System. In this project you are going to create a Weather System, see Figure 1-1. Figure 1-1: Weather system

University College of Southeast Norway. Web Services. with Examples. Hans-Petter Halvorsen,

Now find the button component in the tool box. [if toolbox isn't present click VIEW on the top and click toolbox]

Simulation in LabVIEW. Hans-Petter Halvorsen, M.Sc.

CALCULATOR APPLICATION

Database Lab. Hans-Petter Halvorsen

Exercise 5: Basic LabVIEW Programming

First start a new Windows Form Application from C# and name it Interest Calculator. We need 3 text boxes. 4 labels. 1 button

LabVIEW Tutorials. T.1 Temperature Measurement and Cold Junction Compensation (CJC) LUMS School of Science and Engineering

IBSDK Quick Start Tutorial for C# 2010

Experiment 5 : Creating a Windows application to interface with 7-Segment LED display

SCADA Lab. Supervisory Control and Data Acquisition. Hans-Petter Halvorsen

We are going to use some graphics and found a nice little batman running GIF, off course you can use any image you want for the project.

University College of Southeast Norway. LM-900 Level Tank. Hans-Petter Halvorsen,

Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK.

To start we will be using visual studio Start a new C# windows form application project and name it motivational quotes viewer

NI-DAQmx Basic Course NITS John Shannon

The Open Core Interface SDK has to be installed on your development computer. The SDK can be downloaded at:

Click on the empty form and apply the following options to the properties Windows.

Start Visual Studio and create a new windows form application under C# programming language. Call this project YouTube Alarm Clock.

Database Communication in Visual Studio/C# using Web Services

Using SQL Server in C#

Form Properties Window

Introduction to LabVIEW

Hardware: Acquiring Data and Communicating with Instruments

LabVIEW MathScript Quick Reference

CSIS 1624 CLASS TEST 6

1. Learn about LabView software and its different components

Start Visual Studio, create a new project called Helicopter Game and press OK

Conventions in this tutorial

Wireless Data Acquisition in. LabVIEW

Sensors and Actuators with Arduino. Hans-Petter Halvorsen, M.Sc.

Industrial IT Laboratory Work Hans-Petter Halvorsen

if (say==0) { k.commandtext = "Insert into kullanici(k_adi,sifre) values('" + textbox3.text + "','" + textbox4.text + "')"; k.

Hands-On Lab. Lab: Client Object Model. Lab version: Last updated: 2/23/2011

Additional products and features

Create your own Meme Maker in C#

The first program we write will display a picture on a Windows screen, with buttons to make the picture appear and disappear.

Install the Software and Hardware

Chapter 12. Tool Strips, Status Strips, and Splitters

Introduction to Visual Studio and C#

Lab Exercise 2: Data Acquisition with NI LabVIEW

Savoy ActiveX Control User Guide

3-tier Architecture Step by step Exercises Hans-Petter Halvorsen

Visual Studio Team Services

Quick Guide for the ServoWorks.NET API 2010/7/13

Class Test 4. Question 1. Use notepad to create a console application that displays a stick figure. See figure 1. Question 2

Main Game Code. //ok honestly im not sure, if i guess its a class ment for this page called methodtimer that //either uses the timer or set to timer..

Unit Testing. Quiz with Explainations. Hans-Petter Halvorsen, M.Sc.

This is the empty form we will be working with in this game. Look under the properties window and find the following and change them.

Contents. Software CALIBRATION PROCEDURE NI TC-4353

Strain and Force Measurement

Introduction to ERwin

Step 1: Start a GUI Project. Start->New Project->Visual C# ->Windows Forms Application. Name: Wack-A-Gopher. Step 2: Add Content

Developing for Mobile Devices Lab (Part 1 of 2)

Determination of Drag Coefficient

Object oriented lab /second year / review/lecturer: yasmin maki

NAME EET 2259 Lab 3 The Boolean Data Type

Step-by-Step Data Acquisition Part II Exercise 2: Generating an Analog Output Waveform

Measurement & Automation Explorer (MAX) View and control your devices and software

Developing for Mobile Devices Lab (Part 2 of 2)

Introduction to Labview and Temperature Measurement

Notes on installing and using the OM-USB-5201 and OM-USB-5203 data logging devices

Create a worksheet that collects, displays and saves temperature data

Create a Virtual Test Environment

Visual Basic/C# Programming (330)

Contents. Software Requirements CALIBRATION PROCEDURE NI TB-4353

Homework Assignment 9 LabVIEW tutorial

University College of Southeast Norway ASP.NET. Web Programming. Hans-Petter Halvorsen,

Temperature control with DeltaV using MPC

DAC-4U SERIES DIGITAL TO ANALOG CONVERTER TECHNICAL REFERENCE

DAC-8U SERIES DIGITAL TO ANALOG CONVERTER TECHNICAL REFERENCE

LabVIEW Basics I: Introduction Course

EL-USB-RT API Guide V1.0

// Specify SEF file to load. edischema oschema = oedidoc.loadschema(spath + sseffilename, SchemaTypeIDConstants. Schema_Standard_Exchange_Format);

Team Foundation Server Visual Studio Team Services. Hans-Petter Halvorsen, M.Sc.

Hands-On Lab (MBL04) Lab Manual Incorporating COM Objects into Your.NET Compact Framework 2.0 Application

Writing Your First Autodesk Revit Model Review Plug-In

Representing Recursive Relationships Using REP++ TreeView

BE/EE189 Design and Construction of Biodevices Lecture 5. BE/EE189 Design and Construction of Biodevices - Caltech

Lab Exercise 4: Analog & Digital I/O Signals

Your First Windows Form

Activating AspxCodeGen 4.0

Transcription:

Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics NI USB-TC01 Thermocouple Measurement Device HANS- PETTER HALVORSEN, 2013.02.18 Faculty of Technology, Postboks 203, Kjølnes ring 56, N-3901 Porsgrunn, Norway. Tel: +47 35 57 50 00 Fax: +47 35 57 54 01

Table of Contents Table of Contents... ii Preface... 1 1 Introduction... 1 2 System Description... 5 2.1 Documentation... 5 3 Configuration... 6 3.1.1 Testing the NI USB- TC01 in MAX... 6 4 Using TC01 in LabVIEW... 8 4.1 NI- DAQmx... 8 4.1.1 DAQ Assistant... 9 5 Using TC01 in Visual Studio and C#... 14 5.1 DAQmx... 14 5.2 C# Example... 15 6 Using TC01 with Measurement Studio... 19 6.1 DAQmx Driver... 19 6.2 Measurement Studio... 19 6.3 Create a NI Windows Application... 19 6.4 Create a NI DAQ Windows Application... 23 ii

Preface You will find this document and lots of other information in the following web site: http://home.hit.no/~hansha/?equipment=tc01 In order to use the NI TC- 01 Thermocouple device you need to install the DAQmx driver. You can use the TC- 01 device with LabVIEW or with Visual Studio. We can also use the device with Measurement Studio, which is an add- on to Visual Studio. Så the different alternatives are as follows: A - Using LabVIEW: 1. LabVIEW + DAQmx driver (Chapter 4) B - Using Visual Studio/C#: 2. Visual Studio + DAQmx driver (Chapter 5) 3. Visual Studio + DAQmx driver + Measurement Studio (Chapter 6) In this document we go through all these alternatives. 1

1 Introduction Below (Figure 1) we see the NI USB- TC01 Thermocouple Measurement device. Figure 1: NI USB- TC01 Thermocouple Measurement Device The NI USB- TC01 provides connections for one thermocouple. Thermocouple types J, K, R, S, T, N, E, and B are supported. At TUC we will use the J type. The NI USB- TC01 software support for Windows 7/Vista/XP is provided by the device. No separate driver installation is required for operation. Below (Figure 2) we see the different components that NI USB- TC01 Thermocouple is part of: Figure 2: NI USB- TC01 Thermocouple Components 1

Introduction The following window (Figure 3) should pop up automatically when you plug in your NI USB- TC01 device in your USB port: Figure 3: NI USB- TC01 Launch Screen If not this window pops up automatically, we need to start it manually, see Figure 4below: Figure 4: NI USB- TC01 appears as a separate drive in your Windows Explorer

Introduction Select TC01Launcher.exe and the Launch Screen in Figure 3 will appear. From the Launch Screen the following are available (Figure 5): LabVIEW Example (Figure 6 and Figure 7): Figure 5: Temperature Logger

Introduction Figure 6: LabVIEW Example Front Panel Figure 7: LabVIEW Example Block Diagram

2 System Description Below (Figure 8) we see the NI USB- TC01 Thermocouple Measurement device. Figure 8: NI USB- TC01 Thermocouple Measurement Device 2.1 Documentation The documentation for the NI USB- TC01 device is as follows: NI USB- TC01 User Guide and Specifications NI USB- TC01 Data Sheet NI USB- TC01 Calibration Procedure These documents are available from www.ni.com (or just Google them) 5

3 Configuration Configuring and testing: NI USB- TC01 can be configured and tested using MAX (Measurement and Automation Explorer), which is installed with the NI- DAQmx Driver Software. 3.1.1 Testing the NI USB-TC01 in MAX Before you start to use the NI USB- TC01 in an application, you should test the device in the Measurement and Automation Explorer (MAX), see Figure 9. Figure 9: MAX In the MAX window, expand the Devices and Interfaces node. Right- click on the NI USB- TC01 device and select Self- Test (Figure 10). 6

7 Configuration Figure 10: Self Test Hopefully the self- test passes without errors. Then, you should test the device using the Test Panels (Figure 11). Figure 11: Test Panels

4 Using TC01 in LabVIEW Software requirements: LabVIEW + DAQmx driver 4.1 NI-DAQmx In order to use the NI USB- TC01 in LabVIEW you need to use the DAQmx functions, see Figure 12 below. Figure 12: NI- DAQmx 8

9 Using TC01 in LabVIEW DAQmx Data Acquisition palette (Figure 13): Figure 13: DAQmx Palette in LabVIEW 4.1.1 DAQ Assistant The easiest ways is to use the DAQ Assistant. When you drag the DAQ Assistant icon on your Block Diagram, the following window appears (Figure 14): Figure 14: DAQ Assistant Wizard Select Signal Type

10 Using TC01 in LabVIEW In this window you need to select Acquire Signals and Thermocouple. In the next window (Figure 15) you select the channels, and in this case there is only one channel available (AI0). Figure 15: DAQ Assistant Wizard Select Channel When clicking Finish, the following window appears (Figure 16):

11 Using TC01 in LabVIEW Figure 16: DAQ Assistant - Properties In the Timing Settings, select 1 Sample (On Demand). You are now finished with the configuration. Click OK in the DAQ Assistant window The DAQ Assistant icon appears on the Block Diagram: Example: Wire the data output to a numeric indicator like this (and hit the Run button):

12 Using TC01 in LabVIEW Then numeric indicator will show, e.g., the following value: If you want a continuous acquisition, put a While loop around the DAQ Assistant like this: However you should not use the DAQ Assistant inside a loop because of the lack of performance. The following is therefore better: In this example we have put the DAQ Assistant outside the While loop. Inside the loop we have used the DAQmx Read.vi in order to read the value from the ai0 channel.

13 Using TC01 in LabVIEW You should also use the DAQmx Start Task.vi and the DAQmx Clear Task.vi. [End of Example]

5 Using TC01 in Visual Studio and C# Software requirements: Visual Studio + DAQmx driver 5.1 DAQmx In order to use the NI USB- TC01 Thermocouple Measurement device with C# we need to have the DAQmx driver and the DAQmx API for C# installed. Note! In order to install the DAQmx API for C#, make sure to select.net Support when installing the DAQmx driver. This application uses the C# API included in the NI DAQmx driver, so make sure that you have installed the NI DAQmx driver in advance. During the installation makesure to select Custom : 14

15 Using TC01 in Visual Studio and C# Next, make sure that you select.net Framework X.x Support for the version of.net that yourversion of Visual Studio id using: 5.2 C# Example We vill create the following simple application: Add Reference: We need to add the following Assembly references: NationalInstruments.Common

16 Using TC01 in Visual Studio and C# NationalInstruments.DAQmx We add References by right- clicking the References node in the Solution Explorer: When we have added the necessary References, the Solution Explorer will look like this: The dlls are normally to find here:

17 Using TC01 in Visual Studio and C# Initialization: We need to add the following Namespaces: using NationalInstruments; using NationalInstruments.DAQmx; Add Code: Enter the following code lines: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using NationalInstruments; using NationalInstruments.DAQmx; namespace TC01_DAQ_Example { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btngetdata_click(object sender, EventArgs e) { Task temperaturetask = new Task(); AIChannel myaichannel; myaichannel = temperaturetask.aichannels.createthermocouplechannel( "Dev1/ai0", "Temperature", 0, 100, AIThermocoupleType.J, AITemperatureUnits.DegreesC, 25 ); AnalogSingleChannelReader reader = new AnalogSingleChannelReader(temperatureTask.Stream); double analogdatain = reader.readsinglesample(); txttempdata.text = analogdatain.tostring(); } } } Test your application: Run your application. When clicking the button, you should now retrieve data from the temoerature device. Error?

18 Using TC01 in Visual Studio and C# If your application runs without error that s fine, but perhaps you get the following error: In order to fix the problem, open the Properties for your project: Make sure to select.net Framework X in the Target framework drop- down menu.

6 Using TC01 with Measurement Studio Software requirements: Visual Studio + DAQmx driver + Measurement Studio 6.1 DAQmx Driver In order to use the NI USB- TC01 Thermocouple Measurement device with C# we need to have the DAQmx driver and the DAQmx API for C# installed. Note! In order to install the DAQmx API for C#, make sure to select.net Support when installing the DAQmx driver. 6.2 Measurement Studio C# is a powerful programming language, but has few built- in features for measurement and control applications. Measurement Studio is an add- on to Visual Studio which makes it easier to create such applications. With Measurement Studio we can implement Data Acquisition and a graphical HMI. You don t need to use the Measurement Studio to create an application where you use the NI USB- TC01 Thermocouple Measurement device (as shown in previous chapter), but it is easier. Here we will use Visual Studio and the Measurement Studio Add- in to create some DAQ examples where we get temperature data from the NI USB- TC01 Thermocouple Measurement device. 6.3 Create a NI Windows Application In this example, we will select the NI windows Application Template in the New Project window (Error! Reference source not found.). 19

20 Using TC01 with Measurement Studio Figure 17: NI Windows Application Note! The New Project window may look different on your computer, it depends on what features you have installed and which version or edition of Measurement Studio you are using. Next we select the Class Libraries we want to include. In our case we need at least to select the DAQmx Library (Error! Reference source not found.). Figure 18: Measurement Studio Class Libraries

21 Using TC01 with Measurement Studio When we click Finish an empty project will be created for us. We are now ready to create our own application. We start by creating a simple User Interface (Error! Reference source not found.): Figure 19: Simple User Interface for reading Temperature Data When we click the Read Temp button, the Temperature data shall be shown in the Temp Data TextBox. In the event Handler for the Read Temp button, we create the following code: private void btnreadtempdata_click(object sender, EventArgs e) { Task analogintask = new Task(); AIChannel myaichannel; myaichannel = analogintask.aichannels.createthermocouplechannel( "Dev1/ai0", "Temperature", 0, 100, AIThermocoupleType.J, AITemperatureUnits.DegreesC, 25 ); } AnalogSingleChannelReader reader = new AnalogSingleChannelReader(analogInTask.Stream); double analogdatain = reader.readsinglesample(); txttempdata.text = analogdatain.tostring(); Then we can test our application:

22 Using TC01 with Measurement Studio Improvements: We should use a Timer in order to read Temperature data at specific intervals instead of pushing a button each time we need data. We drag in a Timer component from the Toolbox. First, we need to start the Timer: public Form1() { InitializeComponent(); } timer1.start(); Next, we need to specify the interval. We can do that in the Properties window: In the Timer Event we write the code for reading the Temperature: private void timer1_tick(object sender, EventArgs e) { Task analogintask = new Task(); AIChannel myaichannel; myaichannel = analogintask.aichannels.createthermocouplechannel( "Dev1/ai0", "Temperature", 0,

23 Using TC01 with Measurement Studio 100, AIThermocoupleType.J, AITemperatureUnits.DegreesC, 25 ); AnalogSingleChannelReader reader = new AnalogSingleChannelReader(analogInTask.Stream); double analogdatain = reader.readsinglesample(); } txttempdata.text = analogdatain.tostring("0.0"); Finally, we test the application: Congratulations, you have created your first DAQ application using Measurement Studio. 6.4 Create a NI DAQ Windows Application Note! This option is only availible if you to have either the Professional or Enterprise version of the Measurement Studio software. We start by creating a New Project from Visual Studio. In the New Project window (Figure 20) we select Visual C#» Measurement Studio, and then select the NI DAQ Windows Application Template that is part of the Measurement Studio.

24 Using TC01 with Measurement Studio Figure 20: New Project Window in Visual Studio Note! The New Project window may look different on your computer, it depends on what features you have installed and which version or edition of Measurement Studio you are using. Next, we need to go through different steps in a wizard. In the first step we select Create a new project task (Figure 21): Figure 21: Add DAQ Component In the next step we select the measurement type (Figure 22), and since the NI USB- TC01 Thermocouple Measurement device is for reading Temperature values, we need to select Acquire Signals.

25 Using TC01 with Measurement Studio Figure 22: Select Measurement Type In the Acquire Signals node we first select Temperature and then select Thermocouple. Figure 23: Thermocouple Next we need to select the physical channel(s), Figure 24. Since the NI USB- TC01 Thermocouple Measurement device has only one channel available, we need to select ai0 (Analog In, Channel 0).

26 Using TC01 with Measurement Studio Figure 24: Select Physical Channels Next we can set different Properties (Figure 25), such as Input Range, Acquisition Mode, Thermocouple Type, etc.

27 Using TC01 with Measurement Studio Figure 25: Properties Finally we see a Preview of the User Interface before it is automatically generated by the Measurement Studio (Figure 26):

28 Using TC01 with Measurement Studio Figure 26: Preview of User Interface When we click Finish, the Solution, the Project and User Interface will be automatically created (Figure 27). Finally we can test the Application (Figure 28): Figure 27: Visual Studio Generated Solution

29 Using TC01 with Measurement Studio Figure 28: Test of Application With this approach we get a flying start and we can change the code as we please. The drawback with this approach is that the code that is automatically generated is a little bit messy. So actually, this is not a method I will recommend to use.

Telemark University College Faculty of Technology Kjølnes Ring 56 N- 3918 Porsgrunn, Norway www.hit.no Hans- Petter Halvorsen, M.Sc. Telemark University College Faculty of Technology Department of Electrical Engineering, Information Technology and Cybernetics E- mail: hans.p.halvorsen@hit.no Blog: http://home.hit.no/~hansha/