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.

bprobjcurrentpress(BPRObj)
function currentPress = bprobjcurrentpress(BPRObj)
% BPROBJCURRENTPRESS reads the current pressure of Jasco BPRs
% currentPress = bprobjcurrentpress(BPRObj) reads the current pressure of
% Jasco BPRs. BPRObj is the BPR serial object (generated by bprobj).
% Pressure is in bar.

% e.g. bprobjcurrentpress(bprobj(5)) - returns the current pressure of the
% BPR on COM5 e.g. 100.12 (bar)

% Range:

% BPRObj = valid serial port object


% checks the number of arguments
error(nargchk(1, 1, nargin))
    
% sends command (returns both pressure and temperature)
currentPress = bprobjcomm(BPRObj, '#0x1000 0x12');

% splits response into a cell array - the response should be "#0 0
% temperature pressure"
currentPress = textscan(currentPress, '%s');

% selects out the pressure
currentPress = hex2dec(currentPress{1}{3});

% defines the offset to use for negative numbers
negativeOffset = hex2dec('100000000');

% guards against a strange error where the BPR gives a large number
% when the pressure is negative (this number is usually the SAME large
% number, so the error handling for this could be more precise)
if currentPress > negativeOffset - 1000
    % modifies
    currentPress = currentPress - negativeOffset;
end

% current press convert from MPa to bar
currentPress = currentPress / 10;

Contact us