LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Access to time of each measure made by a DAQ USB TC01

Solved!
Go to solution

Hello everyone,

I'm trying to make a VI which measures temperature with a DAQ USB TC01 and saves the measurements in a text file to be reused after. Unfortunately, I can't access to the date and time of each measurement made by the DAQ. For example, now I have a list of temperature : 

26,654971
26,679116
26,679116
26,686015
And I would like to add a line corresponding to the date and time of each temperature like this (here I supposed that each measurement is made with 2 ms interval:

080524_160522,002  26,654971
080524_160522,004  26,679116
080524_160522,006  26,679116
080524_160522,008  26,686015

Please find attached the VI.

Thank you for your answer

0 Kudos
Message 1 of 5
(351 Views)

There are a number of methods to do this -- it depends (a bit) on how you handle the data acquisition.  Unfortunately, like many long-time LabVIEW developers who participate in the Forums, I do not have recent LabVIEW versions installed, so I can't examine your code.  Could you please "Save for Previous Version" and specify LabVIEW 2019 or 2021?

 

If you are sampling using Continuous Samples and a fixed Sampling Frequency, you can save the data as a Waveform, which bundles a Time Stamp showing the time of the first sample and a "dt" that gives the time between successive samples.  You can also use the LabVIEW Time functions to "time-stamp" the samples (again, assuming Continuous Sampling, otherwise you need to get "time" for each sample ...).

 

Show us your code (in a version of LabVIEW we can open) and we can make further suggestions.

 

Bob Schor

0 Kudos
Message 2 of 5
(297 Views)

Thank you for your answer.

Here the code with a 2019 version.

Best,

Manon

0 Kudos
Message 3 of 5
(280 Views)
Solution
Accepted by topic author phdmancn

Bon jour, Manon.

 

It has been many years since I studied Le Français in high school, so I will continue in English.

 

There is a very useful NI White Paper that I read, and finally learned and understood how to use DAQmx.  Do a Web search for Learn 10 Functions in NI-DAQmx and Handle 80% of Your Data Acquisition Applications, 

 

So I'm looking at your code, and noticing a few things that are "missing" or at least unclear to me, some related to your question about Finite vs Continuous sampling.

 

First, it appears that you are sampling a single channel, as your Physical Channel input has only a single Dev1/ai0 entry.  You are missing a DAQmx Timing function (which should go before the Start Task function).  Your DAQmx Read is 1D Wfm NChan/NSamp, but you only have a single Channel defined.

 

So here are some questions:

  1. What sampling rate are you using for temperature?  Note that temperature tends to vary "slowly", so you might want a "slow" sampling rate, like 1 Hz, or even 0.01 Hz (one reading every 100 seconds).  With such slow rates, you might want to acquire one sample at a time, particularly if you want to "look at them" (via a Chart) or respond "quickly" when it exceeds some limits.
  2. You set the timing with the DAQmx Timing function. What is your sampling rate, and how many samples do you want to acquire before you "do something with them" (such as check for values too high or too low)?  I'm guessing you'll sample fairly slowly, and will want to process every sample.  To process every sample, you should use either Continuous Sampling with a sample size of 1 or Hardware Timed Single Point (if your device supports this).  This function comes just before the Start DAQmx function.  You also specify the sampling Rate here, so putting in "1" means you'll take one temperature reading per second.
  3. If you are doing a single sample, your DAQmx Read will specify Single Channel Single Sample, and will probably be a Dbl.  If you don't need to immediately see every sample (but could collect, say, 10-100 at a time at some faster rate, say 10 Hz), you could try 1 Chan N Samp Waveform, which gives you the Time information that you might want.  Just be aware you will not "see" your data until the sample has finished.

For example, suppose you say "I want to sample at 10 Hz and take 100 samples at a time".  Your DAQmx Read loop (if you set Continuous Sampling at a rate of 10 with 100 samples/channel) will sample for 10 seconds, deliver a waveform (if you asked for it) with 100 data points, and loop waiting for the next sample 9.998 seconds later (actually, it's probably 9.99998 seconds, as enqueuing a Waveform takes very little time).

 

Set your Waveform Queue to hold a single Waveform, as you are sampling a single channel.

 

See how that works.

 

Bob Schor

0 Kudos
Message 4 of 5
(267 Views)

Thank you for your answer.

I could fix the Multiple Channel to Single channel with multiple samples. But when I tried to include a Sample Clock the VI didn't work anymore. The error code associated is : 

Error 200077 occurred at DAQ Assistant

Property: SampTimingType

Requested Value: Sample Clock

Possible Values: On Demand

 

After some research, it seems that the USB TC01 doesn't support a sample clock for that analog input (https://forums.ni.com/t5/LabVIEW/SampTimingType-Error-200077-using-myDAQ/td-p/3828578).

 

The DAQ must therefore be replaced. As I then want to create a PID control for the temperature via an Arduino Uno, I'll take an Arduino-compatible MAX31855 thermocouple amplifier. This solution is less expensive.

Thank you again for your advice,

Manon

0 Kudos
Message 5 of 5
(234 Views)