pyVISA:Return 以编程方式进入本地模式

pyVISA: Return instrument to local mode programmatically

我正在使用 pyVISA 来控制 GPIB 网络中的一些仪器。当我创建资源管理器时,我的 GPIB 网络中的所有仪器都进入远程模式,因此前面板显示被锁定并且不更新。当我关闭资源管理器时,仪器仍处于远程模式。

import visa

rm = visa.ResourceManager()

#Connect to a specific instrument
MyInstrument = rm.open_resource('GPIB0::10::INSTR')

#Do stuff
print(MyInstrument.query("*IDN?"))

#close resource manager
rm.close()

在这种特殊情况下,我只想控制网络中的一台仪器,但需要打开其他仪器的电源,并使前面板显示屏实时显示。

有没有办法以编程方式从资源管理器中排除 "extra" 仪器(如果可以的话,我不想断开 GPIB 电缆或手动关闭 GPIB 通信)and/or 类似 "go to local" 命令的东西,我可以发送到整个网络或特定仪器,所以一旦相关仪器已根据需要进行配置,前面板就会激活?

更新:

经过一些实验和进一步阅读,我发现以下 returns 我的仪器为本地模式:

#Return single instrument to local with 
#GTL command (VI_GPIB_REN_ADDRESS_GTL = 6)
MyInstrument.control_ren(6)

#Return all instruments in network to local by 
#deasserting remote enable line (VI_GPIB_REN_DEASSERT = 0)
MyInstrument.control_ren(0)

值0和6是pyVISA中设置的常量(http://pyvisa.readthedocs.io/en/stable/_modules/pyvisa/constants.html) 似乎我应该能够在这里指定一个变量名而不是常量,所以显然还有一些我不理解的东西,但至少我现在有一个可行的解决方案。

大多数仪器都有远程和本地命令。 Visa 也有自己的set local 命令,在c 中看起来像viGpibControlREN( handle, VI_GPIB_REN_ADDRESS_GTL )。您必须阅读设备的手册才能确定,但​​他们各自的签证命令通常类似于 "SYST:LOC"

有一个调用可用于控制设备的 remote/local 状态。

GPIBInstrument.control_ren(mode)

Controls the state of the GPIB Remote Enable (REN) interface line, and optionally the remote/local state of the device.

Corresponds to viGpibControlREN function of the VISA library.

(Source)