发表于:2002-10-22 14:10:00
楼主
PSDASKManual.pdf手册的 5.1.2 Synchronous Continuous Analog input programming
Scheme中为把采集到的数据转换成电压实际值,用AI_ContVScale()函数。我用时转换结果一半正确一半错误,很奇怪!(板卡上硬件跳线应该没问题)
***我的用法:(Borland C++Builder5环境,Tchart控件图形显示)
U16 FBuffer[1024];
F64 FVoltageArray[1024];
AI_ContReadChannel(Card9113ID_Two, 0, AD_B_10_V,FBuffer, 1024, 25000,SYNCH_OP);
AI_ContVScale( Card9113ID_Two, AD_B_10_V,FBuffer,FVoltageArray,1024);
for (int j=0; j<1024; j++)
{
Series1->AddXY(i+1,FVoltageArray[j],"",clRed);//画图显示
i+=1;
}
如果不用AI_ContVScale(),而手动转换
for (int k=0; k<1024; k++)
{
FVoltageArray[k] = ((FBuffer[k]&0xFFF)*20)/4096-10;
}
也不对.
***例子程序Samples\9113\sdk9113DbfInt\9113cint.c 中的用法:
//变量声明
U32 *ai_buf;//很奇怪,函数原型中用 U16 *ai_buf??
//start动作之后
AI_9113_Config(card,TRIG_INT_PACER);
AI_AsyncDblBufferMode (card, 1)
AI_ContReadChannel(card, channel, AD_B_10_V, ai_buf, data_size, (F64)sample_rate, ASYNCH_OP)
do {
do {
AI_AsyncDblBufferHalfReady(card, &HalfReady, &fstop);
} while (!HalfReady);
AI_AsyncDblBufferTransfer(card, ai_buf);
for (i=0; i<data_size; i++)
{
adinput = ai_buf[i] & 0xfff;
newy=io_pos[0].y+172-(174*adinput)/4096;
newx = i*336/data_size+output_pos[15].x+35;
//...(省略)
} //这个for循环里怎么这样转换成实际电压值???172,174,336如何解释???
pdf文档的附录C数据格式中对PCI-9113板卡,对continuous AI,是32位数据,而AI_ContReadChannel()中的参数要16位的缓冲,这是怎么回事???