Code covered by the BSD License  

Highlights from
Knauer pump RS232 communication

Knauer pump RS232 communication

by

 

Functions for communicating with Knauer pumps via RS232.

knauerpumpobjwritemaxcurrent(serialObject, maxCurrent, pumpHeadSize)
function knauerpumpobjwritemaxcurrent(serialObject, maxCurrent, pumpHeadSize)
% KNAUERPUMPOBJWRITEMAXCURRENT sets maximum current of Knauer pumps
% knauerpumpobjwritemaxcurrent(serialObject, maxCurrent, pumpHeadSize)
% changes the maximum current of Knauer pumps (where the pump will stop
% pumping automatically) given a valid serial object and a current from 0
% to 100 units.  The function automatically rounds the minimum current to
% the nearest integer.

% e.g. knauerpumpobjwritemaxcurrent(serialObject, 50) - sets maximum
% current of the pump to 50.

% Range:

% serialObject = valid serial object

% minCurrent = unsigned number: 0-100


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

% if a pump head size was supplied...
if nargin >= 3
    
    % check the input
    if ~isvalidknauerpumpheadsize(pumpHeadSize)
        
        % complain
        error('Must supply a valid pump head size - 10 or 50 [mL].')
    end

else
    
    % fetch it
    pumpHeadSize = knauerpumpobjreadpumpheadsizefast(serialObject);
end

% error handling
if ~isscalar(maxCurrent) || ~isreal(maxCurrent) || isnan(maxCurrent) || maxCurrent < 0 || maxCurrent > 100
    
    % errors
    error('Maximum current must be a number from 0 to 100.')
end

% checks the minimum current
if maxCurrent ~= round(maxCurrent)
    
    % display a warning (don't actually need to round it off as the sprintf
    % will deal with that)
    warning('KnauerPumpWriteMinCurrent:ValueTooPrecise', 'Supplied minimum current was not an integer so has been rounded off.')
end

% forms and writes command
knauerpumpobjcomm(serialObject, 'write', sprintf('IMAX%d:%.0f', pumpHeadSize, maxCurrent))

Contact us