How to que analog and digital output simultaneously?

6 ビュー (過去 30 日間)
Ashley
Ashley 2020 年 1 月 10 日
回答済み: Kavya Vuriti 2020 年 4 月 2 日
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();

回答 (1 件)

Kavya Vuriti
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!!

カテゴリ

Help Center および File ExchangeAnalog Input and Output についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by