High-level thermocouple measurement – Measurement Computing TempBook rev.3.0 User Manual
Page 46

6-14 Standard API Programming of the TempBook with C
TempBook User’s Manual
High-Level Thermocouple Measurement
***********************************************
File:
Description:
This example 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.
Functions Used:
tbkRdTemp(unsigned chan, unsigned tcType, int * temp)
tbkRdTempN( unsigned chan, unsigned tcType, unsigned count, int *
temp,
unsigned * buf, float freq, unsigned avg ) tbkRdTempScan(unsigned startChan,
unsigned endChan,unsigned tcType, int * temp) tbkRdTempScanN(unsigned
startChan,
unsigned endChan, unsigned tcType, unsigned count, int * temp, unsigned *
buf,
float freq, unsigned avg)
****************************************************/
int i, temp, temps[10];
unsigned buf[1200];
sprintf(response,"\r\nTempex1.c\r\n");
/* Set the default mode of operation to differential bipolar */
tbkSetMode(1, 1);
/* Get 1 ADC sample from a type J thermocouple on channel 0 and
convert the reading to a temperature. 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 10 ADC samples from a type J thermocouple on channel 0 and
convert the readings to a single temperature using block averaging.
Print the results. */
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 1 ADC sample each from type J thermocouples on channels 0
through
7 and convert the readings to temperatures. Print the results */
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);
}