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.

tharbprobjreadprofilesetup.m
function [setPress, alarmPress, extSetTemp, extAlarmTemp] = tharbprobjreadprofilesetup(tharBPRObj, profile)
% THARBPROBJREADPROFILESETUP reads a profile setup from a Thar BPR
% [setPress, alarmPress, extSetTemp, extAlarmTemp] =
% tharbprobjreadprofilesetup(tharBPRObj, profile) reads the set pressure,
% alarm pressure, external set temperature, or the external heater alarm
% temperature. tharBPRObj is the BPR serial object (generated by
% tharbproj), and profile is either 'A' or 'B'.  If the profile is not
% supplied, the setup of the current profile is returned. The pressures are
% returned in bar and the temperatures in C.  Both the extSetTemp and
% extAlarmTemp are returned as empty ('') if the external heater is
% disabled.


% error handling for non-zero argumens
error(nargchk(1, nargin, 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

% retrieves the heater status
extHeaterStatus = tharbprobjreadextheaterstatus(tharBPRObj);

% presses F4 then the profile name to get to the correct screen
tharbprobjcomm('write', tharBPRObj, [20, uint8(profile)])

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

% extracts out the numeric part and turns it into a number
setPress = str2double(response1{3}(isstrprop(response1{3}, 'digit')));

% presses enter (<CR>) to get to the next screen
tharbprobjcomm('write', tharBPRObj, 13)

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

% gets the alarm pressure out
alarmPress = response2{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')));

% returns empty fields if the external heater is not enabled
if ~extHeaterStatus
    % initialises empty fields
    extSetTemp = '';
    extAlarmTemp = '';
    
else
    % presses enter (<CR>) to get to the next screen
    tharbprobjcomm('write', tharBPRObj, 13)

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

    % gets the external set temperature out and converts it into a number
    extSetTemp = str2double(response3{3}(isstrprop(response3{3}, 'digit')));
    
    % if it was a NaN, set it to empty
    if isnan(extSetTemp)
        % resets it
        extSetTemp = [];
    end
    
    % presses enter (<CR>) to get to the next screen
    tharbprobjcomm('write', tharBPRObj, 13)

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

    % gets the alarm pressure out
    extAlarmTemp = response4{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)
    extAlarmTemp = str2double(extAlarmTemp(isstrprop(extAlarmTemp, 'digit')));
    
    % if it was a NaN, set it to empty
    if isnan(extAlarmTemp)
        % resets it
        extAlarmTemp = [];
    end
end

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

Contact us