How do I run multiple background operations (ie, "startBackground")

3 次查看(过去 30 天)
I'm having trouble sending multiple simultanious outputs to the same DAQ. Here's the realavent part of my code:
%% initialize DAQ
daqreset
%laser controller
sLaser = daq.createSession('ni');
sLaser.addAnalogOutputChannel('Dev1','ao0','Voltage');
sLaser.Rate = 2000;
%estim controller
sElectro = daq.createSession('ni');
sElectro.addAnalogOutputChannel('Dev1','ao1','Voltage');
sElectro.Rate = 2000;
stim_pattern_output=[0 0 0 5 5 5 0 0 0 5 5 5]; %not the actual output, but it'll give you an idea
stim_pattern_output=stim_pattern_output';
queueOutputData(sElectro, stim_pattern_output)
startBackground(sElectro)
queueOutputData(sLaser, stim_pattern_output)
startBackground(sLaser)
Ultimately, when we get to "startBackground(sLaser)" I get the error "The hardware associated with this session is reserved. If you are using it in another session use the release function to unreserve the hardware. If you are using it in an external program exit that program. Then try this operation again."
Is there a workaround for this? I'm a bit new to the program, but I cannot imagine there's such a major limiting factor to DAQ useable with MATLAB to only allow one output/daq at a time.

回答(1 个)

Kavya Vuriti
Kavya Vuriti 2020-3-25
Hi,
To output on two analog output channels from the same device, you can add two channels on same session.
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.

类别

Help CenterFile Exchange 中查找有关 Hardware Discovery and Setup 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by