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.

knauerpumpobjwritecorrectionparameter(serialObject, correctionParameter, pumpHeadSize)
function knauerpumpobjwritecorrectionparameter(serialObject, correctionParameter, pumpHeadSize)
% KNAUERPUMPOBJWRITECORRECTIONPARAMETER sets maximum current of Knauer pumps
% knauerpumpobjwritecorrectionparameter(serialObject, correctionParameter,
% 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 300 units.  The function automatically rounds the
% minimum current to the nearest integer.  If no pump head size is
% supplied, it will try and retrieve it, but if one is supplied, then will
% retrieve the maximum pressure set for that pump head size.

% e.g. knauerpumpobjwritecorrectionparameter(serialObject, 200) - sets
% correction parameter of the pump to 200.

% Range:

% serialObject = valid serial object

% correctionParameter = unsigned number: 0-300


% 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(correctionParameter) || ~isreal(correctionParameter) || isnan(correctionParameter) || correctionParameter < 0 || correctionParameter > 300
    
    % errors
    error('Correction parameter must be a number from 0 to 300.')
end

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

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

Contact us