Code covered by the BSD License  

Highlights from
CO2gui - lab control and automation

CO2gui - lab control and automation

by

 

06 Jan 2010 (Updated )

Software used for controlling and data logging lab equipment.

tharbprobjreadalarmpress(tharBPRObj, profile)
function alarmPress = tharbprobjreadalarmpress(tharBPRObj, profile)
% THARBPROBJREADALARMPRESS reads the alarm pressure of Thar BPRs
% alarmPress = tharbprobjreadalarmpress(tharBPRObj, profile) reads the alarm
% pressure of Thar BPRs. tharBPRObj is the BPR serial object (generated by
% tharbproj). The pressure is returned in bar.  The profile is either 'A'
% or 'B', or omitted, in which case the name of the current profile is
% used.

% e.g. tharbprobjreadalarmpress(tharbprobj(5)) - returns the current alarm
% pressure of the Thar BPR on COM5 e.g. 600 (bar)

% Range:

% tharBPRObj = valid serial port object

% profile = 'A', 'B' or omitted


% check the number of arguments
error(nargchk(1, 2, nargin))

% if profile wasn't defined, fetch the current one, otherwise, error check
% the supplied profile
if nargin < 2
    % gets the current profile
    profile = tharbprobjreadcurrentprofile(tharBPRObj);
    
elseif ~istharbprobjprofile(profile)
    % errors
    error('Profile must be either A or B.')
end

% presses F4, the profile name, then enter (<CR>) once to get to the
% correct screen
tharbprobjcomm('write', tharBPRObj, [20, uint8(profile), 13])

% reads the screen out (using 'readnoflush' since the screen does not get
% continually updated here)
response = tharbprobjcomm('readnoflush', tharBPRObj);

% gets the alarm pressure out
alarmPress = response{3}(14:16);

% extracts out the numeric part and turns it into a number (there is a
% parenthesis in there that will move depending on the number of digits
% involved)
alarmPress = str2double(alarmPress(isstrprop(alarmPress, 'digit')));

% navigates back to the display menu
tharbprobjcomm('write', tharBPRObj, 27)

Contact us