Code covered by the BSD License  

Highlights from
CO2gui - lab control and automation

CO2gui - lab control and automation



06 Jan 2010 (Updated )

Software used for controlling and data logging lab equipment.

gilsonpumpobjwriteflow(gilsonPumpObj, setFlow)
function gilsonpumpobjwriteflow(gilsonPumpObj, setFlow)
% GILSONPUMPOBJWRITEFLOW sets flow rate of Gilson pumps
% gilsonpumpobjwriteflow(gilsonPumpObj, setFlow) changes the set flow rate
% of Gilson pumps given a valid serial object and a flow rate from 0.0000
% to 5.000. The pump ignores any more than 3 decimal places, and at less
% than 1 mLmin-1, the fourth decimal place can be 0 or 5 only.  This is
% currently explicitly configured for the 5SC pump heads, limited to a
% maximum flow rate of 5 mLmin-1.  Improvements to this function would
% involve fetching the pump head size to see what the maximum flow rate
% could be.

% e.g. gilsonpumpobjwriteflow(gilsonPumpObj(6), 0.2) - sets the flow rate
% of the Gilson pump on COM6 to 0.2 mLmin-1

% Range:

% gilsonPumpObj = valid serial port object

% setFlow = unsigned number: 0-5

% first stage error handling
if nargin < 2
    % errors
    error('Insufficient arguments')

% pre-defines the deviceID for future ease of changing
deviceID = 1;

% fetches the pump head size from the menu - hopefully there is a better
% way of doing this

% the "official" way (if it worked) where flowRate is the flow in
% hundredth's of percent of the pump head size
%gilsonpumpobjcomm('write', gilsonPumpObj, deviceID, ['s', num2str(flowRate)])

% checks the user data for the pump head size
if isfield(gilsonPumpObj.UserData, 'pumpHeadSize')
    % gets it
    pumpHeadSize = gilsonPumpObj.UserData.pumpHeadSize;
    % gets the pump head size
    pumpHeadSize = gilsonpumpobjreadpumpheadsize(gilsonPumpObj);

% second stage error handling
if ~isnumeric(setFlow) || ~isscalar(setFlow) || isnan(setFlow) || ~isreal(setFlow) || setFlow < 0 || setFlow > pumpHeadSize
    % errors
    error('Flow rate must be a number between 0 and %d mLmin-1', pumpHeadSize)

% checks the flow rate
if setFlow * 10000 ~= round(setFlow * 10000)
    % display a warning (don't actually need to round it off since the
    % sprintf deals with that)
    warning('Gilson30xWriteFlow:ValueTooPrecise', 'Supplied flow rate was not to the nearest 0.0001 mLmin-1 (in practice to the nearest 0.0005 mLmin-1) so has been rounded off.')

% sends command based on normal keystrokes (there must be a better way than
% this
gilsonpumpobjcomm('write', gilsonPumpObj, deviceID, sprintf('K%2.4fE', setFlow));

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

Contact us