outputSingleScan() causing errors in R2018b?

3 views (last 30 days)
Chaitanya Jha
Chaitanya Jha on 10 Jan 2019
Edited: Chaitanya Jha on 30 Apr 2019
Hi, I am using Data Acquisition Toolbox with National Instrument's 'USB-6221oem' board. My aim is to configure two different sessions, one for handling the Analogue I/O and other for Digital Output in the user interface that I am developing. In R2018b the Data Acquisition Toolbox function 'outputSingleScan(s,data)' is causing errors, this error was not present in R2018a. When I run the code below
% Session for Digital Output
D = daq.createSession('ni');
Dout = D.addDigitalChannel('Dev1','Port0/Line0:4','OutputOnly');
% Session for Analogue Input/Output
A = daq.createSession('ni');
A.Rate = 100000;
Ain = A.addAnalogInputChannel('Dev1','ai0','Voltage');
Ain.TerminalConfig = 'SingleEnded';
Aout = A.addAnalogOutputChannel('Dev1','ao0','Voltage');
% Data for Analogue Output
DataOut = ones(50,1);
% Execution
outputSingleScan(D,[0 0 0 1 0]);
queueOutputData(A,repmat(DataOut,20,1));
DataIn = startForeground(A);
outputSingleScan(A,0);
outputSingleScan(D,[0 0 1 0 0]);
% If successful execution
disp('Done!');
Matlab gives me the error 'The data argument must contain one column for each output channel in the session.' at line 20 which is the line outputSingleScan(D,[0 0 1 0 0]); (3rd last line in above code, this line of code is to send a single output for the session configured for Digital Output). However, when I comment out line 19: outputSingleScan(A,0); (4th last line in above code, this line of code is to send a single output for the session configured for Analogue I/O) the script runs successfully.
It doesn't matter if there are any lines of code between line 19 (output for the session configured for Analogue I/O) and line 20 (output for the session configured for Digital output), the execution always stops when it encounters the outputSingleScan(D,[0 0 1 0 0]); for session configured for Digital output and this line is number given as the error line in the command window. Also, as you can see in the above code if I execute the outputSingleScan(D,[0 0 0 1 0]); function for Digital output Session and then execute the outputSingleScan(A,0); function for Analogue I/O Session then it works fine. The error only occurs when I execute outputSingleScan(D,[0 0 0 1 0]); function for Digital output Session AFTER I have executed the outputSingleScan(A,0); function for Analogue I/O Session.
This problem has been driving me crazy from last 3 days. Do any of you know why this is happening? Thanks for your time and help in advance! :)
  6 Comments
Steven Lord
Steven Lord on 8 Apr 2019
This sounds like it may be Bug Report 1935216 which is listed as fixed in release R2019a.
Chaitanya Jha
Chaitanya Jha on 30 Apr 2019
Edited: Chaitanya Jha on 30 Apr 2019
Indeed, it looks like Matlab has addressed this bug in R2019a. However, the fix is not what I hoped it would be as we still have to use the clearSingleScanCache function between successive calls to outputSingleScan or inputSingleScan. I have been doing this since last one year when I reported the bug, I was hoping for a better solution where we do not have to use clearSingleScanCache at all like in previous versions of Matlab. Hopefully in R2019b :)

Sign in to comment.

Answers (0)

Categories

Find more on Data Acquisition Toolbox Supported Hardware in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!