Code covered by the BSD License  

Highlights from
Thar ABPR-20 RS232 communication via handheld emulation

Thar ABPR-20 RS232 communication via handheld emulation



20 May 2013 (Updated )

Controls and reads from a Thar ABPR-20, by emulating the handheld controller.

tharbprobjreadalarmpress(serialObject, profile)
function alarmPress = tharbprobjreadalarmpress(serialObject, profile)
% THARBPROBJREADALARMPRESS reads the alarm pressure of Thar BPRs
% alarmPress = tharbprobjreadalarmpress(serialObject, profile) reads the
% alarm pressure of Thar BPRs. serialObject is the BPR serial object
% (generated by tharbproj). The pressure is returned in bar.  The profile
% is either 'A' or 'B', or omitted, in which case the name of the current
% profile is used.

% e.g. tharbprobjreadalarmpress(serialObject) - returns the current alarm
% pressure of the Thar BPR e.g. 600 (bar)

% Range:

% serialObject = valid serial port object

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

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

% if profile wasn't defined, fetch the current one, otherwise, error check
% the supplied profile
if nargin < 2
    % gets the current profile
    profile = tharbprobjreadcurrentprofile(serialObject);
elseif ~istharbprobjprofile(profile)
    % errors
    error('Profile must be either A or B.')

% presses F4, the profile name, then enter (<CR>) once to get to the
% correct screen
tharbprobjcomm('write', serialObject, [20, uint8(profile), 13])

% reads the screen out (using 'readnoflush' since the screen does not get
% continually updated here)
response = tharbprobjcomm('readnoflush', serialObject);

% gets the alarm pressure out
alarmPress = response{3}(14:16);

% extracts out the numeric part and turns it into a number (there is a
% parenthesis in there that will move depending on the number of digits
% involved)
alarmPress = str2double(alarmPress(isstrprop(alarmPress, 'digit')));

% navigates back to the display menu
tharbprobjcomm('write', serialObject, 27)

Contact us