Low-level analog input – Measurement Computing TempBook rev.3.0 User Manual
Page 41

TempBook User’s Manual
Standard API Programming of the TempBook with C 6-9
tbkRdScan(0, 7, data, TgainX1);
/* Print the results using a 12 bit data format */
sprintf(tempstr,"\r\n\r\nResults of tbkRdscan:\r\n");
strcat(response,tempstr);
for(i=0;i<8;i++) {
sprintf(tempstr,"Channel: %2d Data: %4d\r\n", i, data[i]>4);
strcat(response,tempstr);
}
/* Get 10 samples from channels 0 - 7, triggered by the pacer clock
with a 1000 Hz sampling frequency and unity gain. */
tbkRdScanN(0, 7, data2, 10, TtsPacerClock, 0, 1000, TgainX1);
/* Print the results using a 12 bit data format */
sprintf(tempstr,"\r\nResults of tbkRdScanN Channels 0 - 7:");
strcat(response,tempstr);
for (scan=0 ; scan <8; scan++) {
sprintf(tempstr,"\r\nScan %d: ", scan);
strcat(response,tempstr);
for (chan=0 ; chan<8 ; chan++) {
sprintf(tempstr,"%4d ", data2[(scan * 8) + chan]>4)
; strcat(response,tempstr);
}
}
SendDlgItemMessage(myDlg, 101, WM_SETTEXT, 0, (LONG)(LPSTR)response)
; EmptyMessageQueue(myDlg);
}
Low-Level Analog Input
/***********************************************
File:Adcex2.c
Description:This example demonstrates the use of the TempBook/66's lower
level ADC functions. These functions allow separate scan
sequencer setup, trigger source selection, and ADC data collection.
Functions Used:bkSetMux(unsigned startChan, unsigned endChan, unsigned char
gain)
tbkSetFreq(float freq) tbkSetTrig(unsigned char trigger, unsigned char
oneShot, unsigned char ctr0mode, unsigned char pacerMode)
tbkRdNFore(unsigned _far *buf, unsigned count)
*************************************************/
unsigned int buf[80], scan, chan;
sprintf(response,"\r\nAdcex2.c\r\n");
/* Set the default mode of operation to single-ended bipolar */
tbkSetMode(0, 1);
/* Set the scan sequencer for channels 0 - 7 at unity gain */
tbkSetMux(0, 7, TgainX1);
/* Set the scan frequency for 1000 Hz */
tbkSetFreq(1000);
/* Set the trigger source for the Pacer Clock. Note that the trigger
is armed immediately */
tbkSetTrig(TtsPacerClock, 0, 0, 1);
/* Read 10 scans of data */