Skip to main content

Python library for interfacing with Rigol DS1000Z series oscilloscopes.

Project description

rigol-ds1000z

Python library for interfacing with Rigol DS1000Z series oscilloscopes.

This package differs from the alternatives by:

  1. Flattening the communication interface with the test equipment so that code can be written in a more compact form.
  2. Providing a command line interface for easy display and waveform data capture.

This package strives to maintain the verbiage used in the Rigol DS1000Z programming manual as closely as possible. Aside from basic type-casting, command arguments are not validated and instrument responses are not post-processed. Separate utility routines are provided for post-processing display and waveform data.

A function call will send commands associated with the arguments provided and a data structure is always returned with the queried values that belong under that function's domain. Not all interfaces are fully implemented. The basic write, read, and query commands are provided for the user to use in the abscense of a functional interface.

All commands are issued once at a time with a wait after instruction appended. The autoscale and IEEE reset commands enforce a ten and five second sleep respectively to avoid a VISA serial communication timeout or other odd behavior.

Extensive hardware testing has been performed with a Rigol DS1054Z oscilloscope.

Inspired by similar packages iteratively developed by @jtambasco, @jeanyvesb9, and @AlexZettler.

Usage

This package is available on PyPI: pip install rigol-ds1000z.

The command line interface saves to file a display capture or waveform data from a Rigol DS1000Z series oscilloscope. The first valid VISA address identified is utilized by default.

rigol-ds1000z --help
rigol-ds1000z --display path/to/file.png
rigol-ds1000z --waveform src path/to/file.csv

Example code is shown below and also provided as part of this repository. See the status section for the summary of the implemented functional interfaces or browse the generated documentation here.

from rigol_ds1000z import Rigol_DS1000Z
from rigol_ds1000z import find_visa, process_display, process_waveform

# find visa address
visa = find_visa()

with Rigol_DS1000Z(visa) as oscope:
    # run and autoscale
    oscope.run()
    oscope.autoscale()

    # reset, self-test, return queried ieee values
    ieee = oscope.ieee(rst=True, tst=True)
    print(ieee.idn)

    # configure channels, return queried channel values
    ch2 = oscope.channel(2, probe=10, coupling="AC", bwlimit=True)
    ch3 = oscope.channel(3, display=True)
    print(ch2.scale, ch3.scale)

    # send SCPI command to clear the display
    oscope.write(":DISP:CLE")

Status

The following SCPI commands are implemented as functional interfaces:

  • All base-level commands (ex. AUT, RUN, STOP).
  • All IEEE488.2 common commands (ex. IDN?, *RST, TST?).
  • All channel commands (ex. :CHAN1:PROB).
  • All timebase commands (ex. :TIM:MOD, :TIM:DEL:SCAL).
  • All waveform commands (ex. :WAV:SOUR, :WAV:DATA?).
  • The display data query :DISP:DATA?.

Development Notes

  • Package management by Poetry.
  • Automated processing hooks by pre-commit.
  • Code formatting in compliance with PEP8 by isort, black, and flake8.
  • Static type checking in compliance with PEP484 by mypy.
  • Test execution with random ordering and code coverage analysis by pytest.
  • Automated documentation generation by pdoc.

Installing the development environment requires running the following command sequence.

poetry install
poetry run pre-commit install

In order for all tests to pass, an oscilloscope must be connected and channel 2 must be connected to the calibration square wave.

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

rigol-ds1000z-0.1.1.tar.gz (9.8 kB view hashes)

Uploaded Source

Built Distribution

rigol_ds1000z-0.1.1-py3-none-any.whl (10.0 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