Code covered by the BSD License  

Highlights from
Jasco BPR RS232 communication

Jasco BPR RS232 communication

by

 

20 May 2013 (Updated )

Drivers and higher level commands for controlling Jasco BPRs via RS232.

bprobjwritevalvestatus(serialObject, status)
function bprobjwritevalvestatus(serialObject, status)
% BPROBJWRITEVALVESTATUS sets the valve status of Jasco BPRs
% bprobjwritevalvestatus(serialObject, status) sets the valve status of
% Jasco back-pressure regulators, where serialObject is a valid serial port
% object (generated by bprobj) and status is 0 (valve open), 1 (valve
% closed), or 2 (valve regulated automatically).

% e.g. bprobjwritevalvestatus(bprobj(5), 2) - sets automatic valve control
% on the BPR on COM5.

% Range:

% serialObject = valid serial port object

% status = 0, 1, 2 or 3


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

% error handling
if ~isnumeric(status) || ~isscalar(status) || ~ismember(status, 0:3)
    % errors
    error('Valve status must be 0 (open), 1 (closed), 2 (regulated), or 3 (manual).')
end

% decides what to do depending on the command (no try-catch because each of
% the commands below has its own error handling)
switch status
    
    case 0
        % opens the valve
        bprobjopenvalve(serialObject)
        
    case 1
        % closes the valve
        bprobjclosevalve(serialObject)
        
    case 2
        % changes it to auto mode
        bprobjstart(serialObject)
        
    case 3
        % changes it to manuak
        bprobjmanualvalve(serialObject)
end

Contact us