How do I run multiple background operations (ie, "startBackground")
5 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Kavya Vuriti
on 25 Mar 2020
Hi,
To output on two analog output channels from the same device, you can add two channels on same session.
For more information, you can refer the following link: https://www.mathworks.com/help/releases/R2019b/daq/examples/generate-signals-on-ni-devices-that-output-voltage.html
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.
0 Comments
See Also
Categories
Find more on Data Acquisition Toolbox Supported Hardware in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!