NI LabVIEW,CVI,数据采集等产品讨论区

取消
显示结果 
搜索替代 
您的意思是: 

How to receive binary trace data from R3767CG Network Analyzer in VC++?

你好, 我公司用的频谱分析仪型号是R3767CG,采用GPIB接口采集数据,,鉴于读取Trace data(ASCII )非常慢,所以改用读binary数据的办法,但得到数据(科学计数法)不准确。 有关VC++代码如下:
int RecieveBinaryData(int iDev,double *buf,unsigned bufsize,char *name)
{
unsigned cnt;
char s[32];

double iSize=0;
double dblTest1=0.0;

iSize=sizeof(double);

ibwrt(iDev, "FORM: BORD NORM", 14L);
ibwrt(iDev, "FORM: DATA REAL, 64", 18L);
ibwrt(iDev,"INIT:CONT OFF;:ABOR;INIT",24);

ibwrt(iDev,"TRAC? 0",7);
ibconfig(iDev,12,0);
ibcmd(iDev,"?__K",4);
ibrd(iDev,s,8);
ibrd(iDev,(char*)buf,iSize*bufsize);
cnt=ibcnt;
if(!ibsta & END)
{
ibrd(iDev,s,1);
}
ibconfig(iDev,12,'\n');
return (int)(cnt/iSize);
}

int PrintData(double *data,unsigned num)
{
unsigned points=num>>1;
unsigned i;
double dblTest1=0.0;
double dblTest2=0.0;

for (i=0;iMessage Edited by xsfu on 05-25-2009 08:40 PM
0 项奖励
1 条消息(共 3 条)
3,854 次查看
郁闷,显示不完整。
Message Edited by xsfu on 05-25-2009 08:49 PM
0 项奖励
2 条消息(共 3 条)
3,845 次查看
补上未发完的部分。
int PrintData(double *data,unsigned num)
{
unsigned points=num >>1;
unsigned i;
double dblTest1=0.0;
double dblTest2=0.0;

for ( i=0 ; i < points ;++i )
{
TRACE("%4d:%1.7e\t%1.7e\n",i,*data,*(data+1));
dblTest1=*data;
dblTest2=*(data+1);
data+=1;
}
return 1;
}


调用代码如下:
int iResult=RecieveBinaryData(Dev,&databuf1[0],1602,"0");
PrintDat(&databuf1[0],iResult);

部分得到的数据(PrintData)如下:
0:6.8128929e-313 2.7227942e-312
1:2.7227942e-312 4.7633084e-312
2:4.7633084e-312 1.8572610e-314
3:1.8572610e-314 2.0451718e-312
4:2.0451718e-312 1.3637190e-312
5:1.3637190e-312 9.2004822e-315
6:9.2004822e-315 2.7286840e-312
7:2.7286840e-312 6.9529648e-313
8:6.9529648e-313 4.7628946e-312
9:4.7628946e-312 4.0934709e-312
10:4.0934709e-312 1.3632204e-312
11:1.3632204e-312 3.3953648e-312

得到的数据为科学计数法,但e后为-312之类的数值有点怪异,真实数据在0.6左右。
能否告诉我是哪里出了问题。thanks.
0 项奖励
3 条消息(共 3 条)
3,839 次查看