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.

gilsonpumpobjwritepumpsetup(gilsonPumpObj, refillTime, compressibility, pumpHeadSize, inletPress)
function gilsonpumpobjwritepumpsetup(gilsonPumpObj, refillTime, compressibility, pumpHeadSize, inletPress)
% GILSONPUMPOBJWRITEPUMPSETUP writes pump setup to Gilson 30x's
% gilsonpumpobjwritepumpsetup(gilsonPumpObj, refillTime, compressibility,
% pumpHeadSize, inletPress) = writes the refill time, compressibility,
% pumpHeadSize and inletPress to Gilson 30x pumps, where gilsonPumpObj is a
% valid serial object generated by gilsonPumpObj. refill time is in ms,
% compressibility is an integer from 0 to 2000 (Mbar^-1) (only used if a
% manometric module is installed), the pumpHeadSize is in "mL", and the
% inlet pressure is in bar.  If any of values are set to [], then they are
% ignored.

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

% deviceID
deviceID = 1;

% checks if anything is filled, otherwise do nothing
if isempty(refillTime) && isempty(compressibility) && isempty(pumpHeadSize) && isempty(inletPress)
    % error
    error('Must specify at least one parameter to change.')
end

% gets the maximum possible pressure (ignores the rest of the arguments)
[maxPossiblePress, manometricModule] = gilsonpumpobjreadmaxpossiblepress(gilsonPumpObj);

% error handling (none of those are checked if they are empty parameters)
if ~isempty(refillTime) && (~isscalar(refillTime) || ~isnumberbetween(refillTime, 125, 1000))
    % errors
    error('Refill time must be an integer from 125 to 1000 (ms)')
    
elseif strcmp(manometricModule, 'None') && (~isscalar(compressibility) || ~isnumberbetween(compressibility, 0, 2000))
    % errors (only checks this one if the manometric module is installed -
    % otherwise - we don't need to worry about it
    error('Compressibility must be an integer from 0 to 2000 (Mbar^-1).')
    
elseif ~isempty(pumpHeadSize) && (~isnumeric(pumpHeadSize) || ~isscalar(pumpHeadSize) || all(~ismember([5, 10, 25, 50, 100, 200], pumpHeadSize)))
    % errors
    error('Pump head size invalid.')
    
elseif ~isempty(inletPress) && (~isscalar(inletPress) || ~isnumberbetween(inletPress, 0, maxPossiblePressure))
    % errors
    error('Inlet pressure must be an integer between 0 and %d.', maxPossiblePress)
end

% navigate into the main menu
gilsonpumpobjmainmenu(gilsonPumpObj)

% forms the refill time keystrokes
if ~isempty(refillTime)
    % rounds the refill time and warns if it did so
    refillTime = roundto(refillTime, 0, true);

    % keystrokes
    refillTimeKeyStrokes = [num2str(refillTime), 'E'];
else
    % empty
    refillTimeKeyStrokes = '';
end

% forms the compressibility keystrokes
if ~strcmp(manometricModule, 'None') && ~isempty(compressibility)
    % rounds the compressibility and warns if it does
    compressibility = roundto(compressibility, 0, true);
    
    % keystrokes
    compressibilityKeyStrokes = [num2str(compressibility), 'Ea'];
else
    % do nothing
    compressibilityKeyStrokes = '';
end

% forms the pumpHeadSize keystrokes
if ~isempty(pumpHeadSize)
    % keystrokes
    pumpHeadSizeKeyStrokes = [num2str(pumpHeadSize), 'E'];
else
    % empty
    pumpHeadSizeKeyStrokes = '';
end

% forms the inletPress keystrokes
if ~isempty(inletPress)
    % rounds the inlet pressure
    inletPress = roundto(inletPress, 0);
    
    % keystrokes
    inletPressKeyStrokes = [num2str(inletPress), 'E'];
else
    % empty
    inletPressKeyStrokes = '';
end

% navigates to refill time menu, then enters the new time in, goes tthen
% navigates back to the pump menu
gilsonpumpobjcomm('write', gilsonPumpObj, deviceID, ['Kaa', refillTimeKeyStrokes, compressibilityKeyStrokes, pumpHeadSizeKeyStrokes, inletPressKeyStrokes,'e']);

% reconnects the keypad
gilsonpumpobjcomm('write', gilsonPumpObj, deviceID, 'K');

Contact us