Zero compensation – Measurement Computing TempBook rev.3.0 User Manual
Page 53

TempBook User’s Manual
Software Calibration and Zero Compensation 7-3
/*Read the calibration constants from the calibration constant text file
assuming the default name ‘tempbook.cal’*/
tbkReadCalFile(“”);
/* Set the default operating mode to differential, bipolar */
tbkSetMode(1,1);
/* Get 1 sample from channels 0 through 7 at unity gain */
tbkRdScan(0, 7, data, TgainX1);
/* Print the uncalibrated samples using a 12-bit format */
printf(“/nUncalibrated Results of tbkRdScan:/n”);
for(i=0; i<8; i++)
printf(“Channel: %2d Data: %4d/n”, i, data[i]>4);
/* Setup and perform offset and gain software calibration of data */
tbkCalSetup(8,
/* 8 readings within a scan */
0,
/* First reading to be cal’d at position 0 */
8,
/* Calibrate 8 readings per scan */
0,
/* Channel type is 0 for non-CJC */
TgainX1 /* Reading taken at X1 gain */
1,
/* Readings are bipolar */
0);
/* Perform zero as well as gain calibration */
tbkCalConvert (data, /*Pointer to array of readings */
1);
/* 1 scan in that array */
/* Print the calibrated samples using a 12-bit format */
printf(“/nCalibrated Results of tbkRdScan:/n”);
for(i=0; i<8; i++)
printf(“Channel: %2d Data: %4d/n”, i, data[i]>4);
/* Close and exit */
tbkClose
}
Zero Compensation
The zero compensation functions require a shorted channel to be sampled at the same gain as the channels
to be compensated.
The tbkZeroSetup function configures the location of the shorted channel and the channels to be zeroed
within a scan, the size of the scan and the number of readings to zero. This function does not do the
conversion. A non-zero return value indicates an invalid parameter error.
int tbkZeroSetup ()
uint nscan
The number of readings in a single scan.
uint zeroPosition
The position of the zero reading within the scan.
uint
readingsPosition
The position of the readings to be zeroed within the scan.
uint nReadings
The number of readings per scan to be zero compensate.
The tbkZeroConvert function compensates one or more scans according the previously called
tbkZeroSetup function
. This function will modify the array of data passed to it.
int tbkZeroConvert ()
uint *counts
The raw data from one or more scans.
uint scans
The number of scans of raw data in the counts array.
For convenience, both the setup and convert steps can be performed with one call to
tbkZeroSetupConvert
. This is useful when the zero compensation needs to be performed multiple
times because data was read from channels at different gains.