Skip to content

Commit

Permalink
A single device ID for AO and AI.
Browse files Browse the repository at this point in the history
  • Loading branch information
raacampbell committed Jun 4, 2017
1 parent 4a28f81 commit 893bca2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions code/+vidrio/+mixed/AOandAI_OO.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@

% Define properties that we will use for the acquisition
properties
DAQdevice = 'Dev1'

%Properties for the analog input end of things
hAITask %The AI task will be kept here
AIDevice = 'Dev1'
AIChans = 0:1
AIterminalConfig = 'DAQmx_Val_RSE' %Valid values: 'DAQmx_Val_Cfg_Default', 'DAQmx_Val_RSE', 'DAQmx_Val_NRSE', 'DAQmx_Val_Diff', 'DAQmx_Val_PseudoDiff'

%Properties for the analog output end of things
hAOTask %The AO task will be kept here
AODevice = 'Dev1'
AOChans = 0:1

% Shared properties
Expand Down Expand Up @@ -147,8 +147,8 @@ function connectToDAQandSetUpChannels(obj)
obj.hAOTask = dabs.ni.daqmx.Task('mixedAO');

% Set up analog input and output voltage channels
obj.hAITask.createAIVoltageChan(obj.AIDevice, obj.AIChans, [], obj.minVoltage, obj.maxVoltage, [], [], obj.AIterminalConfig);
obj.hAOTask.createAOVoltageChan(obj.AODevice, obj.AOChans);
obj.hAITask.createAIVoltageChan(obj.DAQdevice, obj.AIChans, [], obj.minVoltage, obj.maxVoltage, [], [], obj.AIterminalConfig);
obj.hAOTask.createAOVoltageChan(obj.DAQdevice, obj.AOChans);


% * Set up the AI task
Expand All @@ -173,7 +173,7 @@ function connectToDAQandSetUpChannels(obj)
obj.hAOTask.writeAnalogData(obj.waveforms, 5)

% Configure the AO task to start as soon as the AI task starts
obj.hAOTask.cfgDigEdgeStartTrig(['/',obj.AIDevice,'/ai/StartTrigger'], 'DAQmx_Val_Rising');
obj.hAOTask.cfgDigEdgeStartTrig(['/',obj.DAQdevice,'/ai/StartTrigger'], 'DAQmx_Val_Rising');
catch ME
daqDemosHelpers.errorDisplay(ME)
%Tidy up if we fail
Expand Down
12 changes: 6 additions & 6 deletions code/+vidrio/+mixed/AOandAI_OO_sharedClock.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@

% Define properties that we will use for the acquisition
properties
DAQdevice = 'Dev1'

%Properties for the analog input end of things
hAITask %The AI task will be kept here
AIDevice = 'Dev1'
AIChans = 0:1
AIterminalConfig = 'DAQmx_Val_RSE' %Valid values: 'DAQmx_Val_Cfg_Default', 'DAQmx_Val_RSE', 'DAQmx_Val_NRSE', 'DAQmx_Val_Diff', 'DAQmx_Val_PseudoDiff'

%Properties for the analog output end of things
hAOTask %The AO task will be kept here
AODevice = 'Dev1'
AOChans = 0:1

% Shared properties
Expand Down Expand Up @@ -141,16 +141,16 @@ function connectToDAQandSetUpChannels(obj)
obj.hAOTask = dabs.ni.daqmx.Task('mixedAO');

% Set up analog input and output voltage channels
obj.hAITask.createAIVoltageChan(obj.AIDevice, obj.AIChans, [], obj.minVoltage, obj.maxVoltage, [], [], obj.AIterminalConfig);
obj.hAOTask.createAOVoltageChan(obj.AODevice, obj.AOChans);
obj.hAITask.createAIVoltageChan(obj.DAQdevice, obj.AIChans, [], obj.minVoltage, obj.maxVoltage, [], [], obj.AIterminalConfig);
obj.hAOTask.createAOVoltageChan(obj.DAQdevice, obj.AOChans);


% * Set up the AI task

% Configure the sampling rate and the buffer size
% ===> SET UP THE SHARED CLOCK: Use the AO sample clock for the AI task <===
% The supplied sample rate for the AI task is a nominal value. It will in fact use the AO sample clock.
obj.hAITask.cfgSampClkTiming(obj.sampleRateAO, 'DAQmx_Val_ContSamps', [], ['/',obj.AODevice,'/ao/SampleClock']);
obj.hAITask.cfgSampClkTiming(obj.sampleRateAO, 'DAQmx_Val_ContSamps', [], ['/',obj.DAQdevice,'/ao/SampleClock']);

% Read back the data with a callback function at an interval defined by updatePeriod
% Also see: basicConcepts/anonymousFunctionExample.
Expand All @@ -169,7 +169,7 @@ function connectToDAQandSetUpChannels(obj)
obj.hAOTask.writeAnalogData(obj.waveforms, 5)

% Configure the AO task to start as soon as the AI task starts
obj.hAOTask.cfgDigEdgeStartTrig(['/',obj.AIDevice,'/ai/StartTrigger'], 'DAQmx_Val_Rising');
obj.hAOTask.cfgDigEdgeStartTrig(['/',obj.DAQdevice,'/ai/StartTrigger'], 'DAQmx_Val_Rising');
catch ME
daqDemosHelpers.errorDisplay(ME)
%Tidy up if we fail
Expand Down

0 comments on commit 893bca2

Please sign in to comment.