Code covered by the BSD License  

Highlights from
Eurotherm Modbus RS232 Control

Eurotherm Modbus RS232 Control



11 Jul 2009 (Updated )

Reads and writes information to Eurotherm controllers via Modbus RTU protocols.

function tempobjconnect(serialObject)
% TEMPOBJCONNECT initialises communication with Eurotherm controllers
% tempobjconnect(serialObject, deviceAddress) initialises communication
% with Eurotherm series 2000 and 3000 temperature controllers, given
% serialObject as a valid temperature controller serial object (generated
% by tempobj).  Note that the UserData MUST be a structure, but the only
% reserved fields are "deviceAddress" and "maxWords" so that any other data
% can be stored there.

% e.g. tempobjconnect(tempobj(7)) - initialises communication with the
% temperature controller attached to COM7.

% Range:

% serialObject = valid serial port object (preferably generated by tempobj)

% error handling
if nargin < 1
    % must supply a serial object
    error('Insufficient arguments')
elseif ~isvalidtempobj(serialObject)
    % the serial object must be valid
    error('serialObject must be a valid serial object.')

% opens communication (MLint on 2012b will complain this will display an
% output - this is not true for serial objects)

% tries to gets the Eurotherm type and store it in user data (no identifier
% on catch for compatibility with earlier versions of MATLAB)
    % gets the user data from the serial object
    userData = serialObject.UserData;

    % sends command
    userData.maxWords = dec2hex(tempobjcomm('read', serialObject, userData.deviceAddress, 122, 1));
    % only want the second hex digit
    switch userData.maxWords(1:2);
        case {'22', '32'}
            % sets the maximum number of words that can be sent/received
            userData.maxWords = 32;
        case '24'
            % much more words can be received by the 2400 series
            % controllers
            userData.maxWords = 125;
    % saves the user data back
    serialObject.UserData = userData;
    % displays a warning (the tempobjcomm protocols will see the absence of
    % the field and cope with it accordingly)
    warning('tempObjConnect:UnknownEurotherm', 'Could not retrieve Eurotherm controller type - read and write commands will be limited to the minimum allowed for series 2000 controllers for this serialObject.')

Contact us