-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVTS_setupVibrotactileDevice.m
40 lines (33 loc) · 1.11 KB
/
VTS_setupVibrotactileDevice.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function VTSDevice = VTS_setupVibrotactileDevice(VTSOpts)
% sets up the NIdaq device with number of channels equal to nrStimulators
% setupVibrotactileDevice (VTSOptions)
%
% Required Input:
%
% VTSOptions : Struct containing inputs for vibrotactile experiment
%
%% Check for Options and inputs
if exist('VTSOpts' , 'var') && ~isempty(VTSOpts)
NIdaqNames = VTSOpts.NIdaqNames;
nrStimulators = VTSOpts.nrStimulators;
NIdaqRate = VTSOpts.NIdaqRate;
end
if ~exist('nrStimulators', 'var')
error ('\n\n nrStimulators is a required input\n\n')
end
if ~exist('NIdaqRate', 'var')
error ('\n\nNIdaqRate is a required input\n\n')
end
%% Set up the session
% Initialize the session and parameters
VTSDevice = daq.createSession('ni');
VTSDevice.Rate = NIdaqRate; % Rate of operation (scans/s)
% DAQ names (each can run up to 10 stimulators)
NIdaqName = NIdaqNames{1};
% Add all the output channels to the session
for ii = 0:(nrStimulators-1)
stimName = sprintf('ao%d', ii);
addAnalogOutputChannel(VTSDevice, NIdaqName, stimName, 'Voltage');
end
fprintf('\nNIdaq box successfully initialized\n\n')
end