Code covered by the BSD License  

Highlights from
CO2gui - lab control and automation

CO2gui - lab control and automation



06 Jan 2010 (Updated )

Software used for controlling and data logging lab equipment.

rheodyneobjwriteperiod(rheodyneTimer, period)
function rheodyneobjwriteperiod(rheodyneTimer, period)
% RHEODYNEOBJWRITEPERIOD write the period to the rheodyne timer object
% rheodyneobjwriteperiod(rheodyneTimer, period) changes the timer period of
% the Rheodyne timer.  rheodyneTimer is the timer object (generated by
% rheodyneobj). The period is required as a scalar in seconds.

% e.g. rheodyneobjwriteperiod(rheodyneobj, period) - changes the period of
% the rheodyne timer, e.g. to 5 (s).

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

% error handling
if ~istimer(rheodyneTimer)
    % errors
    error('rheodyneTimer must be a valid timer object.')
elseif ~strcmp(rheodyneTimer.Tag, 'rheodyne')
    % errors
    error('Incorrect timer - the timer must be generated from rheodyneobj.')    
elseif ~isscalar(period) || ~isnumberbetween(period, 2.5, 8192)
    % errors
    error('Timer period must be a real number no smaller than 2.5 seconds.')

% gets the user data
userData = rheodyneTimer.UserData;

% more error handling
if ~isfield(userData, 'audioPlayerObject')
    % error
    error('audioPlayerObject is missing from the timer UserData.')
elseif ~isa(userData.audioPlayerObject, 'audioplayer')
    % error
    error('audioPlayerObject in timer UserData is not an audioplayer object.')

% if the number is not a round number into 8192, then there will be
% rounding (warning currently suppressed)
if 8192 / period ~= round(8192 / period)
    % display a warning
    %warning('rheodyneObj;periodRounding', 'New period has been rounded off.')

% changes the audioplayer object
set(userData.audioPlayerObject, 'SampleRate', round((8192 / period) * (10 / 2)))

Contact us