How to que analog and digital output simultaneously?
5 次查看(过去 30 天)
显示 更早的评论
I am trying to use two analog channels and one digital channel on a daq. I am passing the daq session_info a file called "trial_sequence" with a matrix called flicker_info of 3 columns of 0's and 1's, one column per channel. I know that the matrix file works becasue I've troubleshooted by using 3 analog channels and it works, but I need the third channel to go to a digital output.
However, I keep getting the following error:
"The hardware you are trying to use is already reserved"
Is there a way to queue digital output or not rely on outputSingleScan?
clear; clc; %clear everything
timeStarted = cputime;
daqreset; %reset DAQ in case it's still in use by a previous Matlab program
session_info = daq.createSession('ni');
session_info.IsContinuous = true; %for continuous background generation of the signal
sample_rate = 100000; %sample rate is 100k
session_info.Rate = sample_rate; %pass the sample rate to the DAQ
addAnalogOutputChannel(session_info,'Dev1', [2 3], 'Voltage'); % AO2 for sound, AO3 for LEDs
% start pump channel
addDigitalChannel(session_info,'Dev1','Port0/Line1', 'OutputOnly'); % port 0.1 on the DAQ
filename = 'trial_sequence.mat';
load(filename);
queueOutputData(session_info, flicker_info);
session_info.startBackground();
0 个评论
回答(1 个)
Kavya Vuriti
2020-4-2
Hi,
I think the reserved hardware error is not due to digital channel. Here is an example showing how to generate signals on both analog and digital channels.
In this case, the reserved hardware error is expected because the vendor's NI-DAQmx driver does not allow two separate connections to the same subsystem at once.
Hope this helps!!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Digital Input and Output 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!