Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
2 ratings:
 4 out of 5     Rate this Document

Why Do I Have to Specify a Number of Samples to Read When Continuously Acquiring Data?

Primary Software: LabVIEW Development Systems>>LabVIEW Base Package
Primary Software Version: 1.0
Primary Software Fixed Version: N/A
Secondary Software: LabVIEW SignalExpress>>Development System

Problem:
Why Do I Have to Specify a Number of Samples to Read When Continuously Acquiring Data?

Solution:
When using DAQ, the acquired data is imported into your software (LabVIEW, SignalExpress, C-code, etc) in two important transfer steps. In the first, the data is transferred from the DAQ device into the memory (RAM) of your computer. There is a finite amount of space in the RAM, called the buffer, which is reserved for that transfer. In the second, the data is read from the RAM and into your software in chunks. Thus when you are prompted to enter a number of samples for continuous measurement, it is asking for the size parameters of these transfers.

So, for example, when you configure the DAQmx Timing VI for your task in LabVIEW, you are essentially configuring the first transfer from card to RAM. This buffer is abstracted away in the hardware and is separate from any accessible data in your software. One of the inputs to the timing VI is Samples per Channel. When the Sample mode input is set to Continuous Samples, the Samples per Channel defines the relative size of this buffer that is reserved in RAM.



Likewise, when you configure the DAQmx Read VI, you are essentially configuring the second transfer from the buffer to the software. In this VI there is an input called Number of Samples per Channel. When the task sampling mode is set to continuous, the Number of Samples per Channel input sets the size, in samples, of each chunk that is read from the buffer into the software.



In Signal Express, this parameter is inputted as Samples to Read, in the Configuration tab of the Step Setup.



It should be noted that the DAQmx Read VI waits until a chunk of data at least that big exists in the buffer before it will take the data off of the buffer and into the software for processing. Therefore if the sampling rate is not sufficient to create a chunk of this size in the time allotted by the timeout, the VI will throw a timeout error. To prevent this, increase the timeout or reducing the chunk size. In LabVIEW, you also have the option of entering -1 as the value, which is the default setting in LabVIEW if none is set. When set to -1, the DAQmx Read VI will read all data is available in the buffer.

Related Links:
KnowledgeBase 2V3FK03J : Samples Per Channel Input of -1 On the DAQmx Read VI
KnowledgeBase 27R8Q3YF: How Is the Actual Scan Rate Determined When I Specify the Scan Rate for My Data Acquisition?

Attachments:





Report Date: 03/30/2009
Last Updated: 11/24/2009
Document ID: 4VTI04BQ

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit