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.

function currentFlow = gilsonpumpobjreadflow(gilsonPumpObj)
% GILSONPUMPOBJREADFLOW returns the current flow rate of Gilson 30x pumps
% gilsonpumpobjreadflow(gilsonPumpObj) returns the current flow rate of
% Gilson 30x pumps connected to a valid serial port object.  Defaults to a
% deviceID of 1.

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

% defines deviceID for future ease of changing
deviceID = 1;

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

        % if it didn't, assume its set to 5
        pumpHeadSize = 5;

        % display a warning
        warning('gilsonPumpConnect:pumpHeadSize', 'Did not determine the pump head size on connection (pump may be priming) so is set to 5 by default.')

    % saves it
    gilsonPumpObj.UserData.pumpHeadSize = pumpHeadSize;

% calculates the divisors - not clear how the round divisor will change
% with pump head size - this is an estimate
roundDivisor = (pumpHeadSize * 40) + 1;
mainDivisor = pumpHeadSize * 400;

% fetches the flow rate
currentFlow = str2double(gilsonpumpobjcomm('read', gilsonPumpObj, deviceID, 's'));

% calculates the flow rate
currentFlow = (currentFlow - round(currentFlow / roundDivisor)) / mainDivisor;

Contact us