High-speed digital input – Measurement Computing TempBook rev.3.0 User Manual
Page 44

6-12 Standard API Programming of the TempBook with C
TempBook User’s Manual
sprintf(tempstr,"Digital output byte written 0x%2x\r\n", out_byte);
strcat(response,tempstr);
}
/* Read the value from the digital input port (DI0 - DI7 inclusive) */
tbkRdByte(&in_byte);
sprintf(tempstr,"Digital input byte is 0x%2x\r\n", in_byte);
strcat(response,tempstr);
SendDlgItemMessage(myDlg, 101, WM_SETTEXT, 0, (LONG)(LPSTR)response);
EmptyMessageQueue(myDlg);
}
High-Speed Digital Input
/***********************************************
File: Digex2.c
Description:This example demonstrates the use of the TempBook's high speed
digital inputs.
Functions Used:tbkSetScan(unsigned *chans, unsigned char *gains, unsigned
char *polarity, unsigned count)
tbkRdNFore(unsigned _far *buf, unsigned count)
***********************************************/
unsigned chans[9], data[9], i, chan;
unsigned char gains[9], polarity[9];
sprintf(response,"\nDigex2.c\n\n");
/* Configure the channels and gains arrays for analog inputs 0-7 */
/* plus the high speed digital inputs */
for (i=0 ; i<8 ; i++)
{
chans[i] = i; /* Analog input channels 0 - 7 */
gains[i] = TgainX1; /* Unity gain */
polarity[i] = 1; /* Bipolar */
}
chans[8] = TchHighSpeedDig; /* High speed digital inputs */
gains[8] = TgainX1; /* Put any gain, it doesn't matter */
polarity[8] = 1; /* Put any polarity, it doesn't matter */
/* Set default operation to single-ended, bipolar */
tbkSetMode(0, 1);
/* Load the scan sequencer, NULL pointer for polarities array */
/* indicates use default polarity */
tbkSetScan(chans, gains, 0, 9);
/* Set software trigger source */
tbkSetTrig(TtsSoftware, 0, 0, 0);
/* Trigger a scan */
tbkSoftTrig();
/* Read the ADC FIFO buffer */
tbkRdNFore(data, 1);
/* Print the results */
sprintf(tempstr,"Analog input channels 0 - 7:\n");