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:
- Flattening the communication interface with the test equipment so that code can be written in a more compact form.
- 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
Built Distribution
Hashes for rigol_ds1000z-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13262d5e4f7129d0e13d4658fd8cbc45bf387ad9f09b5a1129620201f8c06b96 |
|
MD5 | 8185a5bf53d0dc6e0429733554897523 |
|
BLAKE2b-256 | 412c3a317b317561bd1f0b0083394f6bbe9a36c1eff74c855bf66c2669c274c1 |