/**********************************************************************/ /* This program is developed by MicroSoft C 5.1 */ /***********************************************************************/ /* Demo 5: one PCI-1202 card M_FUN_1 demo. */ /***********************************************************************/ #define MYLIB #include "P1202.H" int iLine; float fAdBuf[510]; DWORD dwDaFreq=90; WORD wAdClk; 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 fSampleRate; 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==0 ) { putch(0x07); putch(0x07); putch(0x07); printf("There are no P1202 card 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\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("Please Enter the Frequency for D/A(suggestion 90) -> "); scanf("%ld",&dwDaFreq); printf("\n"); // Enter wAdClk, the A/D sampling rate is 8M/wAdClk // suggestion: wAdClk=24 printf("Please Enter wAdClk(suggestion 24) -> "); scanf("%ld",&wAdClk); printf("\n"); fSampleRate=8000.0/wAdClk; // A/D is fSampleRate Khz /************** M1 Function ****************************/ for(i=0; i<510; i++) fAdBuf[i]=0.0; wRetVal=P1202_M_FUN_1(dwDaFreq,wDaWave,dfDaMagnitude,wAdClk,wAdNum, 0,fAdBuf,-10.0,+10.0); if (wRetVal==0) printf("1. P1202_M_FUN_1 OK, Sample Rate is %7.3fK\n\n",fSampleRate); else { putch(0x07); printf("1. 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; }