问题:
import visa
rm = visa.ResourceManager()
scope = rm.open_resource("TCPIP::192.168.2.2::5025::SOCKET")
# All these three settings are required for SOCKET and Serial connection
scope.write_termination = '\n'
scope.set_visa_attribute(visa.constants.VI_ATTR_TERMCHAR, 10)
scope.set_visa_attribute(visa.constants.VI_ATTR_TERMCHAR_EN, True)
scope.clear() # Clear instrument io buffers and status
idn_response = scope.query('*IDN?') # Query the Identification string
print 'Hello, I am ' + idn_response
RTO/RTE Oscilloscope example for Python using PyVISA
import visa
import VISAresourceExtentions
# -----------------------------------------------------------
# Initialization
# -----------------------------------------------------------
rm = visa.ResourceManager()
scope = rm.open_resource('TCPIP::10.85.0.119::INSTR')
# try block to catch any InstrumentErrorException() or InstrumentTimeoutException()
try:
scope.write_termination = ''
# Some instruments require LF at the end of each command. In that case, use:
# scope.write_termination = '\n'
scope.ext_clear_status() # Clear instrument io buffers and status
scope.write('*RST;*CLS;:SYST:DISP:UPD ON') # Reset the instrument
scope.write('*ESE 1') # Event Status Enable OPC bit - one time setting after *RST
scope.ext_error_checking() # Error Checking
# -----------------------------------------------------------
# Settings all in one string:
# -----------------------------------------------------------
scope.write('ACQ:POIN:AUTO RECL;:TIM:RANG 2.0;:ACQ:POIN 1002;:CHAN1:STAT ON;:TRIG1:MODE AUTO')
scope.ext_error_checking() # Error Checking
# -----------------------------------------------------------
# Acquisition:
# -----------------------------------------------------------
print '\nAcquisition started...'
scope.ext_write_with_srq_sync('SING', 6000)
print 'Acquisition finished'
# -----------------------------------------------------------
# Selftest:
# -----------------------------------------------------------
print '\nSelftest started...'
scope.ext_query_with_srq_sync('*TST?', 120000)
scope.ext_error_checking() # Error Checking
print 'Selftest finished...'
print 'Finished'
except VISAresourceExtentions.InstrumentErrorException, e:
# Catching instrument error exception and showing its content
print 'Instrument error(s) occurred:\n' + e.message
except VISAresourceExtentions.InstrumentTimeoutException, e:
# Catching instrument error exception and showing its content
print 'Timeout error(s) occurred:\n' + e.message
有没有这方面入门经验的分享一下, 感觉 SCPI 命令好难懂.
谢谢
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.