MATLAB Answers

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

3 ビュー (過去 30 日間)
Tyler Strauss
Tyler Strauss 2020 年 2 月 26 日
回答済み: Kavya Vuriti 2020 年 3 月 25 日
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 件のコメント

サインインしてコメントする。

回答 (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.

  0 件のコメント

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by