LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to control sample rate, data acquision export to excel

Thank you for that! Much appreciated!

 

I still have another question. I want to increase the rate at which the data is written. At the moment it is around 5 lines per second, how can I increase the sample rate of data written?

 

Again, thanks in advance for your help.

0 Kudos
Message 11 of 16
(754 Views)

You have two 1 channel N sample VIs one for input one for output.  There is nothing in the SubVI that indicates the setup of those processes.  My guess is that combined they take about 200 ms and there is no way around that unless you use something other than an FFT based frequency detector.

0 Kudos
Message 12 of 16
(742 Views)

Thank you again for your help.

 

I have attached images of the setup for the input and output. How would I know how long they take and is there anyway to increase this? Is there any alternative to obtain a faster sample rate and obtain more samples? Also, any alternative to FFT and would this improve sample rate?

 

Thanks again

Download All
0 Kudos
Message 13 of 16
(731 Views)

On both of those you are reading/writing 1000 samples at 10,000 samples per second.  That takes 0.1 sec each. 

 

You can use less points or a higher sample rate but it would cost you in the frequency/phase resolution on the output. where

 

deltaF = Sample_rate / N

 

Alternately you can increase the signal frequency of the sine wave and the sample rate.  you want several cycles of the sine wave in order to get decent frequency resolution.  You can see what i mean if you play around with the parameters and look at a plot of the fft

0 Kudos
Message 14 of 16
(725 Views)

Thank you again, your replies have been very helpful after spending a long time and not making progress.

 

I have set the output frequency to 150Hz, why, when I change the output 'Samples to write' and 'Rate' change the actual frequency that is physically being driven? How do I determine the optimum frequency to drive at the required frequency without those figures changing the output?

 

Thanks again

0 Kudos
Message 15 of 16
(717 Views)

I'm going to guess that you are largely "self-taught" about LabVIEW, and have not taken full advantage of the "LabVIEW Training Resources" listed on the first page of this Forum.

 

I'm also going to guess that you've not had any experience with "Signal Analysis", including acquiring signals by modern Data Acquisition techniques, including sampling (and how that works).

 

LabVIEW is a language designed by Engineers (and largely targetted for Engineers) to build "Virtual Instruments" for testing (and sometimes replacing) hardware designs.  Indeed, the name comes from Laboratory Virtual Instrument Engineering Workbench (hence the funny style of capitalization).

 

LabVIEW includes a particularly robust (and fairly User-Friendly, once you "Learn 10 Functions in NI DAQmx" and handle 80% of your Data Acquisition Applications -- I encourage you to search that phrase on the Web) and can easily handle the tasks you are trying to do, but you need to learn a little more in order to do it properly.

 

LabVIEW is a Data Flow language, which makes it behave a little differently (as far as timing goes) from other computer languages you may have used.  You've seen, already, that there are things such as Controls (or "inputs"), Indicators (or "outputs"), Functions, and Structures (Loops, Case Structures, etc.) and something called "Wires" that connect them and carry Data.  There are three important "Rules" for Data Flow:

  1. No Structure or Function will start running until every Wire coming into it has Data.
  2. No Structure or Function will put Data on its "output" Wires until the Structure or Function exits.
  3. No Structure or Function can exit until everything "inside it" has run.

LabVIEW also differs from other computing languages in elevating "Time" to have an elevated importance.  This is especially important when dealing with Data Acquisition and DAQmx.

 

Suppose you want to acquire data and save it for later analysis.  Let's say you want to acquire the data at 1 kHz, and acquire it for 10 minutes.  That means taking 1000 x 60 x 10 = 600 k points.  Should you take them one-at-a-time?  That's a lot of tiny operations (almost a million of them!).  Better that you take them, say, 1000 at a time, so every second, you get 1000 points.  No problem writing 1000 points to disk in a second, right?

 

Most Data Acquisition (or DAQ) hardware that works with LabVIEW can take single samples, or multiple samples based on an internal (and generally quite accurate) "Hardware Clock".  So you can ask the Hardware to acquire 1000 points at 1 kHz and do it "over and over again until I say Stop" (or until you do it 600 times, if you want 10 minutes worth).  Suppose you put such a DAQmx Read function inside a For Loop (with 600 wired to N).  How fast will the Loop run?

 

The Third Law of Data Flow says that if a DAQ Read function inside the Loop is acquiring 1000 samples at 1 kHz, that operation will take exactly 1 second, so the Loop (without you having to do any other timing!) will run at exactly 1 Hz (or once per second).  Now all you have to do is write the data to disk!

 

But that's also simple.  Before entering the Loop, open a Disk File for writing, and bring the Wires (representing the Error Line and the  File Reference) into the For Loop.  Take the output from the DAQmx Read holding the 1000 points of data and wire in to a File Write function (which you assume takes less than 1 second).  Bring the File Reference wire to the right edge of the For Loop, and put the "Close File" function outside the Loop to close the file.

 

Now run the program.  You enter the For Loop at t = 0 (say).  The DAQmx Read starts to run, but the File Write function just sits there because there's no "Data" from the DAQmx Read to the File Write present yet.  At t = 1 (second), the DAQmx Read finishes and passes the data to the File Write.  [Oops -- I forgot to say that you configure the DAQmx Read to "sample continuously", meaning as soon as it finishes the first 1000-point sample, it continues sampling without a break to get the next 1000 points].  Assume the File Write takes 0.7 seconds.  So at 1.7 seconds, the For Loop finishes Loop 0, and starts Loop 1.

 

Now we're in Loop 1, with 70% of the 1000 points already collected.  So 0.3 seconds later, the DAQmx finishes, passes the data to the File Write, and at 1.7 + 0.3 + 0.7 = 2.7 seconds later, Loop 1 finishes, and on to Loop 2.  We continue the DAQmx Read/File Write sequence until we reach Loop 599, after which the For Loop exits, passes the File Reference to Close File, and you're done.

 

Give it a whirl.

 

Bob Schor

Message 16 of 16
(705 Views)