EasyManua.ls Logo

PICO USB TC-08 - Page 15

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
14
© 2005 Pico Technology Limited. All rights reserved.
USBTC08044-2
Example
The following code is a fragment of a C application demonstrating how to use legacy
mode with the USB TC-08 driver:
//==========================================================
// Setting up and running the unit in Legacy mode
// This is designed to make it easier to adapt code written
// for the Serial TC08 for use with the USB TC08
//==========================================================
usb_tc08_set_mains
(handle,
0
);
// use 50Hz mains noise rejection
for
(channel =
1
; channel <
9
; channel++)
{
// set each channel up as a type K thermocouple
// switch off filtering for all channels
usb_tc08_legacy_set_channel
(handle, channel,
'K'
,
0
);
}
usb_tc08_legacy_run
(handle);
last_cycle_no =
0
;
no_of_readings =
0
;
while
(no_of_readings <
50
)
// collect 50 readings
{
usb_tc08_legacy_get_cycle
(handle, &this_cycle_no);
if
(last_cycle_no != this_cycle_no)
{
last_cycle_no = this_cycle_no;
no_of_readings++;
for
(channel =
1
; channel <
9
; channel++)
{
usb_tc08_legacy_get_temp
( &reading[channel],
handle,
channel,
0
);
}
// now do something with the readings
// check that they have not overflowed
// by comparing each reading with 2147483647L
// or LONG_MAX (include limits.h)
usb_tc08_legacy_get_cold_junction
(handle, &cold_junction);
// now do something with the cold junction temperature
}
}
usb_tc08_stop
(handle);