Giter VIP home page Giter VIP logo

keyoscacquire's Introduction

keyoscacquire: Keysight oscilloscope acquire

PyPI

CodeFactor

Code Climate maintainability

Read the Docs Building

License

keyoscacquire is a Python package for acquiring traces from Keysight InfiniiVision oscilloscopes through a VISA interface.

Based on PyVISA, keyoscacquire provides programmes for acquiring and exporting traces to your choice of ASCII format files (default csv) or numpy npy, and a png of the trace plot. The package also provides an API for integration in other Python code.

By default, the package uses the binary WORD format for the waveform transfer from the oscilloscope, giving roughly an order of magnitude speed-up over the ASCII transfer type.

The code has been tested on Windows 7 and 10 with a Keysight DSO2024A model using a USB connection.

Documentation

Available at keyoscacquire.rtfd.io. A few examples below, but formatting and links are broken as this file is intended for the documentation parser.

Building a local copy of the docs

Should you wish to build a local copy of the sphinx docs, make sure the necessary packages are installed:

pip install sphinx sphinx-prompt furo recommonmark

and then build by executing make html in the docs folder.

Installation

Install the package with pip:

pip install keyoscacquire

or download locally and install with $ python setup.py install or by running install.bat.

Python console/API

The Reference/API section (particularly osc-class) gives all the necessary information about the API.

As an example of API usage/use in the Python console:

>>> import keyoscacquire as koa
>>> scope = koa.Oscilloscope(address='USB0::1234::1234::MY1234567::INSTR')
Connected to:
   AGILENT TECHNOLOGIES
   DSO-X 2024A (serial MY1234567)
>>> scope.acq_type = 'AVER8'
>>> print(scope.num_points)
7680
>>> time, y, channel_numbers = scope.get_trace(channels=[2, 1, 4])
Acquisition type: AVER
# of averages:    8
From channels:    [1, 2, 4]
Acquiring ('WORD').. done
Points captured per channel: 7,680
>>> print(channel_numbers)
[1, 2, 4]
>>> scope.save_trace(showplot=True)
Saving trace to:  data.csv
>>> scope.close()

where time is a vertical numpy (2D) array of time values and y is a numpy array which columns contain the data from the active channels listed in channel_numbers. The trace saved to data.csv also contains metadata (can be further customised) in the first lines:

# AGILENT TECHNOLOGIES,DSO-X 2024A,MY1234567,02.50.2019022736
# AVER,8
# 2020-12-21 03:13:18.184028
# time,1,2,4
-5.000063390000000080e-03,-4.853398528000013590e-03,-5.247737759999995810e-03,-5.247737759999995810e-03
...

The trace can be easily loaded from disk to a Pandas dataframe with:

>>> df, metadata = koa.fileio.load_trace("data")
>>> df.head()
    time         1         2         4
0 -0.005 -0.004853 -0.005248 -0.005248
1 -0.005 -0.005406 -0.005017 -0.005248
2 -0.005 -0.004964 -0.005190 -0.005248
3 -0.005 -0.005185 -0.005363 -0.005248
4 -0.005 -0.005517 -0.005074 -0.005248
>>> metadata
['AGILENT TECHNOLOGIES,DSO-X 2024A,MY1234567,02.50.2019022736', 'AVER,8', '2020-12-21 03:13:18.184028', 'time,1,2,4']

Command line use

Capture the active channels on an oscilloscope connected with VISA address from command prompt

bash

get_single_trace -v "USB0::1234::1234::MY1234567::INSTR"

The get_single_trace programme takes several other arguments too, see them with

bash

get_single_trace -h

If you need to find the VISA address of your oscilloscope, simply use the command line programme list_visa_devices provided by this package

bash

list_visa_devices

If you want to set a default VISA address (and other default options too), run path_of_config to find the folder of the keyoscacquire.config module, locate it and change the _visa_address variable to the VISA address of your chosen default instrument.

The package installs the following command line programmes in the Python path

  • list_visa_devices: list the available VISA devices
  • path_of_config: find the path of keyoscacquire.config storing default options. Change this file to your choice of standard settings, see default-options.
  • get_single_trace: use with option -h for instructions
  • get_num_traces: get a set number of traces, use with option -h for instructions
  • get_traces_single_connection: get a trace each time enter is pressed, use with option -h for instructions

See more under cli-programmes-short.

Contribute/report issues

Please report any issues with the package with the issue tracker on Github.

Contributions are welcome via Github.

The package is written and maintained by Andreas Svela.

keyoscacquire's People

Contributors

asvela avatar k9bbzjavftzaqaqsw3dy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

keyoscacquire's Issues

Support for 2-channel scopes?

Hello, I am testing keyoscacquire with a Keysight DSOX1202G and when issuing the scope = koa.Oscilloscope('LONG ADDRESS') command, the library responds with:
Connected to: KEYSIGHT TECHNOLOGIES DSOX1202G (serial CN######)

Then after a delay there is a timeout when trying to query ':CHAN3:DISP?'. Since this is a two channel scope, polling channel 3 causes an error. Changing the range(1 to 5) to range(1 to 3) on lines 319 and 326 of oscilliscope.py clears the error but now it is hardcoded for 2 channels.

Since there isn't a standard SCPI command to determine the number of channels on a scope, perhaps channels could be added as a parameter when initializing.

Support Infiniium series

Hello,
While searching for controlling lab equipment via Python I found your code. Looks very clean, well documented, super !
In our lab we have an Keysight MSOS404A and DSOV084A. Connected via ethernet network.
While trying your code I get the following error:

Connected to:
  KEYSIGHT TECHNOLOGIES
  MSOS404A (serial MYxxxxxxxx)

VisaError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
  When trying query ':ACQuire:TYPE?'  (full traceback below).
  Have you checked that the timeout (currently 30,000 ms) is sufficently long?
Latest errors from the oscilloscope (FIFO queue, upto 30 errors)
 0: -113
 1: -113
 2: -420
 3: 0
....

I saw in the documentation you added support for the Infiniium series, is this also something which needs adjustment for our series?
Kind Regards, Hans

setup depend on pandas

  1. install_requires miss pandas package
  2. Would you enhance the feature to save screenshot to PC?

Reading error message from scope

Add function in oscacq.py to extract error from oscilloscope's error queue. Consider clever way of asking for error before connection is terminated due to failure.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.