/**********************************************************************/ /* This program is developed by MicroSoft C 5.1 */ /***********************************************************************/ /* Demo 6: two board PCI-1202 cards M_FUN_1 demo. */ /***********************************************************************/ #define MYLIB #include "P1202.H" int iLine; float fAdBuf[510]; DWORD dwDaFreq0,dwDaFreq1; WORD wAdClk0,wAdClk1; WORD wPlot0[512]; // transformed into wave form int main() { int i,j; WORD wBoards,wRetVal; WORD wDIOdata; char cShow[80]; DWORD dwExact,dwOKs,dwErrors,dwScanCount,dwP1,dwP2,dwStatus; WORD wDaWave=50,wAdNum=510; double dfDaMagnitude=(double)2.5,dfAdFrequency; float fSampleRate0,fSampleRate1; WORD wAddrTimer,wAddrCtrl,wAddrDio,wAddrAdda; clrscr(); // a clear screen function in P1202MC?.LIB gotoxy(1,1); // initiaing P1202 card and detect how many P1202 card in PC wRetVal=P1202_DriverInit(&wBoards); printf("Threr are %d P1202 Cards in this PC\n",wBoards); if( wBoards<=1 ) { putch(0x07); putch(0x07); putch(0x07); printf("Please install two P1202 cards in this PC !!!\n"); exit(0); } /* dump every P1202 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("The Second P1202 Card...\n"); P1202_ActiveBoard( 1 ); P1202_Do(0x5678); // Digital output P1202_Di(&wDIOdata); // Digital input printf("Digital Output -> 5678H | Digital Input -> %04xH\n",wDIOdata); printf("\n\n"); // The D/A output wave form generator is a machine dependent function. // The D/A output frequency: // for Pemtium-120 -> D/A output freqency=1.8M/dwDaFreq // for Pemtium-133 -> D/A output freqency=2.0M/dwDaFreq // suggestion: dwDaFreq=90 printf("(1st Card)Please Enter the Frequency for D/A(suggestion 90) -> "); scanf("%ld",&dwDaFreq0); // Enter wAdClk, the A/D sampling rate is 8M/wAdClk // suggestion: wAdClk=24 printf("(1st Card)Please Enter wAdClk(suggestion 24) -> "); scanf("%d",&wAdClk0); printf("\n"); fSampleRate0=8000.0/wAdClk0; // A/D is fSampleRate Khz printf("(2nd Card)Please Enter the Frequency for D/A(suggestion 90) -> "); scanf("%ld",&dwDaFreq1); // Enter wAdClk, the A/D sampling rate is 8M/wAdClk // suggestion: wAdClk=24 printf("(1st Card)Please Enter wAdClk(suggestion 24) -> "); scanf("%d",&wAdClk1); printf("\n"); fSampleRate1=8000.0/wAdClk1; // A/D is fSampleRate Khz /************** M1 Function ****************************/ //--------- To Active First P1202 Card -------------------- P1202_ActiveBoard( 0 ); for(i=0; i<510; i++) fAdBuf[i]=0.0; wRetVal=P1202_M_FUN_1(dwDaFreq0,wDaWave,dfDaMagnitude,wAdClk0,wAdNum, 0,fAdBuf,-10.0,+10.0); if (wRetVal==0) { printf(cShow,"1st Card: P1202_M_FUN_1 OK, Sample Rate is %7.3fK",fSampleRate0); } else { putch(0x07); printf("1st Card: P1202_M_FUN_1 ERROR, return=%x\n\n",wRetVal); exit(0); } printf("[ 0]=%+4.2f, [ 1]=%+4.2f, [ 2]=%+4.2f, [ 3]=%+4.2f\n", fAdBuf[0],fAdBuf[1],fAdBuf[2],fAdBuf[3]); printf("[ 4]=%+4.2f, [ 5]=%+4.2f, [ 6]=%+4.2f, [ 7]=%+4.2f\n", fAdBuf[4],fAdBuf[5],fAdBuf[6],fAdBuf[7]); printf("[ 8]=%+4.2f, [ 9]=%+4.2f, [10]=%+4.2f, [11]=%+4.2f\n", fAdBuf[8],fAdBuf[9],fAdBuf[10],fAdBuf[11]); printf("[12]=%+4.2f, [13]=%+4.2f, [14]=%+4.2f, [15]=%+4.2f\n", fAdBuf[12],fAdBuf[13],fAdBuf[14],fAdBuf[15]); printf("[16]=%+4.2f, [17]=%+4.2f, [18]=%+4.2f, [19]=%+4.2f\n", fAdBuf[16],fAdBuf[17],fAdBuf[18],fAdBuf[19]); //--------- To Active Second P1202 Card -------------------- P1202_ActiveBoard( 1 ); for(i=0; i<510; i++) fAdBuf[i]=0.0; wRetVal=P1202_M_FUN_1(dwDaFreq1,wDaWave,dfDaMagnitude,wAdClk1,wAdNum, 0,fAdBuf,-10.0,+10.0); if (wRetVal==0) { printf("2nd Card: P1202_M_FUN_1 OK, Sample Rate is %7.3fK",fSampleRate0); } else { putch(0x07); printf("2nd: P1202_M_FUN_1 ERROR, return=%x\n\n",wRetVal); exit(0); } printf("[ 0]=%+4.2f, [ 1]=%+4.2f, [ 2]=%+4.2f, [ 3]=%+4.2f\n", fAdBuf[0],fAdBuf[1],fAdBuf[2],fAdBuf[3]); printf("[ 4]=%+4.2f, [ 5]=%+4.2f, [ 6]=%+4.2f, [ 7]=%+4.2f\n", fAdBuf[4],fAdBuf[5],fAdBuf[6],fAdBuf[7]); printf("[ 8]=%+4.2f, [ 9]=%+4.2f, [10]=%+4.2f, [11]=%+4.2f\n", fAdBuf[8],fAdBuf[9],fAdBuf[10],fAdBuf[11]); printf("[12]=%+4.2f, [13]=%+4.2f, [14]=%+4.2f, [15]=%+4.2f\n", fAdBuf[12],fAdBuf[13],fAdBuf[14],fAdBuf[15]); printf("[16]=%+4.2f, [17]=%+4.2f, [18]=%+4.2f, [19]=%+4.2f\n", fAdBuf[16],fAdBuf[17],fAdBuf[18],fAdBuf[19]); P1202_DriverClose(); return 0; }