-
Notifications
You must be signed in to change notification settings - Fork 1
/
valveCalibrate.m
69 lines (58 loc) · 1.5 KB
/
valveCalibrate.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function valveCalibrate(nClicks, rewardType)
global daqSession
global OFFLINE
global EXP
if nargin<1
nClicks=100;
end
if nargin<2
rewardType='CORRECT';
end
OFFLINE=false;
EXP=setExperimentPars;
[~, RIGNAME]=system('hostname');
if ~isempty(strfind(RIGNAME, 'ZAMBONI'))
daqVendorName = 'ni'; % this name is used for 64-bit interface
aoDeviceID='Dev1';
aoValveChannel = 'ao0';
dioID='Dev1';
dioCh=1;
dioPort=0;
optiStimChanInd=2;
valveChanInd=1;
elseif ~isempty(strfind(RIGNAME, 'ZMAZE'))
daqVendorName = 'ni'; % this name is used for 64-bit interface
aoDeviceID='Dev1';
aoValveChannel = 'ao0';
dioID='Dev1';
dioCh=1;
dioPort=0;
optiStimChanInd=2;
valveChanInd=1;
else
aoID='Dev1';
dioID='Dev1';
dioCh=1;
dioPort=0;
optiStimChanInd=1;
valveChanInd=2;
end
daqSession = daq.createSession(daqVendorName);
daqSession.Rate = 10e3;
% defining the Analog Output object for the valve (for precise timing)
daqSession.addAnalogOutputChannel(aoDeviceID, aoValveChannel, 'Voltage');
daqSession.outputSingleScan(valveClosedVoltage);
%
% TRIAL.info.optiStim=0; % just a patch to prevent the reward() function from crashing
% DIO = digitalio('nidaq', dioID);
% addline(DIO, dioCh, dioPort, 'Out', {'SOL1'});
% start(DIO);
% putvalue(DIO.Line(1), 1); % high value - closing the valve
large = EXP.largeRewardTime
small = EXP.smallRewardTime
for iClick=1:nClicks
reward(rewardType)
pause(0.3);
end
stop(daqSession);
delete(daqSession);