Code covered by the BSD License  

Highlights from
CO2gui - lab control and automation

CO2gui - lab control and automation

by

 

06 Jan 2010 (Updated )

Software used for controlling and data logging lab equipment.

rheodyne232objwriteslaveaddress(serialObject, slaveAddress)
function rheodyne232objwriteslaveaddress(serialObject, slaveAddress)
% RHEODYNE232OBJWRITESLAVEADDRESS changes the I2C slave address (reset)
% rheodyne232objwriteslaveaddress(serialObject, slaveAddress) changes the
% I2C slave address of the valve where the address is an even number from
% 14-254.  It is not known how this affects the device in practice.

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

% checks the baud rate supplied
if ~isnumeric(slaveAddress) || ~isscalar(slaveAddress) || ~isreal(slaveAddress) || slaveAddress < 14 || slaveAddress > 254 || slaveAddress / 2 ~= round(slaveAddress / 2)
    % errors
    error('Invalid I2C slave address - it must be an unsigned EVEN integer from 14 to 254.')
end

% converts the slave address
slaveAddress = dec2hex(slaveAddress);

% appends a zero on the front if not long enough
if numel(slaveAddress) == 1
    % add it on
    slaveAddress = ['0', slaveAddress];
end

% sends the command
rheodyne232objcomm(serialObject, ['N', dec2hex(slaveAddress)]);

Contact us