Why Do I Have to Specify a Number of Samples to Read When
Continuously Acquiring Data?
Primary Software:LabVIEW
Development Systems>>LabVIEW Base Development
System
Primary Software Version:1.0
Primary Software Fixed Version:N/A
Secondary Software:SignalExpress>>Development
System
Problem:Why
Do I Have to Specify a Number of Samples to Read When Continuously
Acquiring Data?
Solution:When
performing an acquisition with DAQmx , the acquired data is
transferred into your software (LabVIEW, SignalExpress, C-code,
etc) in two important transfer steps:
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.
Data
is read from the buffer and into your software memory in chunks.
When you are prompted to enter a number of samples on the DAQmx
Read VI, it is asking for the size parameter of this transfer.
When
you configure the DAQmx Timing VI for your task in LabVIEW,
theSamples
per Channelvalue
has a different effect depending on whether theSample
Modeis
set toContinuous
SamplesorFinite
Samples.
ForFinite
Samples, theSamples per
Channeldetermines the exact number
of samples to acquire before the task completes.
ForContinuous
Samples, theSamples per
Channelis used to determine the
size of the buffer.
When you configure the DAQmx Read VI, you are essentially
configuring the second transfer from the buffer to the software
memory. In this VI, there is an input calledNumber
of Samples per Channel.
When the task sampling mode is set to continuous,
theNumber
of Samples per Channelinput
sets the size, in samples, of each chunk that is read from the
buffer into the software.
In Signal Express, this parameter is input asSamples
to Read,
in theConfigurationtab
of theStep
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 takes the
data off of the buffer and pulls it into the software for
processing. Therefore, if the sampling rate is not fast enough 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 reduce theNumber
of Samples per Channel.
In LabVIEW, you also have the option of setting the value
ofNumber
of Samples per Channelto
be -1, which is the default setting in LabVIEW if no value is
specified. When theNumber
of Samples per Channelis
set to -1, the DAQmx Read VI will read all data that is available
in the buffer. If no data is available in the buffer, the DAQmx
Read VI will return an empty array.
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:2009-03-30
Last Updated:2015-03-03
Document ID:4VTI04BQ