Specify per-channel allocated memory
Note: You cannot use the legacy interface on 64–bit MATLAB®. See Session-Based Interface to acquire and generate data.
BufferingConfig is a two-element vector that specifies the per-channel allocated memory. The first element of the vector specifies the block size, while the second element of the vector specifies the number of blocks. The total allocated memory (in bytes) is given by
(block size).(number of blocks).(number of channels).(native data type)
You can determine the native data type with daqhwinfo.
You can allocate memory automatically or manually. If BufferingMode is Auto, the BufferingConfig values are automatically set by the engine. If BufferingMode is Manual, then you must manually set the BufferingConfig values. If you change the BufferingConfig values, BufferingMode is automatically set to Manual.
When memory is automatically allocated by the engine, the block-size value depends on the sampling rate and is typically a binary number. The number of blocks is initially set to a value of 30 but can dynamically increase to accommodate the memory requirements. In most cases, the number of blocks used results in a per-channel memory that is somewhat greater than the SamplesPerTrigger value. When you manually allocate memory, the number of blocks is not dynamic and care must be taken to ensure there is sufficient memory to store the acquired data. If the number of samples acquired or queued exceeds the allocated memory, then an error is returned.
You can easily determine the memory allocated and available memory for each device object with the daqmem function.
AI, AO, common to all channels
Two-element vector of doubles
Read-only when running
The default value is determined by the engine, and is based on the number of channels contained by the device object and the sampling rate. The BufferingMode value determines whether the values are automatically updated as data is acquired. For analog output objects, the default number of blocks is two.
Create the analog input object ai for a sound card and add two channels to it.
ai = analoginput('winsound'); addchannel(ai,1:2);
The block size and number of blocks are given by BufferingConfig, while the native data type for the sound card is given by daqhwinfo.
ai.BufferingConfig ans = 512 30 out = daqhwinfo(ai); out.NativeDataType ans = int16
With this information, the total allocated memory is calculated to be 61,440 bytes. This number is stored by daqmem.
out = daqmem(ai); out.UsedBytes ans = 61440
The allocated memory is more than sufficient to store 8000 two-byte samples for two channels. If more memory was required, then the number of blocks would dynamically grow because BufferingMode is set to Auto.