Code covered by the BSD License  

Highlights from
CO2gui - lab control and automation

CO2gui - lab control and automation



06 Jan 2010 (Updated )

Software used for controlling and data logging lab equipment.

tharbprobjwritemaxout(tharBPRObj, maxOut, profile)
function tharbprobjwritemaxout(tharBPRObj, maxOut, profile)
% THARBPROBJWRITEMAXOUT writes the maxOut of a profile in a Thar BPR
% tharbprobjwritemaxout(tharBPRObj, maxOut, profile) writes the maxOut to a
% profile in a Thar BPR. 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 is applied to the current profile. maxOut is
% an integer from 0 to 1000.

% e.g. tharbprobjwritemaxout(tharbprobj(5), 500) - sets the maxOut of the
% current profile to 500 on the Thar BPR attached to COM5

% Range:

% tharBPRObj = valid serial port object

% maxOut = integer from 0 to 1000

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

% error handling
if nargin < 2
    % errors
    error('Insufficient arguments')
elseif ~isnumeric(maxOut) || ~isscalar(maxOut) || isnan(maxOut) || ~isreal(maxOut) || maxOut < 0 || maxOut > 30000
    % errors
    error('maxOut must be a scalar integer between 0 and 30000.')

% more error handling
if nargin < 3
    % gets the current profile
    profile = tharbprobjreadcurrentprofile(tharBPRObj);
elseif numel(profile) ~= 1 || ~any(strcmp(profile, {'A', 'B'}))
    % errors
    error('Profile must be either A or B.')
    % navigates to the display menu

% rounds the max out
roundMaxOut = round(maxOut);

% checks the maxOut
if maxOut ~= roundMaxOut
    % rounds the number
    maxOut = roundMaxOut;
    % display a warning
    warning('TharBPRWriteMaxOut:ValueTooPrecise', 'Supplied maxOut was not an integer so has been rounded off.')

% presses F5 then the profile name to get to the correct screen, skips past
% the name, kp, ki, and kd, enters maxOut, presses enter once, then 'y' to
% save the changes - it takes around 4 seconds before the BPR starts
% sending screen updates out again (no idea why)
tharbprobjcomm('writesave', tharBPRObj, [char(21), profile, char([13, 13, 13, 13]), num2str(maxOut), char(13), 'Y'])

Contact us