Why am I unable to start an ANALOGOUTPUT object when manually setting its BufferingConfig property and using RepeatOutput?

1 view (last 30 days)
I am using Data Acquisition Toolbox 2.11 (R2007b). I am creating an ANALOGOUTPUT (AO) object and manually setting its BufferingConfig property to a value that represents an amount of memory allocation that is more than what is required for the analog data I wish to output, which is of length 50e3:
ao = analogoutput('nidaq','Dev1');
chan = addchannel(ao,0);
% The default for a data output vector of length 50e3 is [4096 7]
set(ao,'BufferingConfig',[4097 50])
Setting a custom BufferingConfig automatically sets the BufferingMode property of the AO object to 'Manual'. I am also setting the AO object's RepeatOutput property to a non-zero value so as to repeat the output a desired number of times:
set(ao,'RepeatOutput',29);
I then put data on the output queue with PUTDATA:
putdata(ao, frameData);
When issuing a START on AO, I receive the following error:
>> start(ao)
??? The total number of samples queued before starting has exceeded the number of
buffers in in BufferingConfig.
Increase the number of buffers or use 'Auto' BufferingMode.
Error in ==> daqdevice.start at 63
start( daqgetfield(obj,'uddobject') );

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
It is preferable to let the Data Acquisition Toolbox engine configure the BufferingConfig property automatically. If you feel you must modify BufferingConfig and are also setting RepeatOutput greater than the default of zero, there are a number of things to be taken into consideration.
When BufferingMode is set to the default of 'Auto', the second value of BufferingConfig - the number of buffers - shows the initial number, but that number will grow as necessary inside the engine. This is not reflected when examining the BufferingConfig property.
Manually modifying BufferingConfig restricts the number of buffers to the number you specify.
For instance, in this case:
Create an analogoutput object and add 1 channel:
>> ao = analogoutput('nidaq','Dev1');
>> chan1 = addchannel(ao,0);
Note the default BufferingConfig value:
>> ao.BufferingConfig
ans =
64 2
Setting the sample rate increases the buffer size:
>> ao.SampleRate=50000;
>> ao.BufferingConfig
ans =
4096 2
Putting data increases the number of buffers:
>> putdata(ao,zeros(25000,1))
>> autoBufferingConfig = ao.BufferingConfig % Save value for calculation below
autoBufferingConfig =
4096 7
Note that BufferingMode is still 'Auto':
>> ao.BufferingMode
ans =
Auto
Increasing RepeatOutput does not change BufferingConfig but since you're in Auto mode the engine will add buffers as necessary (this is not reflected when examining the BufferingConfig property):
repeatOutput = 29;
ao.RepeatOutput=repeatOutput;
ao.BufferingConfig
ans =
4096 7
You can start the object:
>> start(ao)
Now if you manually set BufferingConfig to these same values, BufferingMode is set to Manual:
>> stop(ao) % cannot change BufferingConfig while object is running
>> ao.Bufferingconfig = [4096 7];
>> ao.BufferingMode
ans =
Manual
>> putdata(ao,zeros(25000,1))
The number of buffers is constrained and you can no longer start the object:
>> start(ao)
??? The total number of samples queued before starting has exceeded the number of buffers in BufferingConfig. Increase the number of buffers or use 'Auto' BufferingMode.
Calculate the number of buffers needed by taking the number of buffers used when BufferingMode = 'Auto' and multiply by the number of repetitions:
>> autoNumBufs = autoBufferingConfig(2);
>> newNumBufs = ceil((repeatOutput + 1) * autoNumBufs);
>> ao.BufferingConfig = [autoBufferingConfig(1) newNumBufs]
>> putdata(ao,zeros(25000,1))
With more buffers we can start the object:
>> start(ao)
Notes:
1. When you use RepeatOutput and Manual buffering the number of buffers must be great enough to hold the data for the entire output session, not just enough to hold the amount of data sent to PUTDATA.
2. You cannot allocate more than 2000 buffers with BufferingConfig.
3. When RepeatOutput is very large or Inf, you must set BufferingMode to 'Auto'.

More Answers (0)

Products


Release

R2007b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!