Solution
With NI-DAQmx, memory allocation for input/output tasks is typically handled automatically for you in the DAQmx Timing Function (for LabView, see DAQmx Timing (VI) - NI).
Input Tasks:
- If the acquisition is finite (sample mode on DAQmx Timing function is set to Finite Samples), NI-DAQmx allocates a buffer equal in size to the value of samples per channel.
- If the acquisition is continuous (sample mode on the DAQmx Timing function is set to Continuous Samples), NI-DAQmx allocates a buffer equal in size to the value of the samples per channel attribute/property, unless that value is less than the value listed in the following table. If the value of the samples per channel attribute/property is less than the value in the table, NI-DAQmx uses the value in the table.
Sample Rate | Buffer Size |
---|
No rate specified | 10 kS |
0-100 S/s | 1 kS |
101-10,000 S/s | 10 kS |
10,001-1,000,000 S/s | 100 kS |
>1,000,000 S/s | 1 MS |
Note: You can override the default buffer size by calling the DAQmx Configure Input Buffer VI.
Output Tasks:
For an output task, the amount of data you write before starting a generation determines the size of the buffer. The first call to a Multiple Samples version of the Write function/VI creates a buffer and determines its size.
You also can use the Output Buffer Config function/VI to create an output buffer. If you use this function/VI, you must use it before writing any data.
The samples per channel attribute/property on the Timing function/VI does not determine the buffer size for output. Instead it is the total number of samples to generate. If n is your buffer size, setting samples per channel to 3×n generates the data in the buffer exactly three times. To generate the data exactly once, set samples per channel to n.