/**********************************************************************/ /* This program is developed by Borland C++ 3.1 */ /***********************************************************************/ /* Demo 7: one P180X card M_FUN_2 demo. */ /***********************************************************************/ #define MYLIB #include "P180X.H" int iLine; float fAdBuf[510]; WORD wAdClk; WORD wDa[320],wAd[510]; WORD wPlot0[512]; /* transformed into wave form */ int main() { int i,j; WORD wBoards,wRetVal; WORD wDIOdata; DWORD dwExact,dwOKs,dwErrors,dwScanCount,dwP1,dwP2,dwStatus; double dfAdFrequency; float fSampleRate; WORD wAddrTimer,wAddrCtrl,wAddrDio,wAddrAdda; /* 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); printf("\nHit any key to continue...\n"); getch(); /************** M2 Function ****************************/ graphic_init(); cleardevice(); for(i=0; i<64; i++) wDa[i]=0x800-i*16; for(i=0; i<64; i++) wDa[i+64]=0x800-(64-i)*16; for(i=0; i<64; i++) wDa[i+64*2]=0x800; for(i=0; i<64; i++) wDa[i+64*3]=0x800-64*8; for(i=0; i<64; i++) wDa[i+64*4]=0x800; for (i=0; i<510; i++) { wAd[i]=0; } wRetVal=P180X_M_FUN_2(320,15,wDa,24,510,0,wAd); if (wRetVal==0) printf("P1802_M_FUN_2 OK\n"); else printf("P1802_M_FUN_2 ERROR, return=%x\n",wRetVal); setcolor(RED); for(i=0; i<501; i++) /* channel 0's data and its wave form */ { wPlot0[i]=100+(wAd[i]/16); } for(i=0; i<500; i++) /* plot channel 0's wave form */ { line(10+i,wPlot0[i],10+i+1,wPlot0[i+1]); } getch(); cleardevice(); closegraph(); P180X_DriverClose(); return 0; } /* -------------------------------------------------------------------- */ graphic_init() { int driver,mode,char_size; driver=EGA; mode=EGAHI; initgraph(&driver,&mode,""); setactivepage(0); setvisualpage(0); setcolor(0); setbkcolor(15); settextstyle(SMALL_FONT,HORIZ_DIR,6); return 0; }