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.

bprobjreadall.m
function data = bprobjreadall(BPRObj)
% BPROBJREADALL returns the current data of Jasco BPRs
% data = bprobjreadall(BPRObj) returns a cell array, with the current valve
% temperure, the set valve temperature, the currrent pressure, the set
% pressure, and the last element is empty since there is no flow rate to
% read.


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

% pre-allocates the answer
data = cell(1, 6);

% try-catches everything to get as much data out as possible
try
    % gets current temperature and current pressure
    current = bprobjcomm(BPRObj, '#0x1000 0x12');

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

    % selects out the temperature and converts into C
    data{1} = hex2dec(current{1}{4}) / 100;

    % selects out the pressure and converts it into bar
    data{3} = hex2dec(current{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
    if data{3} > negativeOffset - 1000
        % modifies the pressure
        data{3} = data{3} - negativeOffset;
    end
    
    % converts from MPa into bar
    data{3} = data{3} / 10;
    
catch
end

try
    % requests set temperature
    data{2} = bprobjreadsettemp(BPRObj);
    
catch
end

try
    % requests set pressure
    data{4} = bprobjreadsetpress(BPRObj);
    
catch
end

try
    % gets the valve status
    data{6} = bprobjstatus(BPRObj);
    
catch
end

Contact us