Skip to main content

electrical instrument control

Project description

Build Status DOI

instrbuilder is an open-source Python package for control of electrical instruments. This package eases the development of high-level "drivers" to interface with oscilloscopes, power supplies, function generators, multimeters, or any instrument that uses ASCII textual string communication (such as SCPI). instrbuilder is particularly suited for prototying and automating experiments in research laboratory setups within an IPython terminal. Our goals are to accelerate the development of automated data collection and improve the reproducibility of laboratory experiments.

Related Journal Papers

  • L. Koerner "Instrbuilder: A Python package for electrical instrument control" The Journal of Open Source Software: doi
  • L. Koerner, T. Caswell, D. Allan, and S. Campbell "A Python instrument control and data acquisition suite for reproducible research" IEEE Transactions on Instrumentation and Measurement doi

Documentation

https://lucask07.github.io/instrbuilder/build/html/

Installation Steps

  1. Install a VISA driver (National Instruments provides free downloads). The PyVISA documentation page is an excellent resource to locate a VISA driver for your system:
  1. Install instrbuilder using pip.
username$ python -m pip install instrbuilder 

Getting Started

  1. Command lists for Keysight oscilloscopes, function generator, DMM; Rigol DC Power Supply (commands.csv) are included in the package at: instrbuilder/instruments/.

Locate the instrument command files using the following python commands:

import instrbuilder
init_file_loc = instrbuilder.__file__
instrument_cmds = init_file_loc.replace('__init__.py', 'instruments/')
print('Instrument commmands (csv files) are at: {}'.format(instrument_cmds))

Note that you can move the command csv files (and probably should). The location of these needs to be specified in the YAML configuration file.

  1. A YAML file is used to track your specific system configurations and instrument addresses (e.g. USB0::0x0957::0x0407::MY44060286::INSTR). Create your system YAML file using the steps below. This will be generated at ~/.instrbuilder/ (where ~ indicates your home directory). See the example YAML on GitHub.

  2. Try an example in the source code at instrbuilder/examples/. A Keysight and Rigol Oscilloscope is demonstrated in: oscilloscope.py.

Locate the example directory using the following python commands:

import instrbuilder
init_file_loc = instrbuilder.__file__
examples = init_file_loc.replace('__init__.py', 'examples/')
print('Examples are at: {}'.format(examples))

Create Your YAML

  1. Initialize a YAML (specify the first parameter, the other 3 should always be default):
from instrbuilder import instrument_opening
instrument_opening.init_yaml(csv_dir = 'where/your/commands_csv/files/are')
  1. To add instruments to the YAML function use the script found in instrbuilder/examples/add_instruments_to_config.py. This will prompt the user for information. Note that it may be helpful to have only one instrument connected/powered at a time so that there is no ambiguity:

  2. An example YAML is available here on GitHub.

Extra Installation Steps if Using the Bluesky Suite from NSLS-II

  1. If using the Bluesky suite uninstall ophyd and re-install from a git fork:
username$ python -m pip uninstall ophyd 
username$ python -m pip install git+https://github.com/lucask07/ophyd@master#egg=ophyd

To check if the correct ophyd fork was installed try:

from ophyd.ee_instruments import generate_ophyd_obj

This warning:

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...

is OK. A module import error is not.

A basic Bluesky demo is at instrbuilder/bluesky_demo/fg_oscilloscope_basics.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

instrbuilder-0.1.14.tar.gz (73.9 kB view hashes)

Uploaded Source

Built Distribution

instrbuilder-0.1.14-py3-none-any.whl (106.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page