//GPIB 自动查找设备代码
#include
#include
/* include the visa32.lib*/
#pragma comment(lib,"visa32.lib")
main()
{
int retCnt=0;
char buf [256] = {0};
char instrDesc[100]={0};
ViSession defaultRM,vi;
ViStatus status;
ViFindList
find_list;
viOpenDefaultRM (&defaultRM);
status = viFindRsrc(defaultRM, "USB0::?*INSTR",
&find_list, &retCnt, instrDesc);
status = viOpen(defaultRM,instrDesc,
VI_NULL,VI_NULL, &vi);
if (status != VI_SUCCESS){
printf("Can not find USBTMC device!
");
viClose(vi);
viClose (defaultRM);
return;
}
printf("USBTMC device : %s
",instrDesc);
viPrintf(vi,"*idn?
");
viScanf (vi, "%t", &buf);
printf("%s
",buf);
viClose (vi);
viClose (defaultRM);
}
/* GPIB Sample Code */
#include
#include
/* include the visa32.lib*/
#pragma comment(lib,"visa32.lib")
main()
{
int retCnt=0;
char buf [256] = {0};
char instrDesc[100]={0};
ViSession defaultRM,vi;
ViStatus status;
ViFindList find_list;
viOpenDefaultRM (&defaultRM);
status = viFindRsrc(defaultRM,"GPIB?*INSTR",
&find_list, &retCnt, instrDesc);
status = viOpen(defaultRM,instrDesc,
VI_NULL,VI_NULL, &vi);
if (status != VI_SUCCESS){
printf("Can not find GPIB device!
");
viClose(vi);
viClose (defaultRM);
return;
}
printf("GPIB device : %s
",instrDesc);
viPrintf(vi,"*idn?
");
viScanf (vi, "%t", &buf);
printf("%s
",buf);
viClose (vi);
viClose (defaultRM);
}
VISA资源管理器:
viOpenDefaultRM(sesn):打开缺省资源管理器资源对话通道。
viOpen(sesn,rsrcname,accessMode,timeout,vi):打开特定资源的对话通道。
viFindRsrc(sesn,expr,findList,retcnt,instrDesc):查询VISA系统进行资源定位。
viFindNext(findList,instrDesc):返回前一个查询操作查得的资源。
*CLS
*RST
SYST:DISP:UPD OFF ;关闭显示更快
SYST:PSAV:HOLD 1 ;1分钟
SYST:PSAV ON ;省电
如果命令INIT:CONF OFF 在之前被发送,命令INIT 将起始一次扫描
必须保证当整个扫描都结束时,下个命令才被执行。同步,
INIT:CONF OFF;单次扫描
INIT:IMM;*WAI ;wait不要过用
FORAMT ascii
calc:unit:pow dbm //y轴单位