问题:
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 命令好难懂.
谢谢
1
v2byy 2018-06-04 22:52:58 +08:00 via iPhone
看开发手册啊,做自动化测试吗
|
2
wzw OP @v2byy #1 很多测试只能半自动吧. 正在看手册... 感觉有点怪怪的. 不如 python node js php .net C 好理解. 也可能我刚开始
|
3
wzw OP 一个回复,三个收藏+++
|
4
fsdafsag 2018-06-05 14:42:58 +08:00
只会用 labview 控制,一般都有范例可以改或者 DLL 可以调用, 再不济也可以根据通讯协议通过 scpi 模块来通讯。
|