High-level thermocouple data acquisition – Measurement Computing TempBook rev.3.0 User Manual
Page 38

6-6 Standard API Programming of the TempBook with C
TempBook User’s Manual
High-Level Thermocouple Data Acquisition
The following excerpt from TBKEX.C demonstrates the use of the TempBook's high-level thermocouple
temperature data acquisition routines. These functions have combined scan sequencer setup, ADC data
collection, and thermocouple linearization.
int i, temp, temps[10];
unsigned buf[1200];
Set the default operating mode to differential, bipolar. These parameters will affect all scanned channels.
tbkSetMode(1, 1);
Get one temperature sample from a type J thermocouple on channel 0, then print the result.
tbkRdTemp(0, TbkTypeJ, &temp);
sprintf(tempstr, "\r\nResults of tbkRdTemp\r\n");
strcat(response, tempstr);
sprintf(tempstr, "Temperature: %4,1f \r\n", (float)temp/10.0);
strcat(response, tempstr);
Get one temperature value from a type J thermocouple on channel 0 which is the average of 10 acquired
values, then print the result. This has the effect of reducing the noise content of your signal. The 10
readings will be taken at 1kHz, with only one temperature value returned by the function.
tbkRdTempN(0, TbkTypeJ, 10, &temp, buf, 1000, 0);
sprintf(tempstr, "\r\nResults of tbkRdTempN\r\n");
strcat(response, tempstr);
sprintf(tempstr, "Temperature: %4.1f \r\n", (float)temp/10.0);
strcat(response, tempstr);
Get one temperature value from a type J thermocouple on channels 0 through 7, then print the result.
tbkRdTempScan(0, 7, TbkTypeJ, temps);
sprintf(tempstr, "\r\nResults of tbkRdTempScan\r\n");
strcat(response, tempstr);
for (i=0 ; i<8 ; i++){
sprintf(tempstr, "Channel %d Temperature: %4.1f \r\n", i,
(float)temps[i]/10.0);
strcat(response, tempstr);
Get 8 temperature values from type J thermocouple on channels 0 through 7 which are the average of 10
acquired values, then print the result. This has the effect of reducing the noise content of your signal. The
10 readings will be taken at 1kHz, with only one temperature value for each channel returned by the
function.
tbkRdTempScanN(0, 7, TbkTypeJ, 10, temps, buf, 1000, 0);
sprintf(tempstr, "\r\nResults of tbkRdTempScanN\r\n");
strcat(response, tempstr);
for (i=0 ; i<8 ; i++){
sprintf(tempstr, "Channel %d Temperature: %4.1f \r\n", i,
(float)temps[i]/10.0);
strcat(response, tempstr);
}