-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpollMFC.m
37 lines (30 loc) · 825 Bytes
/
pollMFC.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
function out=pollMFC(ID,rate,samples)
% Poll Alicat MFC at regular interval
%
% function out=pollMFC(AC,ID,rate,samples)
%
% Purpose
% Poll Alicat MFC "ID" every "rate" seconds, obtaining
% "samples" number of data points.
%
% Inputs
% ID - unit ID to sample
% rate - scaler defining how often to record. e.g. a rate of 0.2
% will obtain 5 sample a second.
% samples - how many samples to obtain
%
%
% Rob Campbell - June 2010
%Connect to MFC serial port
global aliComm;
if isempty(aliComm), aliComm=connectAlicat; end
rateLimit=0.05;
if rate<rateLimit
fprintf('Desired rate is too fast, setting rate to %f\n',...
rateLimit)
end
for ii=1:samples
fprintf(aliComm,ID); %Triggers the MFC identified by the string "ID" so it generates a data report
out(ii)=readMFC(aliComm);
pause(rate)
end