pyvisa通过python控制hp/agilent/keysight mso-x/dso-x 3000a示波器
msox3000的Python项目详细描述
msox3000系列
通过控制HP/Agilent/Keylight MSO-X/DSO-X 3000A示波器 python via pyvisa
以我以前在dcps方面的工作为指导,本文旨在 控制各种示波器的通用软件包。然而,它是 预期很少示波器共享相同的命令,因此启动 作为专门用于mso-x/dso-x 3000a的python类关闭 示波器。所以我们会开始瞄准示波器家族 使用一个普通的scpi.py类。如果对其他人有用 示波器,然后将创建一个新的项目,但至少这一个 会从这个开始的。
它也可以在mso-x/dso-x 2000a示波器上工作,但我没有 调查了不同之处,但不能确定。试试看,让我 知道
与dcps一样,这将使用brilliant pyvisa python包和 pyvisa py访问模式消除了对 要在您的计算机上安装的visa库。
安装
您需要安装pyvisa和pyvisa py包
要安装msox3000软件包,请运行以下命令:
python setup.py install
或者,可以将此包的路径添加到环境中 变量pythonpath,甚至在 python脚本。使用您喜爱的web搜索引擎查找更多 细节。
更好的是,msox3000在pypi上。所以你可以简单地使用 而且所需的依赖项应该为您安装:
pip install msox3000
使用量
代码是控制和访问 支持的示波器。
如果运行嵌入在各个包源文件中的示例, 确保编辑资源字符串或visa描述符 特殊装置。对于msox3000.py,还可以设置环境 变量,msox3000_在运行 代码
# Lookup environment variable MSOX3000_IP and use it as the resource# name or use the TCPIP0 string if the environment variable does# not existfrommsox3000importMSOX3000fromosimportenvironresource=environ.get('MSOX3000_IP','TCPIP0::172.16.2.13::INSTR')# create your visa instrumentinstr=MSOX3000(resource)instr.open()# set to channel 1## NOTE: can pass channel to each method or just set it# once and it becomes the default for all following calls. If pass the# channel to a Class method call, it will become the default for# following method calls.instr.channel=1# Enable output of channel, if it is not already enabledifnotinstr.isOutputOn():instr.outputOn()# Install measurements to display in statistics display and also# return their current values hereprint('Ch. {} Settings: {:6.4e} V PW {:6.4e} s\n'.format(instr.channel,instr.measureVoltAverage(install=True),instr.measurePosPulseWidth(install=True)))# Add an annotation to the screen before hardcopyinstr._instWrite("DISPlay:ANN ON")instr._instWrite('DISPlay:ANN:TEXT "{}\\n{} {}"'.format('Example of Annotation','for Channel',instr.channel))instr._instWrite("DISPlay:ANN:COLor CH{}".format(instr.channel))# Change label of the channel to "MySig"instr._instWrite('CHAN{}:LABel "MySig"'.format(instr.channel))instr._instWrite('DISPlay:LABel ON')# Make sure the statistics display is showinginstr._instWrite("SYSTem:MENU MEASure")instr._instWrite("MEASure:STATistics:DISPlay ON")## Save a hardcopy of the screen to file 'outfile.png'instr.hardcopy('outfile.png')# Change label back to the defaultinstr._instWrite('CHAN{}:LABel "{}"'.format(instr.channel,instr.channel))instr._instWrite('DISPlay:LABel OFF')# Turn off the annotationinstr._instWrite("DISPlay:ANN OFF")# turn off the channelinstr.outputOff()# return to LOCAL modeinstr.setLocal()instr.close()
更进一步
这实现了可用命令的一小部分。
有关HP/Agilent/Keysight的可能功能的信息 mso-x/dso-x 3000a,请参见Keysight InfiniiVision 3000 X-Series Oscilloscopes Programming Guide
对于符合ieee标准的通用仪器来说 488 scpi规范,如mso-x 3000a,请参见SCPI 1999 Specification和 SCPI Wikipedia 进入
接触
请将错误报告或反馈发送给Stephen Goadhouse