Code covered by the BSD License  

Highlights from
Pico Technology TC-08 USB data acquisition

Pico Technology TC-08 USB data acquisition

by

 

20 May 2013 (Updated )

Files to connect, query, and disconnect from the Pico Technology USB TC-08, using DLL's.

usbtc08connect(types, tc08Path, interval)
function [handle, varargout] = usbtc08connect(types, tc08Path, interval)
% USBTC08CONNECT configures the USB Pico Technology TC-08 data logger
% handle = usbtc08connect(types, tc08Path) configures the USB Pico
% Technology TC-08 data logger where types is a string or a vector array of
% strings of the respective channel types e.g. 'K' for type K
% thermocouples, and 'X' for measuring the voltage. If the tc08Path is
% supplied, it must point to the folder containing the DLLs, otherwise it
% assumes a default path of 'C:\Program Files (x86)\Pico Technology\Pico
% Full'.  Empty paths are also acceptable, in which case the default path
% is used.  handle is the handle of the TC-08 for using usbtc08query, or is
% 0 if any of the steps were unsuccessful.  Additional output arguments are
% tolerated for legacy resons.  This uses the streaming mode of the unit,
% which means queries are much faster - ca. 1 ms per call.  interval is the
% time between samples and is set to the fastest possible value, obtained
% by requesting it from the unit - this is usually about 100 ms per channel
% - but can be specified if necessary.

% e.g. usbtc08connect('KKX') sets up a USB TC-08 with 2 type K
% thermocouples and 1 voltage measurement, numbered as channels 2, 3 and 4
% (the cold junction is #1).  Returns the handle.

% Range

% types = string or vector array of strings: 'B', 'E', 'J', 'K', 'N', 'R',
% 'S', 'T' for different thermocouples, or 'X' for measuring voltages


% number of arguments error check
error(nargchk(1, 3, nargin))

% LEGACY - to do with CO2gui - can be deprecated eventually
if nargout >= 2
    % output a dummy response
    varargout{1} = [];
end
    
if nargout == 3
    % a dummy for the overflowPointer
    varargout{2} = [];
end

% check the rest of the arguments - usbtc08connectslow will check the first
% two


% the interval time data type depends on what platform we're on, so don't
% check it too closely
if nargin >= 3 && (~isscalar(interval) || ~isnumeric(interval) || interval < 300 || isinf(interval))
    
    % complain
    error('Interval time must be >= 300 ms or not infinite.')
    
end


% the beginning part is just the same as the connectslow routine
if nargin == 1
    
    % use that
    handle = usbtc08connectslow(types);
    
elseif nargin >= 2
    
    % add the path in
    handle = usbtc08connectslow(types, tc08Path);
end

% get the minimum interval time
minIntervalTime = usbtc08mininterval(handle);

% if an interval time wasn't specified, use that
if nargin <= 2
    
    % apply
    interval = minIntervalTime;
    
% check its valid
else
    
    if interval < minIntervalTime
        
        % error
        error('Interval time set too short - streaming not started by unit is still connected.')
        
    end
end

% decide what to do with the intervalTime depending on the platform...
if ispc

    % set it to int32
    interval = int32(interval);
    
else
    
    % its Linux (not sure about mac), so set it to int64
    interval = int64(interval);
end

% sends the instruction
actualInterval = calllib('usbtc08', 'usb_tc08_run', handle, interval);

% if it started, then it returns the actual interval it was set to, or a 0
% if it didn't
if actualInterval
    % then it worked - but it may not have been the correct interval
    if actualInterval ~= interval
        % then display a warning
        warning('Actual interval on device (%d) is different to the requested interval (%d).', actualInterval, interval)
    end
    
else
    % complain
    error('USB TC-08 did not start collecting temperatures.')
end

Contact us