电气仪表控制
instrbuilder的Python项目详细描述
instrbuilder是一个用于控制电气仪表的开源python包。该软件包简化了高级“驱动程序”的开发,以与示波器、电源、函数发生器、万用表或任何使用ascii文本字符串通信(如scpi)的仪器进行接口。instrbuilder特别适合在ipython终端内的研究实验室设置中进行原型化和自动化实验。我们的目标是加速自动化数据收集的发展,提高实验室实验的重现性。
文件
https://lucask07.github.io/instrbuilder/build/html/
安装步骤
- 安装visa驱动程序(national instruments提供免费下载)。Pyvisa文档页面是一个很好的资源,可以为您的系统找到visa驱动程序:
- NI-VISA downloads:以操作系统分隔的下载链接。
- PyVISA backends:需要什么的解释。
- 使用pip安装instrbuilder。
username$ python -m pip instrbuilder
开始
- 按键示波器、函数生成器、DMM的命令列表;RIGOL直流电源(commands.csv)包含在位于:instrbuilder/instruments/的包中。
使用以下python命令查找instrument命令文件:
importinstrbuilderinit_file_loc=instrbuilder.__file__instrument_cmds=init_file_loc.replace('__init__.py','instruments/')print('Instrument commmands (csv files) are at: {}'.format(instrument_cmds))
注意,您可以移动命令csv文件(可能应该)。这些文件的位置需要在yaml配置文件中指定。
yaml文件用于跟踪特定的系统配置和仪器地址(例如usb0::0x0957::0x0407::my44060286::instr)。使用以下步骤创建系统yaml文件。这将在~/.instrbuilder/生成(其中~表示主目录)。请参阅github上的example YAML。
在instrbuilder/examples/的源代码中尝试一个示例。keysight和rigol示波器在:oscilloscope.py中演示。
使用以下python命令定位示例目录:
importinstrbuilderinit_file_loc=instrbuilder.__file__examples=init_file_loc.replace('__init__.py','examples/')print('Examples are at: {}'.format(examples))
创建您的yaml
- 初始化一个yaml(指定第一个参数,其他3个参数应始终为默认值):
frominstrbuilderimportinstrument_openinginstrument_opening.init_yaml(csv_dir='where/your/commands_csv/files/are')
若要将add instruments添加到yaml函数,请使用instrbuilder/examples/add_instruments_to_config.py中的脚本。这将提示用户提供信息。请注意,一次只连接/通电一台仪器可能会有帮助,这样就不会产生歧义:
这里有一个示例YAML on GitHub
如果使用NSLS-II
中的Bluesky套件,则需要额外的安装步骤- 如果使用Bluesky套件,请卸载ophyd并从git fork重新安装:
username$ python -m pip uninstall ophyd username$ python -m pip install git+https://github.com/lucask07/ophyd@master#egg=ophyd
要检查是否安装了正确的ophydfork,请尝试:
fromophyd.ee_instrumentsimportgenerate_ophyd_obj
此警告:
Error: <class 'ImportError'>
IC (integrated circuit imports failed)
The aardvark.so or dll must be in the cwd or an importable path
Continuing anyways, since many may not use this portion...
是否正常。模块导入错误不是。
一个基本的bluesky演示在instrbuilder/bluesky_demo/fg_oscilloscope_basics.py