NI-VISA通信的调用

By admin at 2021-09-02 • 1人收藏 • 1986人看过

VISA是一种用来与各种仪器总线进行通信的高级应用编程接口,可用来对USB、GPIB、串口、VXI、PXI和以太网系统进行配置、编程和调试


下面是一些资料:

1.NI-VISATM Programmer  Reference Manual

370132c.pdf

2.NI-VISAUser Manual

370423a.7z


原版rsVISA用到的dll和h头文件

res.zip


简单的封装了下, 完整库代码和调用示例, 请看楼下8楼. 

9 个回复 | 最后更新于 2022-06-19
2021-09-02   #1

使用rsVISA也是一样的,有些仪器USB hid需要安装visa驱动。之前看到的还没时间研究

https://www.rohde-schwarz.com.cn/driver-pages/remote-control/3-visa-and-tools_231388.html#media-gallery-7


2021-09-06   #2
import win.ui;
/*DSG{{*/
mainForm = win.form(text="aardio工程15";right=613;bottom=424)
mainForm.add(
button={cls="button";text="Button";left=52;top=39;right=197;bottom=83;z=1};
button2={cls="button";text="Button";left=53;top=112;right=198;bottom=156;z=2}
)
/*}}*/
 
import console
console.open()
 
//ViStatus  int32
//ViPSession uint32
//ViAttr ViUInt32
 
var dll = ..raw.loadDll("\res\RsVisa32.dll");
viOpenDefaultRM = dll.api("viOpenDefaultRM","int(INT&)" );
viFindRsrc = dll.api("viFindRsrc","INT(INT,string,INT&,INT&,string&)" );
viOpen = dll.api("viOpen","int(INT,string,INT,INT,INT&)" );
viSetAttribute = dll.api("viSetAttribute","int(INT,INT,INT)" );
viWrite = dll.api("viWrite","int(INT,string,INT,INT&)" );
viRead = dll.api("viRead","int(INT,string&,INT,INT&)" );
viClose = dll.api("viClose","int(INT)" );
 
var status,defaultRM = viOpenDefaultRM(0);
console.log(  status,defaultRM )
 
console.log( viFindRsrc( defaultRM,"*?",0,0,raw.buffer(100) ) )
 
 
var instr;
mainForm.button.oncommand = function(id,event){
    status,instr = viOpen( defaultRM,"ASRL1::INSTR",0,5000,0 );
    console.log("viOpen", status,instr )
    status = viSetAttribute(instr,0x3FFF001A,5000);
    console.log("viSetAttribute", status )
    /* Set serial port settings as needed*/
    /* Defaults = 9600 Baud, no parity, 8 data bits, 1 stop bit*/
    status = viSetAttribute(instr, 0x3FFF0021, 2400);
     console.log("viSetAttribute1", status )
    status = viSetAttribute(instr, 0x3FFF0022, 8);
     console.log("viSetAttribute2", status )
    /* Set this attribute for binary transfers, skip it for this text example */
    status = viSetAttribute(instr, 0x3FFF00B3, 2);
      console.log("viSetAttribute3", status )
    
    status = viSetAttribute(instr, 0x3FFF0018, 0x0d);
      console.log("viSetAttribute3", status )
      status = viSetAttribute(instr, 0x3FFF0038, 1);
      console.log("viSetAttribute4", status )
}
 
mainForm.button2.oncommand = function(id,event){
     
    status,retCount = viWrite(instr, '*IDN?', 6, 0);
    console.log("viWrite", status,retCount )
    status,getstr,retCount = viRead(instr, raw.buffer(200,'\0'), 200, 0);
    console.log("viRead", status,getstr,retCount )
 
}
mainForm.onClose = function(hwnd,message,wParam,lParam){
    if(instr){
        status = viClose(instr);
        console.log("viClose", status )   
    }
    if(defaultRM){
        status = viClose(defaultRM);
        console.log("viClose", status )   
    }
}
 
mainForm.show();
return win.loopMessage();

image.png

image.png


2021-09-07   #3

这里的示例都是使用的RSVisa.dll, RS和NI只是一点点区别, 实际上都是用的ivi的visa.lib进行的封装, 文档可以完全相互参考.

RS提供的visa测试软件功能更简洁,而且可以显示每一步所使用的代码, 更方便调试.

无标题.png

从测试软件里可以得到很多信息, 这些代码都是我们今后需要在程序里调用的, 具体的参数功能还是需要看看文档了解下.


我下面弄个动态图, 具体来演示下:

GIF.gif

从图上可知: 我最后读取到的波特率和设置波特率的代码应该如下:

mainForm.button3.oncommand = function(id,event){
	console.log( "viGetAttribute,BAUD 设置前:",viGetAttribute(instr,0x3FFF0021/*VI_ATTR_ASRL_BAUD*/,0) )
	status = viSetAttribute(instr, 0x3FFF0021/*VI_ATTR_ASRL_BAUD*/, 115200);
	console.log( "viGetAttribute,BAUD 设置后:",viGetAttribute(instr,0x3FFF0021/*VI_ATTR_ASRL_BAUD*/,0) )
}

image.png

上面aardio的代码和列表里显示的一模一样.

2021-09-08   #4

2021-09-08 22:26 更新:

增加几个常用函数

2021-09-09 14:22 更新:

修正dll函数中几处错误


研究visa发现, 其实很多时候并不需要那么多的函数来使用, 为了对aardio中使用更友好, 我在RS官方示例基础上, 对dll进行了二次封装, 只保留了9个函数.

VisaRsrc
VisaGetRsrcString
VisaInit
VisaClose
VisaSetAttr
VisaGetAttr
VisaWrite
VisaRead
VisaClear

VISADllEx.dll 下载:

VISADllEx.zip

VISADllEx的vs2015工程源码下载:

IdnSample.zip


GIF.gif

image.png

这里我用串口进行了visa的模拟,  

特别注意: 串口初始化完成, 默认波特率是9600 , 8,0,0,1 , 接收中断默认是接收到'\n'即"0x0A"字符,  如果你的设备不是默认配置, 那么就使用 VisaSetAttr() 对设备进行属性设置, 改变波特率和结束符符号.

至于属性是哪个, 可以参考楼上的方式找到.

aardio中调用示例如下:

import win.ui;
/*DSG{{*/
mainForm = win.form(text="dlltest";right=446;bottom=259)
mainForm.add(
button={cls="button";text="write";left=26;top=84;right=278;bottom=148;z=1};
button2={cls="button";text="read";left=26;top=171;right=278;bottom=235;z=2};
button3={cls="button";text="VisaGetAttr";left=298;top=84;right=429;bottom=148;z=4};
button4={cls="button";text="VisaClear";left=298;top=168;right=429;bottom=232;z=5};
edit={cls="edit";text="*IDN?";left=26;top=34;right=278;bottom=69;edge=1;z=3}
)
/*}}*/

import console
console.open()
 
var dll = ..raw.loadDll("\res\VISADllEx.dll","VISADllEx");
VisaRsrc = dll.api("VisaRsrc","int()" );
VisaGetRsrcString = dll.api("VisaGetRsrcString","string(INT)" );
VisaInit = dll.api("VisaInit","bool(string)" );
VisaClose = dll.api("VisaClose","bool()" );
VisaWrite = dll.api("VisaWrite","bool(string)" );
VisaRead = dll.api("VisaRead","string(WORD)" );
VisaSetAttr = dll.api("VisaSetAttr","bool(INT,INT)" );
VisaGetAttr = dll.api("VisaGetAttr","INT(INT)" );
VisaClear = dll.api("VisaClear","bool()" );


var count = VisaRsrc();

console.log( count )
for(i=0;count-1;1){
	console.dump( VisaGetRsrcString(i) )
}

console.log(VisaInit("ASRL1::INSTR"))
 
mainForm.button.oncommand = function(id,event){
    console.log(VisaWrite(mainForm.edit.text))
}
 
mainForm.button2.oncommand = function(id,event){  
    //0=默认读取1024个数据, 其他数字为读取数量
    console.log(VisaRead(0))
}
 
mainForm.onClose = function(hwnd,message,wParam,lParam){
    VisaClose()
}

mainForm.button3.oncommand = function(id,event){
	 console.log( VisaGetAttr(0x3FFF0021/*VI_ATTR_ASRL_BAUD*/) )
}

mainForm.button4.oncommand = function(id,event){
	VisaClear();
}

mainForm.show();
return win.loopMessage();


2021-09-08   #5

试过USB通讯可以通讯,可以增加一个查询可用端口的函数就更好了。

2021-09-08   #6

回复#5 @cuiqbo :

加好了 , 直接再楼上更新了.

2021-09-09   #7

visa在labview中连续使用的时候, 一般是这样

image.png

红色部分是获取串口缓冲池中有多少个数据字节数, 将这个字节数给读取函数 , 意思就是将缓冲池中所有的数据读出来.

那么代码中要用

#define VI_ATTR_ASRL_AVAIL_NUM                (0x3FFF00ACUL)

这个属性来获取缓冲池内数据字节数.

var num = VisaGetAttr(0x3FFF00AC);
var retStr = VisaRead(num);


顺便说下, visa有个不是bug的bug , 一直未改善

https://www.ni.com/zh-cn/support/documentation/supplemental/06/termination-characters-in-ni-visa.html#toc2

image.png

image.png

image.png

设置接收中断字节 和 中断使能功能的bug

当你使用下面二个属性想要设置 不使用 中断字节码

#define VI_ATTR_TERMCHAR                      (0x3FFF0018UL)

#define VI_ATTR_TERMCHAR_EN                   (0x3FFF0038UL)

你必须也要设置这个属性

#define VI_ATTR_ASRL_END_IN                   (0x3FFF00B3UL)


它们三个配合使用才能取消中断字节码的中断功能.......

status = viSetAttribute(instr, 0x3FFF0018, 0x0a);
status = viSetAttribute(instr, 0x3FFF0038, 0);
status = viSetAttribute(instr, 0x3FFF00B3, 0);


2021-09-11   #8

封装了个简单的库 , 下面是库代码和调用示例:

VISADllEx.aardio

//VISA通信库
class VISADllEx{
	ctor(  ){
		..table.gc(this,"close");
	};
	
	FindRsc = function(){
		var stringList={};
		var count = VisaFindRsrc();
		if(count!=0){
			for(i=0;count-1;1){
				var str = VisaGetRsrcString(i);
				..table.push(stringList,str);
			}
			return stringList;
		}
		return null;
	};
	
	open = function(deviceName){
		return VisaInit(deviceName);
	};
	
	writeString = function(str){
		return VisaWrite(str);
	};
	
	readString = function(len){
		if(len!=null){
			return VisaRead(len);	
		}
		return VisaRead(0);
	};
	
	setAttr = function(k,v){
		return VisaSetAttr(k,v);
	};
	
	getAttr = function(k){
		return VisaGetAttr(k);
	};
	
	close = function(){
		VisaClose();
	};
}

namespace VISADllEx{
	_dll = ..raw.loadDll($"\res\VISADllEx.dll");
	VisaFindRsrc = _dll.api("VisaRsrc","int()" );
	VisaGetRsrcString = _dll.api("VisaGetRsrcString","string(INT)" );
	VisaInit = _dll.api("VisaInit","bool(string)" );
	VisaClose = _dll.api("VisaClose","bool()" );
	VisaWrite = _dll.api("VisaWrite","bool(string)" );
	VisaRead = _dll.api("VisaRead","string(WORD)" );
	VisaSetAttr = _dll.api("VisaSetAttr","bool(INT,INT)" );
	VisaGetAttr = _dll.api("VisaGetAttr","INT(INT)" );
	VisaClear = _dll.api("VisaClear","bool()" );
}

/**intellisense()
VISADllEx =  基于RSVisa通信扩展库
VISADllEx() = !VISADllExLib.
end intellisense**/

/**intellisense(!VISADllExLib)
FindRsc() = 成功:返回找到的设备系列号列表,\n失败返回null
open(.(设备标识码) = 打开设备\n返回值 成功:true,失败:false
close() = 关闭设备
writeString(.(字符) = 写入字符码\n返回值 成功:true,失败:false
readString(.(字节数) = 读取字符\n返回值 成功:true,失败:false
setAttr(.(名称,属性值) = 设置属性\n名称:_VI_ATTR_开头 属性值:_VI_开头或者直接输入数值\n返回值 成功:true,失败:false
getAttr(.(名称) = 读取属性\n名称:_VI_ATTR_开头
end intellisense**/

// 常量提示
/**intellisense() 
_VI_ATTR_RSRC_CLASS=@0xBFFF0001/*_VI_ATTR_RSR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ECV_TRIG_ID=@0x3FFF4012/*_VI_ATTR_RECV_TRIG_ID*/
_VI_ATTR_INTR_STATUS_ID=@0x3FFF4023/*_VI_ATTR_INTR_STATUS_ID*/
_VI_ATTR_STATUS=@0x3FFF4025/*_VI_ATTR_STATUS*/
_VI_ATTR_RET_COUNT_32=@0x3FFF4026/*_VI_ATTR_RET_COUNT_32*/
_VI_ATTR_BUFFER=@0x3FFF4027/*_VI_ATTR_BUFFER*/
_VI_ATTR_RECV_INTR_LEVEL=@0x3FFF4041/*_VI_ATTR_RECV_INTR_LEVEL*/
_VI_ATTR_OPER_NAME=@0xBFFF4042/*_VI_ATTR_OPER_NAME*/
_VI_ATTR_GPIB_RECV_CIC_STATE=@0x3FFF4193/*_VI_ATTR_GPIB_RECV_CIC_STATE*/
_VI_ATTR_RECV_TCPIP_ADDR=@0xBFFF4198/*_VI_ATTR_RECV_TCPIP_ADDR*/
_VI_ATTR_USB_RECV_INTR_SIZE=@0x3FFF41B0/*_VI_ATTR_USB_RECV_INTR_SIZE*/
_VI_ATTR_USB_RECV_INTR_DATA=@0xBFFF41B1/*_VI_ATTR_USB_RECV_INTR_DATA*/
_VI_ATTR_PXI_RECV_INTR_SEQ=@0x3FFF4240/*_VI_ATTR_PXI_RECV_INTR_SEQ*/
_VI_ATTR_PXI_RECV_INTR_DATA=@0x3FFF4241/*_VI_ATTR_PXI_RECV_INTR_DATA*/

_VI_READ_BUF=@0x1/*_VI_READ_BUF*/
_VI_WRITE_BUF=@0x2/*_VI_WRITE_BUF*/
_VI_READ_BUF_DISCARD=@0x4/*_VI_READ_BUF_DISCARD*/
_VI_WRITE_BUF_DISCARD=@0x8/*_VI_WRITE_BUF_DISCARD*/
_VI_IO_IN_BUF=@0x10/*_VI_IO_IN_BUF*/
_VI_IO_OUT_BUF=@0x20/*_VI_IO_OUT_BUF*/
_VI_IO_IN_BUF_DISCARD=@0x40/*_VI_IO_IN_BUF_DISCARD*/
_VI_IO_OUT_BUF_DISCARD=@0x80/*_V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LAST_BIT=@0x1/*_VI_ASRL_END_LAST_BIT*/
_VI_ASRL_END_TERMCHAR=@0x2/*_VI_ASRL_END_TERMCHAR*/
_VI_ASRL_END_BREAK=@0x3/*_VI_ASRL_END_BREAK*/
_VI_STATE_ASSERTED=@0x1/*_VI_STATE_ASSERTED*/
_VI_STATE_UNASSERTED=@0x0/*_VI_STATE_UNASSERTED*/
_VI_STATE_UNKNOWN=@0xFFFFFFFF/*_VI_STATE_UNKNOWN*/
_VI_BIG_ENDIAN=@0x0/*_VI_BIG_ENDIAN*/
_VI_LITTLE_ENDIAN=@0x1/*_VI_LITTLE_ENDIAN*/
_VI_GPIB_REN_DEASSERT=@0x0/*_VI_GPIB_REN_DEASSERT*/
_VI_GPIB_REN_ASSERT=@0x1/*_VI_GPIB_REN_ASSERT*/
_VI_GPIB_REN_DEASSERT_GTL=@0x2/*_VI_GPIB_REN_DEASSERT_GTL*/
_VI_GPIB_REN_ASSERT_ADDRESS=@0x3/*_VI_GPIB_REN_ASSERT_ADDRESS*/
_VI_GPIB_REN_ASSERT_LLO=@0x4/*_VI_GPIB_REN_ASSERT_LLO*/
_VI_GPIB_REN_ASSERT_ADDRESS_LLO=@0x5/*_VI_GPIB_REN_ASSERT_ADDRESS_LLO*/
_VI_GPIB_REN_ADDRESS_GTL=@0x6/*_VI_GPIB_REN_ADDRESS_GTL*/
_VI_GPIB_ATN_DEASSERT=@0x0/*_VI_GPIB_ATN_DEASSERT*/
_VI_GPIB_ATN_ASSERT=@0x1/*_VI_GPIB_ATN_ASSERT*/
_VI_GPIB_ATN_DEASSERT_HANDSHAKE=@0x2/*_VI_GPIB_ATN_DEASSERT_HANDSHAKE*/
_VI_GPIB_ATN_ASSERT_IMMEDIATE=@0x3/*_VI_GPIB_ATN_ASSERT_IMMEDIATE*/
_VI_GPIB_HS488_DISABLED=@0x0/*_VI_GPIB_HS488_DISABLED*/
_VI_GPIB_HS488_NIMPL=@0xFFFFFFFF/*_VI_GPIB_HS488_NIMPL*/
_VI_GPIB_UNADDRESSED=@0x0/*_VI_GPIB_UNADDRESSED*/
_VI_GPIB_TALKER=@0x1/*_VI_GPIB_TALKER*/
_VI_GPIB_LISTENER=@0x2/*_VI_GPIB_LISTENER*/

end intellisense**/


mainform.aardio调用示例:

import win.ui;
/*DSG{{*/
mainForm = win.form(text="aardio工程15";right=251;bottom=375)
mainForm.add(
button={cls="button";text="write";left=28;top=26;right=209;bottom=79;z=1};
button2={cls="button";text="read";left=28;top=93;right=209;bottom=146;z=2};
button6={cls="button";text="setAttr";left=28;top=205;right=209;bottom=258;z=3};
button7={cls="button";text="getAttr";left=28;top=278;right=209;bottom=331;z=4}
)
/*}}*/

import console
console.open()

import VISADllEx;
var inst = VISADllEx();

console.dump( inst.FindRsc() )
console.log( inst.open("ASRL1::INSTR") )

mainForm.button.oncommand = function(id,event){
	console.log( inst.writeString("123456") );
}

mainForm.button2.oncommand = function(id,event){
	console.log( inst.readString() );
}

mainForm.button6.oncommand = function(id,event){
	console.log( inst.setAttr(0x3FFF0021/*_VI_ATTR_ASRL_BAUD*/,115200) )
}

mainForm.button7.oncommand = function(id,event){
	console.log( inst.getAttr(0x3FFF0021/*_VI_ATTR_ASRL_BAUD*/) )
}

mainForm.show();
return win.loopMessage();


完整工程下载:

visaLIB.zip


RS所有资料下载:

链接:https://pan.baidu.com/s/12KrwqWhmNDr1ghNJoTx9Mw 

提取码:yh3q



新增:

包含了vc运行时的VISADLLEx.dll 

VISADllEx.zip

替换下工程里面的res目录里面的dll即可

2022-06-19   #9

回复#8 @admin :

感谢!

登录后方可回帖

登 录
信息栏
 私人小站

本站域名

ChengXu.XYZ

投诉联系:  popdes@126.com



快速上位机开发学习,本站主要记录了学习过程中遇到的问题和解决办法及上位机代码分享

这里主要专注于学习交流和经验分享.
纯私人站,当笔记本用的,学到哪写到哪.
如果侵权,联系 Popdes@126.com

友情链接
Aardio官方
Aardio资源网


才仁机械


网站地图SiteMap

Loading...