DAQ session : share trigger connection for analog input and output sessions

3 vues (au cours des 30 derniers jours)
Marc Gesnik
Marc Gesnik le 25 Nov 2019
Hello,
I have a NI USB-6003 and matlab 2018a, with data acquisition toolbox. I would like to start an analog input session and an analog output session simultaneously, based on an external trigger. On the USB-6003, there are two ports that can be used fort trig-in PFI1 and PFI0. But I want to use only PFI1 for trig-in (because I am using PFI0 as a counter in another session).
So ideally I want to use PFI1 trigger connection to start 2 sessions.
Here is the simpified code I would ideally like to use :
% % % % % -- Analog inputs -- % % % % %
DAQsessionAI = daq.createSession('ni');
% open a channel
ch0 = DAQsessionAI.addAnalogInputChannel('Dev1','ai0', 'Voltage');
% % % % % -- Analog outputs -- % % % % %
DAQsessionAO = daq.createSession('ni');
% open a channel
chOut0 = DAQsessionAO.addAnalogOutputChannel('Dev1','ao0', 'Voltage');
% % % % % -- triggering -- % % % % %
% use PFI1
trigChAI = addTriggerConnection(DAQsessionAI,'external','Dev1/PFI1','StartTrigger'); % trig AI
trigChAO = addTriggerConnection(DAQsessionAO,'external','Dev1/PFI1','StartTrigger'); % trig AO
%% set analog output (with a dummy output)
DAQsessionAO.Rate = 5000; % [Hz] sampling rate of signals, max 5000
DAQsessionAO.IsContinuous = true; % [true/false].
% build a dummy output signal
AcqDurationAO = 5; % [s] total duration of analog output
timeOutput = 0:(1/DAQsessionAO.Rate):AcqDurationAO; % [s]
f_out = 10; %[Hz]
outputData = sin(timeOutput.*2.*pi.*f_out)';
queueOutputData(DAQsessionAO,outputData);
%% set analog inputs
DAQsessionAI.Rate = 10000; % [Hz] sampling rate of signals
DAQsessionAI.IsContinuous = true; % background acquisition will run until we stop it.
% listener ( a dummy listener function that simply do : plot(event.TimeStamps, event.Data) )
lh = addlistener(DAQsessionAI,'DataAvailable', @PlotData);
%% background acquisition
startBackground(DAQsessionAI);
startBackground(DAQsessionAO);
but when calling startBackground, It get error -89137
NI Error -89137:
Specified route cannot be satisfied, because it requires resources that are currently in use by another route.
Property: DAQmx_DigEdge_StartTrig_Src
Property: DAQmx_DigEdge_StartTrig_Edge
Source Device: Dev1
Source Terminal: PFI1
Required Resources in Use by
Device: Dev1
Reserved Terminal: AO/PFI1
Task Name: _unnamedTask<84>
Status Code: -89137
In a nutshell : Is it possible to share a trigger connection between 2 sessions and how to do it properly ?

Réponses (0)

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by