Measurement Computing TempBook rev.3.0 User Manual
Page 35

TempBook User’s Manual
Standard API Programming of the TempBook with C 6-3
Initialize the TempBook on LPT1 with interrupt 7.
tbkInit(LPT1, 7);
Set the default operating mode to single-ended, bipolar. These parameters will affect all scanned channels.
tbkSetMode(0, 1);
The TempBook has a sophisticated channel-gain sequencer that allows every channel in the defined scan to
have a different gain and unipolar/bipolar setting. The following array assignment will be used to setup the
sequencer to sample channels 0 through 7 in bipolar mode at unity gain. If desired, each channel could
have been assigned a different gain and/or unipolar/bipolar setting.
for(i=0;i<8;i++){
chans[i] = i;
gains[i] = TgainX1;
polarities[i] = 1;
}
Once the arrays are loaded with the desired channel numbers and their associated gain and unipolar/bipolar
settings, the following function uses them to load the sequencer.
tbkSetScan(chans, gains, polarities, 8);
Set the Clock to 1 Hz. (This assumes that the time base selection jumper is in the default 1 MHz position)
tbkSetClk(1000, 1000);
Make the Pacer Clock the trigger source.
tbkSetTrig(TtsPacerClock, 1, 0, 0);
Setup the background acquisition of 10 scans. As the data is collected, place it into the array called data.
Regardless of the status of the acquisition, the program will immediately return from this function call and
proceed to the next line in our code. The data will be collected via interrupts and placed in the specified
buffer in the background.
tbkRdNBack(data, 10, 0, 1);
At any point in the program, you can check the status of the background acquisition. The next lines of code
poll the background status continuously until it is no longer active, then it exits the do loop and proceeds
through the remainder of the program.
/* Check if acquisition is complete */
do
{
tbkGetBackStat(&active, &count);
sprintf(tempstr"Transfer in progress : %2d scans acquired.\r",count);
strcat(response, tempstr);
}
while (active != 0);
sprintf(tempstr"\r\nAcquisition complete.\r\n\r\n");
Since the background acquisition is complete, print the data in the buffer.
sprintf(tempstr"Data Acquired:\r\n");
strcat(response, tempstr);
for (scan=0 ; scan<8 ; scan++){
sprintf(tempstr, "\nScan %d:", scan);
strcat(response, tempstr);
for (scan=0 ; scan<8 ; scan++){
sprintf(tempstr" %4d", data[(scan * 8) + chan]>4);
strcat(response, tempstr);
}
}