Code covered by the BSD License  

Highlights from
CO2gui - lab control and automation

CO2gui - lab control and automation

by

 

06 Jan 2010 (Updated )

Software used for controlling and data logging lab equipment.

tharbprobjreadprofileconfig(tharBPRObj, profile)
function [profileName, kp, ki, kd, maxOut] = tharbprobjreadprofileconfig(tharBPRObj, profile)
% THARBPROBJREADPROFILECONFIG reads the config. of a profile in a Thar BPR
% [profileName, kp, ki, kd, maxOut] =
% tharbprobjreadprofileconfig(tharBPRObj, profile) reads the name , the Kp,
% Ki, Kd and maxOut (PID constants) 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.  Name is a string, and the rest are integers.

% e.g. [profileName, kp, ki, kd, maxOut] =
% tharbprobjreadprofileconfig(tharbprobj(5), 'A') - returns the
% configuration of profile A of the Thar BPR on COM5.

% 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.')
end
    
% navigates to display menu
tharbprobjdisplaymenu(tharBPRObj);

% presses F5 to get to the profile config screen
tharbprobjcomm('write', tharBPRObj, 21)

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

% the line is: 'A-Name' starting at row 2, also remove any trailing white
% space
profileName = deblank(response1{uint8(profile) - 63}(3:end));

% selects a profile, then skips past the profile name screen
tharbprobjcomm('write', tharBPRObj, [uint8(profile), 13])

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

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

% navigates to the next screen
tharbprobjcomm('write', tharBPRObj, 13)

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

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

% navigates to the next screen
tharbprobjcomm('write', tharBPRObj, 13)

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

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

% navigates to the next screen
tharbprobjcomm('write', tharBPRObj, 13)

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

% pull out the numbers and convert them
maxOut = str2double(response5{3}(isstrprop(response5{3}, 'digit')));

% navigate back to the display menu
tharbprobjcomm('write', tharBPRObj, 27)

Contact us