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.

fibreobjwritedelaytime(serialObject, delayTime)
function fibreobjwritedelaytime(serialObject, delayTime)
% FIBREOBJWRITEDELAYTIME writes the time between broadcasts from the FOR
% fibreobjwritedelaytime(serialObject, delayTime) writes the time between each
% broadcast by the FOR.  It must be any integer from 20 to 500 ms
% (although the actually hardware limits for these numbers are unknown).


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

% checks the averages
if ~isnumeric(delayTime) || ~isscalar(delayTime) || ~isreal(delayTime) || isnan(delayTime) || delayTime < 20 || delayTime > 500 || delayTime ~= round(delayTime)
    % errors
    error('The time between transmission must be a scalar integer from 20 to 500 ms.')
end

% checks its not broadcasting
if fibreobjstatus(serialObject)
    % error
    error('FOR must not be broadcasting to write the delay time.')
end

% sends it, along with the calculated checksum
try
    % sends the command (note that the delay time is actually double what
    % gets written to the device
    fibreobjcomm('write', serialObject, 10, 2, delayTime / 2)
    
    % if it got this far, store it
    serialObject.UserData.delayTime = delayTime;
    
catch
    % errors
    error('Could not change the delay time.')
end

Contact us