LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Different values for seemingly same code

I am using LabVIEW 14.0 and I want to read temperature off of an NI 9213 Thermocouple input using an NI 9162 USB Carrier. I have written a way to do this two different ways, but one of the outputs is always a few degrees less than the other. I have attached the VI below. I think the output of the second sequence structure is the correct temperature measurement because I get similar values when using Signal Express. I need to figure out why the first frame of the sequence structure is incorrect because it is part of a larger VI where I need to be able to search for a device and then read from it. My question is why do these two versions of code give me values that are a few degrees off and how do I fix the code in the first frame of the sequence structure to give me the same readings as the first frame. 

0 Kudos
Message 1 of 5
(2,828 Views)

There are three ways to configure a DAQmx Task, one Hard Way and two Easy Ways.  You show part of a Hard Way and an Easy Way, but there is not enough information present to examine the specifications and understand why your two readings are different, but I'm going to wager (a dime) that it lies in the Task Definition.

 

The Hard Way is exemplified by your first Sequence.  You use a bunch of DAQmx functions, including Create Virtual Channel, and possibly Timing functions, to define the Task, followed by a DAQmx Read.

 

The two Easy Ways use either MAX or the LabVIEW Project to define the Task.  I'm hoping you did this using LabVIEW Project (if you had, you should attach the entire Project Folder, with all the VIs, which you can do by compressing the folder and attaching the resulting .ZIP file), but in case you used MAX, I'll describe how to do this in Project.

 

  1. Open your Project.  Right-click "My Computer" (assuming the device is plugged into your PC) and choose New, DAQmx Task.
  2. In the Create New ... window, choose Acquire Signals, Analog Input, Temperature, and the rest of the specifications for your device.  You should also have your device plugged in so that you can choose the correct Device Name.
  3. Once you've chosen the Device Name, choose the Channel(s) that you want to record.  I notice you talk about "Thermocouple" (singular), yet you specify recording from 16 Analog Channels -- is this a mistake?
  4. Name the Task (so LabVIEW can find it), set the Task parameters, and pay attention to the Acquisition Mode (do you want one sample, or multiple samples at some interval?).
  5. When you click "OK", your Task will appear in your Project.

Suppose you do this and decide you only want to take one temperature reading from a single Channel (which you configured in Step 3, choosing a single channel).  You only need a single DAQmx function to do this, the DAQmx Read (yes, you could/should have a DAQmx Start and a DAQmx Stop or Close ...).  Drop down the DAQmx Read, right-click the Task In connector, say "Create Constant", right-click the selection arrow, and choose the (probably only) Task that you see, the one you just created in Project.  It should look something like this (I named my dummy task ProjectTemperatureTask, the default name Project chose for me):

Temp Task.png

Bob Schor

0 Kudos
Message 2 of 5
(2,814 Views)

@MaddieDrake wrote:

.... My question is why do these two versions of code give me values that are a few degrees off and how do I fix the code in the first frame of the sequence structure to give me the same readings as the first frame. 


THere are details in the second version we can not see without having a copy of your MAX configuration. But YOU can ....

 

Copy the task constant for the second frame to a new VI.

Right-Click and select Generate >>> Configuration

 

Compare what is in the Sub-VI that is generated to what your explicit code does. Guessing Cold Junction maybe?

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 5
(2,800 Views)

Thank you for your response. I'm not sure your answer will work with what I am trying to do because I have multiple sets of NI-9213s and NI-9162s. I need to be able to plug in any one of these and have them work with my program without having to reconfigure NI Max or the project folder. This is why I need to figure out why the first frame is not working properly, because I will be searching for the device that is plugged in and then reading the thermocouple's temperature from it. 

0 Kudos
Message 4 of 5
(2,797 Views)

@Bob_Schor wrote:

... an Easy Way, but there is not enough information present to examine the specifications ...

 

The Hard Way is exemplified by your first Sequence. ...

 

Bob Schor


Hi Bob,

 

I prefer the hard way because all of the details are in the diagrams and not off in another configuration file somewhere. It only took the challenge of converting a 150 channel application developed using traditional DAQ and custom scales to DAQmx to convince to avoid using the virtual channels.

 

I have also seen situation where pepole have loaned their PC to another reseach group for short experiment only to find out MAX had been changed and teh application no longer runs.

 

The "hard way" is more solid and requires less effort to duplicate or move between machines.

 

Just my 2 cents,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 5 of 5
(2,796 Views)