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.

usbtc08query(tc08Handle, tc08Buffer, tc08OverflowBuffer)
function response = usbtc08query(tc08Handle, tc08Buffer, tc08OverflowBuffer)
% USBTC08QUERY gets information from Pico Technology TC-08 data loggers
% response = usbtc08query(tc08Handle, tc08Buffer, tc08OverflowBuffer,
% tc08Slope, tc08Offset) returns the values (as a numeric column vector)
% from the number of channels specified by usbtc08connect, including the
% cold junction as item #1, as well as calibrating for the values in a
% linear fashion with tc08Slope and tc08Offset.  usbtc08connect must be run
% first to configure the USB TC-08 and to obtain tc08Handle, tc08Buffer and
% tc08OverflowBuffer.

% e.g. response = usbtc08query(tc08Connect, tc08Buffer, tc08OverflowBuffer)
% returns all the temperature(s) and/or voltage(s) from all the channels
% from the USB TC-08 attached first (excluding the cold junction).


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

% error handling
if ~libisloaded(tc08LibraryName)
    % errors
    error('dll is not loaded - run usbtc08connect first to configure TC-08')
    
elseif ~isnumeric(tc08Handle) || ~isscalar(tc08Handle) || tc08Handle ~= uint8(tc08Handle) || tc08Handle == 0
    % errors
    error('tc08Handle must be an unsigned integer from 1-255 generated by usbtc08connect')
    
elseif isempty(tc08Buffer) || ~isscalar(tc08Buffer)
    % errors
    error('tc08Buffer must be a library pointer generated by usbtc08connect')
    
elseif isempty(tc08OverflowBuffer) || ~isscalar(tc08OverflowBuffer)
    % errors
    error('tc08Overflowbuffer must be a library pointer generated by usbtc08connect')
end

% fetches data into DLL - the final 0 is for filtering
calllib('usbtc08', 'usb_tc08_get_temp', tc08Handle, tc08Buffer, tc08OverflowBuffer, int16(0))

% fetches data into MATLAB (EXCLUDING cold junction temperature)
response = get(tc08Buffer, 'Value');

% if response is not empty, eliminate the first item (the cold junction
% termperature
if ~isempty(response)
    % removes the first item
    response(1) = [];
end

Contact us