Low-level thermocouple linearization – Measurement Computing TempBook rev.3.0 User Manual
Page 47

TempBook User’s Manual
Standard API Programming of the TempBook with C 6-15
/* Get 10 ADC samples each from type J thermocouples on channels 0
through 7 and convert the readings to temperatures using block
averaging. Print the results */
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);
}
SendDlgItemMessage(myDlg, 101, WM_SETTEXT, 0, (LONG)(LPSTR)response);
EmptyMessageQueue(myDlg);
}
Low-Level Thermocouple Linearization
***********************************************
File: Description:
This example demonstrates the use of the TempBook's thermocouple
linearization
routines.
Functions Used:
tbkTCSetup(unsigned nscan, unsigned cjcPosition, unsigned ntc,
unsigned tcType, unsigned char bipolar, unsigned avg)
tbkTCConvert(unsigned _far *counts, unsigned scans,
int _far *temp, unsigned ntemp)
*************************************************/
*/ unsigned i, chans[11], data[1100];
unsigned char gains[11]; int temp[8];
sprintf(response,"\r\nTempex2.c\r\n");
/* Configure chans array */
chans[0] = 18; /* Shorted channel*/
chans[1] = 18; /* Shorted channel*/
chans[2] = 16; /* CJC channel */
chans[3] = 0; /* Thermocouple on channel 0 */
chans[4] = 1; /* Thermocouple on channel 1 */
chans[5] = 2; /* Thermocouple on channel 2 */
chans[6] = 3; /* Thermocouple on channel 3 */
chans[7] = 4; /* Thermocouple on channel 4 */
chans[8] = 5; /* Thermocouple on channel 5 */
chans[9] = 6; /* Thermocouple on channel 6 */
chans[10] = 7; /* Thermocouple on channel 7 */
/* Configure gains array */
gains[0] = TbkBiCJC; /* Bipolar CJC gain setting */
gains[1] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */
gains[2] = TbkBiCJC; /* Bipolar CJC gain setting */
gains[3] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */
gains[4] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */
gains[5] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */
gains[6] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */
gains[7] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */
gains[8] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */
gains[9] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */
gains[10] = TbkBiTypeJ; /* Bipolar Type J Thermocouple gain setting */
/* Set the default mode of operation to differential bipolar */
tbkSetMode(1, 1);
/* Configure the scan sequencer, will use default polarity. */
tbkSetScan(chans, gains, 0, 11);