/**********************************************************************/ /* This program is developed by Microsoft C 5.1 */ /***********************************************************************/ /* Demo 9: one P180X card M_FUN_3 demo. */ /* To acquire A/D CH:0, CH:1, CH:2 250 times. */ /***********************************************************************/ #define MYLIB #include "P180X.H" int iLine; WORD wAdNum=250; // how many data is scan for a A/D channel float fAdBuf[750]; // stored the acquired data. 0-249 is the data for CH:0, // 250-499 is the data for CH:1, 500-750 data for CH:2 WORD wDaFreq=90; // D/A output frequency is 1.8M/wDaFreq WORD wAdClk=24; // A/D sampling rate is 8M/wAdClk WORD wDa[320],wAd[750]; 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 wChannel[32],wConfigCode[32]; WORD wDaWave=80; float fDaMagnitude=2.5,dfAdFrequency; WORD wAddrTimer,wAddrCtrl,wAddrDio,wAddrAdda; clrscr(); // a clear screen function in P180XMC?.LIB gotoxy(1,1); // initiaing P180X card and detect how many P180X card in PC wRetVal=P180X_DriverInit(&wBoards); printf("Threr are %d P180X Cards in this PC\n",wBoards); if( wBoards==0 ) { putch(0x07); putch(0x07); putch(0x07); printf("There are no P180X card in this PC !!!\n"); exit(0); } /* dump every P180X 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); /************** M3 Function ****************************/ for(i=0; i<750; i++) fAdBuf[i]=0.0; for(i=0; i<32; i++) wChannel[i]=0; wChannel[0]=wChannel[1]=wChannel[2]=1; for(i=0; i<32; i++) wConfigCode[i]=0; wRetVal=P180X_M_FUN_3(wDaFreq,wDaWave,fDaMagnitude,wAdClk,wAdNum, wChannel,wConfigCode,fAdBuf,-10.0,+10.0); if( wRetVal==0 ) { printf("P180X_M_FUN3 OK.\n"); printf("Channel 0's first 4 data:\n"); printf("[ 0]=%+4.2f, [ 1]=%+4.2f, [ 2]=%+4.2f, [ 3]=%+4.2f\n", fAdBuf[0],fAdBuf[1],fAdBuf[2],fAdBuf[3]); printf("Channel 1's first 4 data:\n"); printf("[250]=%+4.2f, [251]=%+4.2f, [252]=%+4.2f, [253]=%+4.2f\n", fAdBuf[250],fAdBuf[251],fAdBuf[252],fAdBuf[253]); printf("Channel 2's first 4 data:\n"); printf("[500]=%+4.2f, [501]=%+4.2f, [502]=%+4.2f, [503]=%+4.2f\n", fAdBuf[500],fAdBuf[501],fAdBuf[502],fAdBuf[503]); } else { putch(0x07); printf("P180X_M_FUN3 Error !!!\n"); exit(0); } P180X_DriverClose(); return wRetVal; }