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.

bprobjopenvalve(serialObject)
function bprobjopenvalve(serialObject)
% BPROBJOPENVALVE fully opens the Jasco BPR valve
% bprobjopenvalve(serialObject) fully opens the Jasco BPR valve

% e.g. bprobjopenvalve(serialObject) fully opens the Jasco BPR valve

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

% gets the current valve status
valveStatus = bprobjreadvalvestatus(serialObject);

% try-catch for robustness
try
    % chooses action depending on the current status
    switch valveStatus
        case 0
            % its already open, we don't need to do anything

        case 1
            % its closed, so it'll error, must turn it to auto first...
            bprobjcomm(serialObject, '#0x24 2')

            % only now can we open it
            bprobjcomm(serialObject, '#0x24 0')

        case 2
            % its auto-regulated, only need to send it once
            bprobjcomm(serialObject, '#0x24 0')

        case 3
            % its manually regulated (and we don't know what the "normal"
            % setting is set to)

            % set it to auto to guarantee that taking it off manual works
            % properly
            bprobjcomm(serialObject, '#0x24 2')

            % turn manual off
            bprobjcomm(serialObject, '#23 0')

            % now open it
            bprobjcomm(serialObject, '#0x24 0')
    end

catch
    % get the new valve status
    newValveStatus = bprobjreadvalvestatus(serialObject);

    % it errored
    error('Unknown valve error - could not close the BPR valve.  Current valve status: %d', newValveStatus)
end

Contact us