beautypg.com

Analog input in the background – Measurement Computing TempBook rev.3.0 User Manual

Page 42

background image

6-10 Standard API Programming of the TempBook with C

TempBook User’s Manual

tbkRdNFore(buf, 10);

/* Print the results using a 12 bit data format */
sprintf(tempstr,"\r\nResults of tbkRdNFore Channels 0 - 7:\r\n");
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 ", buf[(scan * 8) + chan]>4);
strcat(response,tempstr);
}
}

sprintf(tempstr,"\r\n");
strcat(response,tempstr);

SendDlgItemMessage(myDlg, 101, WM_SETTEXT, 0, (LONG)(LPSTR)response);
EmptyMessageQueue(myDlg);
}

Analog Input in the Background

/***********************************************
File: Adcex3.c
Description:This example demonstrates the use of the TempBook/66's
background transfer routines.
Functions Used:tbkRdNBack(unsigned _far *buf, unsigned count, unsigned char
cycle,
unsigned char updateSingle)
tbkGetBackStat(unsigned char _far *active, unsigned long _far *count)
***********************************************/

unsigned int data[80], chans[8], i, scan, chan;
unsigned char gains[8], polarities[8], active;
unsigned long count;

sprintf(response,"\r\nAdcex3.c\r\n\r\n");

/* Set the default mode of operation to single-ended bipolar */
tbkSetMode(0, 1);

/* Set channels, gains, & polarities arrays to channels 0-7,
bipolar, at unity gain. */

for(i=0;i<8;i++)
{
chans[i] = i;
gains[i] = TgainX1;
polarities[i] = 1;
}

/* Load the scan sequencer FIFO */
tbkSetScan(chans, gains, polarities, 8);

/* Set Clock : 1Hz - xtal set to 1MHz */
tbkSetClk(1000, 1000);

/* Set pacer clock trigger source */
tbkSetTrig(TtsPacerClock, 1, 0, 0);

/* Read 10 scans of data in the background, cycle off, */
/* update on each scan */
tbkRdNBack(data, 10, 0, 1);

/* Check if acquisition is complete */
do {