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.

function extAlarmTemp = tharbprobjreadextalarmtemp(serialObject, profile)
% THARBPROBJREADAEXTALARMTEMP reads the ext. alarm temperature of Thar BPRs
% alarmTemp = tharbprobjreadextalarmtemp(serialObject, profile) reads the
% alarm temperature of Thar BPRs. serialObject is the BPR serial object
% (generated by tharbproj). The temperature is returned in C.  The profile
% is either 'A' or 'B', or omitted, in which case the name of the current
% profile is used.

% e.g. tharbprobjreadextalarmtemp(serialObject) - returns the current
% external alarm temperature of the Thar BPR e.g. 100 (C).

% Range:

% serialObject = valid serial port object

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

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

% can only read the external temperature if it is enabled
if ~tharbprobjreadextheaterstatus(serialObject)
    % errors
    error('Cannot read the external alarm temperature if the external heater is not enabled.')

% 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>) twice to get to the
% correct screen
tharbprobjcomm('write', serialObject, [20, uint8(profile), 13, 13, 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
extAlarmTemp = 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)
extAlarmTemp = str2double(extAlarmTemp(isstrprop(extAlarmTemp, 'digit')));

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

% if the number has come out as a NaN, possibly in a wrong menu, so errors
if isnan(extAlarmTemp)
    % errors
    error('Could not retrieve external heater alarm temperature - value not accessible from menu for an unknown reason.')

Contact us