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.

tharbprobjreadsetpress(tharBPRObj, profile)
function setPress = tharbprobjreadsetpress(tharBPRObj, profile)
% THARBPROBJREADSETPRESS reads the set pressure of Thar BPRs
% setPress = tharbprobjreadsetpress(tharBPRObj, profile) reads the set
% pressure of Thar BPRs. tharBPRObj is the BPR serial object (generated by
% tharbproj), and profile is either 'A' or 'B'.  If the profile is not
% supplied, the set pressure of the current profile is returned. The
% pressure is returned in bar.

% e.g. setPress = tharbprobjreadsetpress(tharbprobj(5)) - returns the
% current set pressure of the thar BPR on COM5 e.g. 124 (bar)

% Range:

% tharBPRObj = valid serial port object

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


% error handling
if ~nargin
    % errors
    error('Insufficient arguments')
end

% if profile wasn't defined, fetch the current set press, otherwise, error
% check the supplied profile
if nargin < 2
    % navigates to main display menu and fetches contents of screen
    response = tharbprobjdisplaymenu(tharBPRObj);

    % the set pressure is the first number on the 4th line of the screen (if on
    % the first F3 screen)
    setPress = str2double(response{4}(5:7));
    
else
    % error checks the profile
    if ~istharbprobjprofile(profile)
        % errors
        error('Profile must be either A or B.')
    end
    
    % 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
    response = tharbprobjcomm('readnoflush', tharBPRObj);

    % extracts out the numeric part and turns it into a number
    setPress = str2double(response{3}(isstrprop(response{3}, 'digit')));
    
    % returns to the display menu
    tharbprobjcomm('write', tharBPRObj, 27)
end

Contact us