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.

bprobjwritesetpress(BPRObj, setPress)
function bprobjwritesetpress(BPRObj, setPress)
% BPROBJWRITESETPRESS sets the pressure of Jasco BPRs
% bprobjwritesetpress(BPRObj, setPress) sets the pressure on Jasco
% back-pressure regulators, where BPRObj is a valid serial port object
% (generated by bprobj) and setPress is the pressure in bar (number from
% 0-350).  The pressure is automatically rounded to the nearest integer.

% e.g. bprobjwritesetpress(BPRObj(5), 100) - sets the pressure of the BPR on
% COM5 to 100 bar

% Range:

% BPRObj = valid serial port object

% setPress = unsigned number: 0-350


% checks the number of arguments
error(nargchk(2, 2, nargin))

% error handling
if ~isnumberbetween(setPress, 0, 350)
    % errors
    error('Set pressure must be a number from 0 to 350 bar')
end

% converts and rounds the pressure off (warns if it does)
setPress = roundto(setPress * 10, 0, true);
    
% need to convert number into a hexadecimal string for the bprcomm command
% - sends command
bprobjcomm(BPRObj, ['#0x44 ', dec2hex(setPress)])

Contact us