发表于:2002-06-13 18:20:00
楼主
我买了一块PCI-9111HR,要编一个数据采集程序,现在遇到一些问题。那位高手能够帮我看看程序?不胜感谢!
我使用PCI-DASK结合DAQBenchd的Dchart控件,使用vc编程。
首先在Dchart控件DChartSampleDlg.h里定义:protected:
int i;
int count;
double data[8];
I16 card;
I16 card_number;
int Card_Type;
U16 channel;
U16 range;
U32 data_size;
F64 sample_rate;
BOOLEAN bStopped;
U32 AccessCnt;
BOOLEAN HalfReady;
BOOLEAN fstop;
然后在DChart SampleDlg.cpp里修改:先包含"dask.h"
1.在void CLuLampDlg::OnBeginPlot() 里加入:
card_number = 0;
Card_Type = PCI_9111HR;
channel=0;
range=AD_B_10_V;
sample_rate=500;
data_size=1024;
card=Register_Card(Card_Type, card_number);
AI_9111_Config(card,TRIG_INT_PACER,false,512);//double-buffered AI
AI_AsyncDblBufferMode (card, 1);
ai_buf=new U16[1024] ;
2.把中代码void CLuLampDlg::OnTimer(UINT nIDEvent)修改为:
AI_ContScanChannels (card, channel, range, ai_buf, data_size,sample_rate, ASYNCH_OP);
do {
AI_AsyncDblBufferHalfReady(card, &HalfReady, &fstop);
} while (!HalfReady);
AI_AsyncDblBufferTransfer(card, ai_buf);
for(i=0;i<=511;i++) //scale to voltage and plot
{
if(ai_buf[i]<=32767)
data=ai_buf[i]*10/32768;
else
data=-((ai_buf[i]^65535)+1)*10/32768;
m_Chart.PlotCharts(&ArrayToVar(data, m_PlotNum+1), m_PlotNum+1, BoolToVar(false));
m_Chart2.PlotCharts(&ArrayToVar(data, m_PlotNum+1), m_PlotNum+1, BoolToVar(false));
}
AI_AsyncClear(card, &AccessCnt);
CDialog::OnTimer(nIDEvent);
3.在void CLuLampDlg::OnStopPlot()中加入:
delete ai_buf;
Release_Card(card);
最后在link时加入dask.dll,编译后生成的可执行文件总是造成无效模块的
致命错误,造成死机。
请各位高人多多指教,本人不胜感激。