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.

tharbprobjreadextsettemp.m
function extSetTemp = tharbprobjreadextsettemp(tharBPRObj, profile)
% THARBPROBJREADEXTSETTEMP reads the set external temperature of Thar BPRs
% extSetTemp = tharbprobjreadextsettemp(tharBPRObj, profile) reads the set
% external temperature of Thar BPRs. tharBPRObj is the BPR serial object
% (generated by tharbprobj). The temperature is returned as a double
% precision scalar number in C, and the profile is 'A', 'B', or omitted,
% in which case the current profile is used.  Note that if the external
% heater is not enabled, the set external temperature of a profile not in
% use is not accessible.

% CAUTION - if the profile is supplied, then this feature does not seem to
% be working correctly - menu does not appear to be updating correctly

% e.g. extSetTemp = tharbprobjreadextsettemp(tharbprobj(5)) - returns the
% set external temperature of the BPR on COM5 e.g. 50 C.

% 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, and make sure that the heater is enabled to allow
% the reading of this
if nargin < 2
    % navigates to second display menu and fetches contents of screen
    response = tharbprobjdisplaymenu2(tharBPRObj);

    % the set pressure is the first number on the 3rd line of the screen (if on
    % the second F3 screen)
    extSetTemp = str2double(response{3}(5:7));

    % presses F3 again to go back to the first display menu
    tharbprobjcomm('write', tharBPRObj, 19)
    
elseif ~istharbprobjprofile(profile)
    % errors
    error('Profile must be either A or B.')
    
elseif ~tharbprobjreadextheaterstatus(tharBPRObj)
    % errors - note that the above function also guarauntees that we are in
    % the correct menu
    error('Cannot read the external alarm temperature if the external heater is not enabled.')
    
else
    % presses F4, the profile name, then enter (<CR>) twice to get to the
    % correct screen
    tharbprobjcomm('write', tharBPRObj, [20, uint8(profile), 13, 13])

    % reads the screen out (using 'readnoflush' since the screen does not
    % get continually updated here
    response = tharbprobjcomm('readnoflush', tharBPRObj);
    
    % gets the external set temperature out and converts into a number
    extSetTemp = str2double(response{3}(isstrprop(response{3}, 'digit')));

    % navigates back to the display menu
    tharbprobjcomm('write', tharBPRObj, 27)
    
    % if the number has come out as a NaN, possibly in a wrong menu, so errors
    if isnan(extSetTemp)
        % errors
        error('Could not retrieve external heater set temperature - value not accessible from menu for an unknown reason.')
    end
end

Contact us