How to que analog and digital output simultaneously?

5 visualizzazioni (ultimi 30 giorni)
Ashley
Ashley il 10 Gen 2020
Risposto: Kavya Vuriti il 2 Apr 2020
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();

Risposte (1)

Kavya Vuriti
Kavya Vuriti il 2 Apr 2020
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!!

Categorie

Scopri di più su Digital Input and Output in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by