outputSingleScan() causing errors in R2018b?

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

Tom DeLonge
Tom DeLonge 2019년 3월 8일
I also observed similar bugs, but did not bother investigating further. I returned to Matlab 2018a
Chaitanya Jha
Chaitanya Jha 2019년 3월 15일
편집: Chaitanya Jha 2019년 3월 15일
Hi Tom,
After writing this question here I reached out to Matlab, they checked it and it turns out it is indeed a bug in R2018b. They gave me an undocumented function clearSingleScanCache() to help with this issue. The way this function works is you call this function before calling outputSingleScan(). Example:
outputSingleScan(D,[0 0 0 1 0]);
queueOutputData(A,repmat(DataOut,20,1));
DataIn = startForeground(A);
clearSingleScanCache(A); % 1st call to undocumented function
outputSingleScan(A,0);
clearSingleScanCache(D); % 2nd call to undocumented function
outputSingleScan(D,[0 0 1 0 0]);
This will work even if you call the clearSingleScanCache() function only before calling the outputSingleScan() for Digital Session i.e. only the 2nd call in above code.
Hope this helps!
Tom DeLonge
Tom DeLonge 2019년 3월 26일
Thank you for letting me know. Do you know whether this bug is fixed in 2019a?
Chaitanya Jha
Chaitanya Jha 2019년 4월 8일
I am not sure if it is fixed or not, I haven't yet started using 2019a.
Steven Lord
Steven Lord 2019년 4월 8일
This sounds like it may be Bug Report 1935216 which is listed as fixed in release R2019a.
Chaitanya Jha
Chaitanya Jha 2019년 4월 30일
편집: Chaitanya Jha 2019년 4월 30일
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 :)

댓글을 달려면 로그인하십시오.

답변 (0개)

제품

릴리스

R2018b

질문:

2019년 1월 10일

편집:

2019년 4월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by