发表于:2004-09-29 20:35:00
楼主
我使用cvi6.0,采用凌华的pci9111DG进行波形的采集和分析,但是,由于初学,出现一些无法解决的问题,在数据采集使无法取得数据,显示全是0,而且,有个错误显示
NON-FATAL RUN-TIME ERROR
"示波器.c", line 92, col 12, thread id 0xFFF539E3
Library function error (return value == -13 [0xfffffff3]).
Invalid control ID
程序如下
#include <cvirte.h>
#include <userint.h>
#include "示波器.h"
#include "dask.h"
//constants definition
#define CardNumber 0
#define ADChan 0
#define ScanCount 65536
#define SampleRate 10000.0000
//AI config constants definition
#define PreTrigEn 0
#define TraceCnt 0
//variables definition
I16 cardID = -1;
I16 err=0;
U32 AccessCnt = 0;
U32 MemSize = 0;
I16 InBuf[65536]; //AI data buffer
F64 InVolBuf[65536]; // AI voltages buffer
static int panelHandle;
static int STRIPCHART;
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "示波器.uir", PANEL)) < 0)
return -1;
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}
int CVICALLBACK START_DATA (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
cardID = Register_Card(PCI_9111DG, CardNumber);
if (cardID<0) {
//Error occurs !!
//ToDo : Handle error here
}
err = AI_InitialMemoryAllocated(cardID,&MemSize);
if (err!=NoError) {
//Error occurs !!
//ToDo : Handle error here
}
if (MemSize*1024 < ScanCount*sizeof(I16) ) {
//available memory size for analog input in the device driver
//is smaller than the data size specified!!
//ToDo : do something here
}
err = AI_AsyncDblBufferMode(cardID, 0);
if (err!=NoError) {
//Error occurs !!
//ToDo : Handle error here
}
err=AI_9111_Config(cardID, TRIG_INT_PACER, PreTrigEn, TraceCnt);
if (err!=NoError) {
//Error occurs !!
//ToDo : Handle error here
}
err=AI_ContReadChannel (cardID, ADChan, AD_B_10_V, InBuf, ScanCount, SampleRate, SYNCH_OP);
if (err!=NoError) {
//Error occurs !!
//ToDo : Handle error here
}
err=AI_ContVScale (cardID, AD_B_10_V, InBuf, InVolBuf, ScanCount);
if (err!=NoError) {
//Error occurs !!
//ToDo : Handle error here
}
Release_Card(cardID);
break;
}
return 0;
}
int CVICALLBACK TRANS_DATA (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
DeleteGraphPlot (panelHandle, STRIPCHART, -1, VAL_IMMEDIATE_DRAW);
PlotY(panelHandle, STRIPCHART, InVolBuf, 65536, VAL_DOUBLE, VAL_THIN_LINE,
VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
break;
}
return 0;
}
int CVICALLBACK QUIT (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
QuitUserInterface (0);
break;
}
return 0;
}
请高手帮我看看吧,事情比较急,先谢谢帮助了。