/************************************************************************/ /* This program is developed by Microsoft C 5.1 */ /************************************************************************/ /* Demo 12: Two P1602 Cards MagicScan Function demo. */ /* First Card: To acquire A/D CH:0, CH:1 250 times. */ /* Second Card: To acquire A/D CH:0, CH:1 250 times. */ /************************************************************************/ #define MYLIB #include "P1602.H" #define DATACOUNT 250 // how many data is scan for a A/D channel WORD wAdClk=24; // A/D sampling rate is 8M/wAdClk WORD wV0[DATACOUNT]; // AD ch:0 buffer WORD wV1[DATACOUNT]; // AD ch:1 buffer WORD wPlot0[DATACOUNT]; // transformed into wave form int main() { WORD i,j; WORD wBoards,wRetVal; WORD wDIOdata; float fVal; char cShow[80]; WORD wAddrTimer,wAddrCtrl,wAddrDio,wAddrAdda; _clearscreen(0); gotoxy(1,1); // initiaing P1602 card and detect how many P1602 card in PC wRetVal=P1602_DriverInit(&wBoards); printf("Threr are %d P1602 Cards in this PC\n",wBoards); if( wBoards<=1 ) { putch(0x07); putch(0x07); putch(0x07); printf("Please install two P1602 cards in this PC !!!\n"); exit(0); } /* dump every P1602 card's configuration address space */ printf("The Configuration Space -> Timer Control DIO AD/DA\n"); for(i=0; i 1234H | Digital Input -> %04xH\n",wDIOdata); printf("--------------------------------------------------\n"); printf("Now Active Second P1602 Card...\n"); P1602_ActiveBoard( 1 ); P1602_Do(0x5678); // Digital output P1602_Di(&wDIOdata); // Digital input printf("Digital Output -> 5678H | Digital Input -> %04xH\n",wDIOdata); printf("\nHit any key to active first card and show data.\n"); getch(); /***************************************************************/ // To active the first card P1602_ActiveBoard( 0 ); for (i=0; i