LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using LabVIEW and a USB-6008 for data acquisition

Solved!
Go to solution

Hello,

 

I am relatively new to LabVIEW and am hopeless stuck. Currently I am attempting to trend data from a temperature sensor. I am using a USB-6008 to sample the data. I have made a VI that is able to trend the data. I would ideally like to export this data to an Excel spreadsheet.

 

My original plan was to run my VI and then right-click on the waveform graph and export the data to Excel. When I run my VI; it will run for a set number of samples, or for a fixed duration. I am able to receive data and I know it is in the ballpark (I have a DMM in parallel). The problem is that the data will overwrite itself once my preset number of samples, or fixed duration, has been realized. This is a problem because I potentially need to collect up to an hours worth of data. I have not been able to figure out how to get the data to trend continuously without writing over previously collected data. This is a lot of data and LabVIEW has already yelled at me for overloading it.

 

I have attached my VI so everyone can see what I have done. I believe I have set it to sample once per second. This sample rate should be fine for my purposes. I could even reduce it further but do not know how to sample in samples/min as opposed to samples/sec.

 

I truly appreciate any help. I have not been able to find anything out there to help so far. It may be because I am not typing my problem using correct vocabulary. Again, I am very much a beginner with all things LabVIEW. 

0 Kudos
Message 1 of 6
(2,930 Views)

Hi JJK,

 

As you said, your VI is currently set to sample one data point (as a DBL) per second.

Since you have it set to "Duration" rather than number of samples, it should return a waveform with 10 points.

 

As you've already discovered (but maybe not yet understood 😉 ) LabVIEW has both Charts and Graphs.

 

A "Chart" (not what you're using) has a fixed length (you can customise this, changing it at runtime sometimes deletes the data depending on how you change it, usually set it with the Right-click menu before running), whereas a "Graph" displays only what you tell it, each time you update it.

 

Charts will automatically store history up until they run out of space in the allowed length, then they'll start deleting older points to make space for newer points.

Graphs only show what is connected, and (at least in principle, perhaps the code under the hood is a little cleverer) completely redraw the entire graph every time you write to them.

 

As a result, to store older data in a Graph you'll usually need to use something like a Shift Register.

A simple example is below (you could adapt this to your case):

Example_VI.png

Note that in the comments I highlight this array is unbounded - it will grow forever with this design.

 

You should take a look at Producer/Consumer designs, since they are commonly used to deal with acquisition (Producer) and logging/graphing (Consumer), but your data rate as given is very low, so on a standard computer (desktop, laptop etc) you should actually have no problem either way...

With 1 Hz sampling, an hour is only 3600 samples or about 3600*8B (size of double) ~= 30kB. Hopefully you can spare that much memory!

 

Edit: Note, there's a select node and control to allow you to switch and see the difference, but you typically just pick what you want (often the top) and don't need the Select.


GCentral
0 Kudos
Message 2 of 6
(2,858 Views)
Solution
Accepted by topic author JJK1503

Since you are just getting started in LabVIEW and DAQmx, I would suggest you do something a little different first.  You are taking data "slowly", i.e. a point a second, so why not have an "scope" display that shows every point as it is acquired, sweeping from left-to-right like an Oscilloscope, and re-tracing at the end?  To do this, change your DAQmx Read to DAQmx, 1 Channel, 1 Sample.  Remove the Graph (which is a static display of whatever you write to it, so if you write, say, 10 points, you will see 10 points) and replace it with a Chart (which is a dynamic display that shows "what came before plus what you just added").  Charts come in three types:  Strip Chart (the default, plot goes from left to right until it reaches the right end, then the "paper" scrolls off to the left and the latest point keeps getting added on the right end, the idea being a paper Strip Chart recorder), a Scope Chart (like an old-fashioned oscilloscope, with the points added from left to right, and when the end is reached, the Chart is erased and the next series of points are added left to right), and Sweep Chart (like newer oscilloscopes, where the new points are added left to right, and in subsequent sweeps, the "new" point replaces the "old" point).  Right-click the Chart (on the Front Panel or Block Diagram), choose "Properties", and you can set the Update Mode to Strip, Scope, or Sweep Chart.

 

Play with this so that you understand how Charts work.  They are great for showing time-varying data as it comes in.  If all you need to do is "look at" the incoming data (and don't need to save or process it), you can let LabVIEW's Chart worry about handling (and temporarily saving) the data for you.  If you use a Graph, you would to accumulate all of the data as it comes in, as you show, anew, first one point, then two points, then three ..., whereas Charts let you show "the latest point" and have all of the earlier points "managed by LabVIEW".

 

Bob Schor

0 Kudos
Message 3 of 6
(2,835 Views)

Hi Bob,

 

Thank you for your help. Your response was thorough and very helpful.

 

I have a follow up question. You mentioned "change your DAQmx Read to DAQmx, 1 Channel, 1 Sample". I do have many options that contain DAQmx but none that are only called DAQmx. What should I use? I am enclosing a screenshot of my pallet. The path is Measurement I/O > NI DAQmx.

0 Kudos
Message 4 of 6
(2,792 Views)

Do you see the VI on the DAQmx Pallet called "Read"?  The "full name" of this function is "DAQmx Read".  Here's a picture ...

DAQmx Read.png

 

Bob Schor

0 Kudos
Message 5 of 6
(2,768 Views)

If you click on the dropdown box under the Read VI, (actually, I don't remember if this was visible in your VI, so perhaps right click and go to Visible Items > Polymorphic Selector or similar), then you get a bunch of options.

 

You can choose between various different reading methods. Currently you have one channel, multiple samples with duration.

Bob is suggesting (if I read correctly) one channel, one sample (double, not waveform).

 

You can try out various settings and see how they change. For multiple samples (double array) or single sample (double) you could also use the snippet I included previously, since an array and a single element can be concatenated together, just like the two arrays (of potentially different lengths).

To use the chart at the rate that you're wanting (1Hz) reading a single sample will be most responsive (it will take 1 second per iteration - currently your loop takes 10*1 second and returns 10 points in a waveform).


GCentral
0 Kudos
Message 6 of 6
(2,766 Views)