outputSingleScan() causing errors in R2018b?
1 次查看(过去 30 天)
显示 更早的评论
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! :)
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Acquisition Toolbox Supported Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!