SOS:PCI-9114多道连续采集问题
我的困惑: 本人购得ADLINK一块PCI-9114HG采集板(16-bit resolutio 32 S.E. or 16 D.I.)。 现要在Win98下用VC 6.0调用PCIS-DASK 4.0作32 S.E.采集程序. 要求0至31通道连续采集,每道的采样频率均为0.5ms,即2000Hz,每道的采样长度均为 16K samples. 请问该如何实现(不许用AI_ContScanCha elsToFile)? 采集回来的数据要放在自定义的缓冲区中. 以下是稍有修改的用PCIS-DASK Code Creator生成的代码,怎样在此基础上做出我要的程序? 请列位热心家Garylin,Yoyo1101,李侃,张斌,国安及其他大侠做答. // P9114AsyncCAI.c : Defines the entry point for the co ole a lication. // #include <windows.h> #include &;lt tdio.h> #include <conio.h> #include "dask.h" // PCI_9114HG : Continuous AI /******************************************************** The following code segment is generated according to your device setup. You can copy and i ert it into your program to operate your device. ********************************************************/ //co tants definition #define CardNumber 0 #define ADChanCount 32 #define LastADChan (ADChanCount-1) #define ScanCount 512 #define SampleRate 64000.0000 //Scan Rate(Hz): 64000.0000/32 = 2K //variables definition I16 cardID = -1; I16 err=0; BOOLEAN fstop = 0; BOOLEAN HalfReady = 0; U32 Acce Cnt = 0; U32 MemSize = 0; U32 I uf[ADChanCount*ScanCount]; //AI data buffer F64 vaiData[ADChanCount*ScanCount]; int main(int argc, char* argv[]) { FILE* f int i,j; char szStr[1024]; char szTmp[100]; fp = fopen("D:\\P9114HGAsyncContAI.TXT","w t"); if(fp==NULL) { printf("not found file.\n"); exit(1); } cardID = Register_Card(PCI_9114HG, CardNumber); if (cardID<0) { //Error occurs !! //ToDo : Handle error here printf("Error: Register_Card(). CarID=%d .\n",cardID); exit(1); } err = AI_InitialMemoryAllocated(cardID,&;MemSize); if (err!=NoError) { //Error occurs !! //ToDo : Handle error here printf("Error: AI_InitialMemoryAllocated().\n"); exit(1); } if (MemSize*1024 < ScanCount*ADChanCount*sizeof(U32) ) { //available memory size for analog i ut in the device driver //is smaller than the data size ecified!! //ToDo : do something here printf("Error: no enough memory.\n"); exit(1); } err = AI_AsyncDblBufferMode(cardID, 1);//enable double-buffer mode if (err!=NoError) { //Error occurs !! //ToDo : Handle error here printf("Error: AI_AsyncDblBufferMode().\n"); exit(1); } err=AI_9114_Config(cardID, TRIG_INT_PACER); if (err!=NoError) { //Error occurs !! //ToDo : Handle error here printf("Error: AI_9114_Config().\n"); exit(1); } err=AI_ContScanCha els (cardID, LastADChan, AD_B_10_V, (U16 *)((U32 *)I uf),ScanCount*ADChanCount, SampleRate, ASYNCH_OP); if (err!=NoError) { //Error occurs !! //ToDo : Handle error here printf("Error: AI_ContScanCha els(). errcode = %d.\n",err); exit(1); } do { do { AI_AsyncDblBufferHalfReady (cardID, &;HalfReady, &;fstop); } while (!HalfReady); //half buffer data is ready for read AI_AsyncDblBufferTra fer (cardID, (U16 *)((U32 *)I uf) ); } while (!kbhit()); err = AI_AsyncClear(cardID, &;Acce Cnt); if (err!=NoError) { //Error occurs !! //ToDo : Handle error here printf("Error: AI_AsyncClear() failure!\n"); } printf("Now begin write the acquired data to file\n"); err = AI_ContVScale(cardID,AD_B_10_V,I uf,vaiData, ScanCount*ADChanCount); if (err!=NoError) { //Error occurs !! //ToDo : Handle error here printf("Error: AI_ContVScale() failure!\n"); } fprintf(fp,"data of Ch#d---->Ch#d as follows.\n\0",0,LastADChan); for(i=0;i&;lt canCount;i ) { rintf(szStr,"%lf ",vaiData[ADChanCount*i 0]); for(j=1;j<ADChanCount;j ) { rintf(szTmp,"%lf ",vaiData[ADChanCount*i j]); strcat(szStr,szTmp); } strcat(szStr,"\n"); fwrite((char *)szStr,strlen(szStr),1,fp); } fclose(fp); Release_Card(cardID); printf("Pre any key to quit!\n"); getch(); return 0; } 注:我用NuDAQ PCI Configuration Utility为AI-Buffer分配了64KBytes的空间. 在上述程序中,若ScanCount的值大于512,则导致AI_ContScanCha els()出错(errcode=-15, ErrorTra ferCountTooLarge). 神啊,快救救我吧.
|