pyVISA: Return instrument to local mode programmatically

半腔热情 提交于 2019-12-07 17:07:35

问题


I am using pyVISA to control some instruments in a GPIB network. When I create a resource manager, all the instruments in my GPIB network enter remote mode, so the front panel displays are locked and do not update. When I close the resource manager, the instruments remain in remote mode.

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()

In this particular case I only want to control one instrument in the network, but need the others to be powered on, with front panel displays live.

Is there a way to exclude the "extra" instruments from the resource manager programmatically (don't want to have to disconnect the GPIB cables or switch off GPIB comms manually if I can help it) and/or something like a "go to local" command I can send to either the whole network or a specific instrument, so the front panels are live once the instrument in question has been configured as needed?

UPDATE:

After some experimentation and further reading, I found the following returns my instrument to local mode:

#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)

The values 0 and 6 are constants set in pyVISA (http://pyvisa.readthedocs.io/en/stable/_modules/pyvisa/constants.html) Seems I should be able to specify a variable name here instead of the constant so there is obviously something else I am not understanding, but at least I have a working solution now.


回答1:


There is a call available to control the remote/local state of the device.

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)




回答2:


Most Instruments have remote and local commands. Visa also has its own set local command, which looks like viGpibControlREN( handle, VI_GPIB_REN_ADDRESS_GTL ) in c. You'd have to read the manuals for the equipment to be sure, but their individual visa commands are usually something like "SYST:LOC"



来源:https://stackoverflow.com/questions/43592317/pyvisa-return-instrument-to-local-mode-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!