EasyManua.ls Logo

PICO USB TC-08 - Page 13

PICO USB TC-08
43 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Technical reference
12
© 2005 Pico Technology Limited. All rights reserved.
USBTC08044-2
Note: The function call overhead can be significant, since it takes approximately 360 ms
to convert all 9 channels, equating to 40 ms per channel. To reduce this overhead,
disable channels that are not required.
Example
The following code is a fragment of a C application demonstrating how to use Get Single
mode with the USB TC-08 driver:
//========================================================
// Setting up and converting readings with Get Single mode
//========================================================
usb_tc08_set_mains
(handle,
0
);
// use 50Hz mains noise rejection
for
(channel =
0
; channel <
9
; channel++)
{
// set each channel up as a type K thermocouple
// channel 0 is the cold junction and will be enabled
// by setting the third argument to anything other than ' '
usb_tc08_set_channel
(handle, channel,
'K'
);
}
// find out the approximate conversion time
// for a call to usb_tc08_get_single
minimum_interval =
usb_tc08_get_minimum_interval_ms
(handle);
printf(
"Conversion time: %d\n"
, minimum_interval);
// Collect 10 readings over approximately 9 minutes
last_time = GetTickCount();
for
(i =
0
, i <
10
, i++)
{
// do the conversion for all channels
usb_tc08_get_single
( handle,
value_array,
// short value_array[9]
&overflow_flags,
0
);
// degrees Celsius units
// print out the values
printf(
"\n\nTime: %d minute(s)"
, i);
for
(c =
0
; c <
9
; c++)
{
// check for overflows on each channel
// with a bitwise & comparator
// shift the comparison bit to match the channel
if
(overflow_flags & (
1
<< c))
{
printf(
"\nChannel %d overflowed"
, c);
}
else
// no overflow
{
printf(
"\nChannel %d: %f"
, c, value_array[c]);
}
}
if
(i <
9
)
{
while
(
60000
>
(GetTickCount() - last_time))
// 60000ms = 1 minute
{
Sleep(
100
);
// let other applications run
}
last_time = GetTickCount();
}
}