-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathreadLoop.m
60 lines (46 loc) · 971 Bytes
/
readLoop.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
function varargout=readLoop(MFC)
% function loop=readLoop(MFC)
%
% Query the loop mode of an MFC
%
% Inputs
% MFC - string specifying the controller ID
%
% Outputs
% loop - string giving the loop type. If no output arg then
% just print to screen.
%
%
% Example
% L=readLoop('B')
%
%
% Rob Campbell June 2010
global aliComm;
if isempty(aliComm), aliComm=connectAlicat; end
fprintf(aliComm,[MFC,'$$R20']);
F=fscanf(aliComm);
loop=regexp(F,'= (.*)','tokens');
loop=str2num(loop{1}{1});
%9460 is mass flow (For the 1 and 5 SLPM controllers)
%9238 is mass flow (For the 0.5 SLPM controllers)
mass=[9238,9460];
volumetric=mass-2^10+768;
pressure=mass-2^10+256;
switch loop
case {volumetric(1),volumetric(2)}
L='volumetric';
case {mass(1),mass(2)}
L='mass';
case {pressure(1),pressure(2)}
L='pressure';
end
if nargout==0
fprintf('%s\n',L)
end
if nargout>0
varargout{1}=L;
end
if nargout>1
varargout{2}=loop;
end