When Should I Use Continuous or Finite Sampling Modes? Primary Software: LabVIEW Development Systems>>Full Development SystemPrimary Software Version: 7.1 Primary Software Fixed Version: N/A Secondary Software: LabWindows/CVI Development Systems>>Full Development System Hardware: Multifunction DAQ (MIO)
Problem: When should one use Continuous, or N samples, or one of the other types of sampling, and what do they mean? Solution: Any given situation calls for a most appropriate mode of Sample Timing, and each type of sample timing makes more sense in a particular flow of DAQ programming. Before going on, it is important to describe the two basic steps to turning a measurement into a number in your computer. The first step is the one that depends on your DAQ hardware. This step is the actual conversion of a voltage at your input into a number of bits in the buffer in RAM. This is performed by the Analog to Digital Converter (ADC) of your hardware. The second step is the act of reading these bits off the buffer. The bits are read as a floating point number in most cases, and this is all done by your PC CPU and your program. When these two steps happen is the main difference between Continuous and Finite acquisition. Continuous sampling means that the DAQ hardware is continuously reading the voltage at the input and converting it into bits on the buffer, at a rate dictated by the sample clock. This makes Continuous sampling the choice for those who are worried about missing samples due to the speed of their program or the speed of their computer. The speed at which the DAQ hardware acquires samples is always given by the sample clock settings, and this part of the acquisition is entirely done by the hardware. The purpose of the buffer is to allow the hardware to acquire the data very fast while the software might read the buffer asynchronously or at an unknown (and probably slower) rate. For a continuous task, the acquisition begins when the Start Task VI runs.This VI should only be placed before a while loop, as it requires a certain amount of overhead and also interacts with the CPU. Then within the loop, the DAQmx Read VI actually reads the buffer. It makes sense to read more than one point at a time here as reading too few points will result in buffer overflow. You will notice that the DAQ driver will only allow you to read 2 or more samples from a continuous task. If you are reading only one point at a time, reconsider either your application or the sampling style you are using. If you request more points to read (samples per channel) than are yet ready, the DAQmx read VI won't finish until that number of points is available. This may appear as a delay in your graphs updating, but does not mean any samples are going to be missed. Using a -1 for the samples per channel input will read as many new samples as are available at that moment. N samples (also called Finite acquisition) is useful when only a certain amount of data is necessary and is especially complimentary to triggered tasks. For example, you may need 10 seconds worth of data, starting at some time zero defined by the trigger. Finite mode will only buffer the samples when you call the Start Task VI, and any trigger conditions have been met. Again, the software speed has no effect on the hardware-timed writing of samples to the buffer. The DAQmx Read VI will read these samples off the buffer, and it makes sense to ask for the same number N of samples here. This task is compatible with a while loop or a state machine. However, unlike continuous sampling, you must actually call Start Task, then Read, then Stop Task, during each iteration of the loop. Otherwise, the DAQ driver will try to Read samples even though it has already fulfilled your request for N samples and you will receive an error. Keep in mind that the time between a given "run" of N samples in such a loop is therefore software timed and subject to slight variations. If you run into timing concerns here, then continuous acquisition is recommended. Acquiring one sample with hardware or software timing is like acquiring N samples. This is useful when you need to process or otherwise react to each incoming sample, and are not concerned with precise timing. Perhaps a battery is slowly losing voltage over the course of several minutes or hours, and when it gets below a certain threshold an email needs to be sent to an operator. The sample is acquired when Start Task is called as usual. If it is hardware timed, it may make more sense to think of this as hardware synchronized. The sample is acquired at the next sample clock tick to come in after Start Task is called. Choosing the proper type of sampling for your application, and programming it appropriately, will result in the most efficient program possible. Often error messages can be avoided by selecting carefully. Related Links: Attachments:
Report Date: 05/09/2005 Last Updated: 06/20/2005 Document ID: 3L8BGMXL |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
