Code covered by the BSD License  

Highlights from
Knauer pump RS232 communication

Knauer pump RS232 communication



Functions for communicating with Knauer pumps via RS232.

knauerpumpobjwriteadjustparameter(serialObject, adjustParameter, pumpHeadSize)
function knauerpumpobjwriteadjustparameter(serialObject, adjustParameter, pumpHeadSize)
% KNAUERPUMPOBJWRITEADJUSTPARAMETER sets maximum current of Knauer pumps
% knauerpumpobjwriteadjustparameter(serialObject, adjustParameter,
% pumpHeadSize) changes the maximum current of Knauer pumps (where the pump
% will stop pumping automatically) given a valid serial object and a
% current from 100 to 2000 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. knauerpumpobjwriteadjustparameter(serialObject, 500) - sets adjust
% parameter of the pump to 500.

% Range:

% serialObject = valid serial object

% minCurrent = unsigned number: 100-2000

% 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(adjustParameter) || ~isreal(adjustParameter) || isnan(adjustParameter) || adjustParameter < 100 || adjustParameter > 2000
    % errors
    error('Adjust parameter must be a number from 100 to 2000.')

% checks the minimum current
if adjustParameter ~= round(adjustParameter)
    % 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('ADJ%d:%.0f', pumpHeadSize, adjustParameter))

Contact us