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.

tharbprobjreadki(tharBPRObj, profile)
function ki = tharbprobjreadki(tharBPRObj, profile)
% BPROBJREADKI reads Ki of a profile in Thar BPRs
% ki = tharbprobjki(tharBPRObj, profile) reads the Ki (PID constant) of a
% particular profile of Thar BPRs. tharBPRObj is the BPR serial object
% (generated by tharbproj).  The profile is either 'A' or 'B', or omitted,
% in which case the name of the current profile is used.  Ki is a number.

% e.g. ki = tharbprobjreadki(tharbprobj(5), 'A') - returns the ki for
% profile A of the Thar BPR on COM5, e.g. 600.

% Range:

% tharBPRObj = 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, and turns it into lower case for data input
    profile = tharbprobjreadcurrentprofile(tharBPRObj);
elseif ~istharbprobjprofile(profile)
    % errors
    error('Profile must be either A or B.')
% navigates to display menu

% presses F5 to get to the profile setup screen, then selects a profile
tharbprobjcomm('write', tharBPRObj, [21, uint8(profile), 13, 13])

% reads out the screen
response = tharbprobjcomm('readnoflush', tharBPRObj);

% pull out the numbers and converts them
ki = str2double(response{3}(isstrprop(response{3}, 'digit')));

% navigate back
tharbprobjcomm('write', tharBPRObj, 27)

Contact us