Thermocouple linearization – Measurement Computing TempBook rev.3.0 User Manual

Page 39

Advertising
background image

TempBook User’s Manual

Standard API Programming of the TempBook with C 6-7

Thermocouple Linearization

The following excerpt from TBKEX.C, demonstrates the use of the TempBook's thermocouple linearization
routines.

unsigned i, chans[11], data[1100];
unsigned char gains[11];
int temp[8];

The following lines of code assign channels and gains to the arrays that will be used to create a scan
sequence. The position of the CJC in the scan and the assignment of the gains for all of the channels must
conform to the conventions used by the linearization routines. See the command reference section for more
information on scan configuration.

/* 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 operating mode to differential, bipolar. These parameters will affect all scanned channels.

tbkSetMode(1, 1);

Configure the scan sequencer,with the desired channels and gains. A zero for the polarity argument forces
the use of the default polarity for all of the channels.

tbkSetScan(chans, gains, 0, 11);

Set the pacer clock for a 1 msec period.

tbkSetFreq(1000);

Use the Pacer Clock as the trigger source.

tbkSetTrig(TtsPacerClock, 0, 0, 0);

The following function tells all of the TbkTC functions to to use zero correction. Zero correction
compensates for offset drift in the electronics due to ambient temperature changes and/or age.

tbkTCAutoZero(1);

Read 100 scans and place the raw data in the supplied buffer.

tbkRdNFore(data, 100);

Reset the trigger to prevent a buffer overrun.

Advertising