Code covered by the BSD License  

Highlights from
Jasco BPR RS232 communication

Jasco BPR RS232 communication



20 May 2013 (Updated )

Drivers and higher level commands for controlling Jasco BPRs via RS232.

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

% e.g. bprobjcurrentpress(serialObject) - returns the current pressure of
% the BPR e.g. 100.12 (bar)

% Range:

% serialObject = valid serial port object

% checks the number of arguments
error(nargchk(1, 1, nargin))
% sends command (returns both pressure and temperature)
currentPress = bprobjcomm(serialObject, '#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;

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

Contact us