LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

understanding data acquisition/logging

Hi, I'm just trying to fully understand how data acquisition/logging works in Labview.

How I understand it is as follows:

- The DAQ card is initialized to sample at a certain sampling frequency. (This happens once outside of the main While Loop)
- Inside the While Loop you set up a vi to read the inputs for the desired channels. Here you choose how many samples to read each iteration of the loop.

I'm having trouble understanding how to log the data continously. For example, say we set sampling frequency to1000Hz, and we have an AI Read.vi the grabs 100 samples each loop iteration. Each time the While Loop iterates, 100 samples will be grabbed, then the loop will do whatever other instructions it contains, and then another 100 samples will be grabbed. The problem here is that the data is not being sampled at a constant continuous frequency (since a small amount of time elapses while the loop is running various other instructions. Am I just not understanding this correctly or is this true. If it is, is there a way to ensure a constant continuous logging?

I guess maybe is there a buffer, that holds a continous amount of samples so that when the loop iterates it actually grabs the samples from the buffer so that it is continuous? The problem I have with this is that unless you synchronize the sampling rate and the # of samples obtained each iteration perfectly, you are going to overflow your buffer and then you will end up with a non continuous situation again.

I'm hoping someone can clarify exactly what is going on, and maybe give some tips on rules of thumb for sampling frequency vs. # of samples grabbed.

Thanks! I really appreciate it!

Sunny
0 Kudos
Message 1 of 4
(2,633 Views)
Hi Sunny,
I am actually not experienced with DAQ, but I worked already with the RS232- interface & CAN-Bus. From this point I can say it is very likely that there is an input buffer filled in background while you can work on some calculations and data-presentation / -storage. The sampling of data is done by the DAQ-card continuously by itself. Thatswhy you can trust on the card to sample at the given samplerate. And because it is timed by a quartz- circuit, the accuracy should be much higher than doing it with the "wait until next ms multiple"-VI or other solutions based on the Windows- timer.
You could test this by connecting an input of the DAQ-card to a Signalgenerator sending some TTL- pulses, just saving the data and analyze, whether the amount of samples between the pulses are constant.
You can solve the problem with a buffer overflow by reading the whole amount of data from the input buffer, appending it to an array of the data you collected before (a good solution is to store it in a shift register of your main while loop or even better in an uninitialized shift register of a sub-VI) and from this array you do the calculations and data-presentation / -storage.

With best regards,
Dave

Message Edited by daveTW on 05-03-2006 08:45 AM

Greets, Dave
0 Kudos
Message 2 of 4
(2,621 Views)

Ideally, you do not keep any over head program ( like other than saving to a file)  inside a while loop that has a DAqmx read.

There will be a default AI buffer enabled in DAQmx read that ensures that no data will be lost in event of a process as you describe, in case you do not specify an AI buffer in your program

Yes you need to keep an optimal number of samples to read for a specified sampling rate or a buffer over flow will occur.

this you can derive by a few trials.

usually,  i keep samples to read = sampling rate, or 1/2 sampling rate, or 1/10 of sampling rate depending on the sampling rate and overheads, if any

hope this helps regards

Dev

 

0 Kudos
Message 3 of 4
(2,613 Views)
Sunny,
 
Just to add to Dave and Dev's posts.  There are a lot of examples that ship with LabVIEW, including continuous acquisition and saving that data to a file.  The example may not serve your exact purpose, but they serve as a great starting point when trying to understand the fundamentals. These examples can be found in Help >> Find Examples.  Here you can search for examples by either keyword or application type.  Start with Cont Acq&Graph Voltage-To File(Binary).vi.  Like I said, it may not be exactly what you want, but will be a great starting point.  Have a great day!
 
Regards,
L. Allen
0 Kudos
Message 4 of 4
(2,599 Views)