Code covered by the BSD License  

Highlights from
Rheodyne valve RS232 communications

Rheodyne valve RS232 communications

by

 

Commands for communicating with Rheodyne valves via RS232

rheodyne232objconnect(serialObject)
function rheodyne232objconnect(serialObject)
% RHEODYNE232OBJCONNECT initialises communication with Rheodyne valves
% rheodyne232objconnect(serialObject) initialises communication with Rheodyne valves, given
% serialObject as a valid Rheodyne serial object (generated by rheodyne232obj).

% e.g. rheodyne232objconnect(serialObject) - initialises communication
% with the valve.

% Range:

% serialObject = valid serial port object


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

% error handling
if ~isa(serialObject, 'serial') || ~isvalid(serialObject) || ~strcmp(serialObject.Status, 'closed')
    % errors
    error('serialObject must be a valid closed serial object.')
end

% opens communication
fopen(serialObject)

% Vista needs a brief pause to behave itself correctly - I've left this in
% for XP too, but in case you wanted to shave off that whole 400 ms, you
% could try...BUT old MATLAB versions detect Vista as "Microsoft Windows
% 2000" - whether this is required or not for realterm has not been tested
%if isempty(strfind(system_dependent('getos'), 'XP'))
pause(0.4)
%end

% stores the valve position in user data
serialObject.UserData.currentValvePosition = rheodyne232objreadvalveposition(serialObject);

% also sets the fast mode to on by default, if not already added
if ~isfield(serialObject.UserData, 'fastMode')
    % save it
    serialObject.UserData.fastMode = true;
end

Contact us