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 extSetTemp = tharbprobjreadextsettemp(serialObject, profile)
% THARBPROBJREADEXTSETTEMP reads the set external temperature of Thar BPRs
% extSetTemp = tharbprobjreadextsettemp(serialObject, profile) reads the
% set external temperature of Thar BPRs. serialObject is the BPR serial
% object (generated by tharbprobj). The temperature is returned as a double
% precision scalar number in C, and the profile is 'A', 'B', or omitted,
% in which case the current profile is used.  Note that if the external
% heater is not enabled, the set external temperature of a profile not in
% use is not accessible.

% CAUTION - if the profile is supplied, then this feature does not seem to
% be working correctly - menu does not appear to be updating correctly

% e.g. extSetTemp = tharbprobjreadextsettemp(serialObject) - returns the
% set external temperature of the BPR e.g. 50 C.

% 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, and make sure that the heater is enabled to allow
% the reading of this
if nargin < 2
    % navigates to second display menu and fetches contents of screen
    response = tharbprobjdisplaymenu2(serialObject);

    % the set pressure is the first number on the 3rd line of the screen (if on
    % the second F3 screen)
    extSetTemp = str2double(response{3}(5:7));

    % presses F3 again to go back to the first display menu
    tharbprobjcomm('write', serialObject, 19)
elseif ~istharbprobjprofile(profile)
    % errors
    error('Profile must be either A or B.')
elseif ~tharbprobjreadextheaterstatus(serialObject)
    % errors - note that the above function also guarauntees that we are in
    % the correct menu
    error('Cannot read the external alarm temperature if the external heater is not enabled.')
    % presses F4, the profile name, then enter (<CR>) twice to get to the
    % correct screen
    tharbprobjcomm('write', serialObject, [20, uint8(profile), 13, 13])

    % reads the screen out (using 'readnoflush' since the screen does not
    % get continually updated here
    response = tharbprobjcomm('readnoflush', serialObject);
    % gets the external set temperature out and converts into a number
    extSetTemp = str2double(response{3}(isstrprop(response{3}, '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(extSetTemp)
        % errors
        error('Could not retrieve external heater set temperature - value not accessible from menu for an unknown reason.')

Contact us