Code covered by the BSD License  

Highlights from
Knauer pump RS232 communication

Knauer pump RS232 communication



Functions for communicating with Knauer pumps via RS232.

knauerpumpobjwritemincurrent(serialObject, minCurrent, pumpHeadSize)
function knauerpumpobjwritemincurrent(serialObject, minCurrent, pumpHeadSize)
% KNAUERPUMPOBJWRITEMINCURRENT sets minimum current of Knauer pumps
% knauerpumpobjwritemincurrent(serialObject, minCurrent, pumpHeadSize)
% changes the minimum 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. knauerpumpobjwritemincurrent(serialObject, 50) - sets minimum
% 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].')

    % fetch it
    pumpHeadSize = knauerpumpobjreadpumpheadsizefast(serialObject);

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

% checks the minimum current
if minCurrent ~= round(minCurrent)
    % 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.')

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

Contact us