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.

tharbprobjwriteextsettemp.m
function tharbprobjwriteextsettemp(tharBPRObj, extSetTemp, profile)
% THARBPROBJWRITEEXTSETTEMP writes the external set temp of Thar BPRs
% tharbprobjwriteextsettemp(tharBPRObj, extSetTemp, profile) writes the
% external set temp 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 external set temperture is applied to the
% current profile. The temperature must be supplied in C.  If the external
% heater is disabled, then the external temperature cannot be set.

% e.g. tharbprobjwriteextsettemp(tharbprobj(5), 500) - sets the external
% set temperature of the current profile to 50 C on the Thar BPR attached
% to COM5

% Range:

% tharBPRObj = valid serial port object

% extSetTemp = integer from 0 to 75

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


% error handling
if nargin < 2
    % errors
    error('Insufficient arguments')
elseif ~isscalar(extSetTemp) || ~isNumberBetween(extSetTemp, 0, 75)
    % errors
    error('extSetTemp must be a scalar integer between 0 and 75.')
elseif onoff(tharbprobjreadextheaterstatus(tharBPRObj))
    % errors
    error('Cannot set external heater set temperature if the heater is not enabled.')
end

% more error handling
if nargin < 3
    % gets the current profile, and turns it into lower case for data input
    profile = tharbprobjreadcurrentprofile(tharBPRObj);
    
elseif numel(profile) ~= 1 || ~any(strcmp(profile, {'A', 'B'}))
    % errors if not 'A' or 'B'
    error('Profile must be either A or B.')
end

% checks the external set temperature
if isInteger(extSetTemp)
    % rounds the number
    extSetTemp = round(extSetTemp);
    
    % display a warning
    warning('TharBPRWriteExtSetTemp:ValueTooPrecise', 'Supplied exteral set temperature was not an integer so has been rounded off.')
end

% presses F4, then the profile name, enter twice, writes the new set
% temperatur , enter twice, then Y to save the changes
tharbprobjcomm('writesave', tharBPRObj, [char(20), profile, char([13, 13]), num2str(extSetTemp), char([13, 13]), 'Y'])

Contact us