Python library to interface with Rigol DS1000z series oscilloscopes.
The interface uses the VISA communication protocol implemented in (PyVISA) and supports both USB and Ethernet.
- Windows 10 - Tested
- ArchLinux - when forked, @jeanyvesb9 stated his version worked with Arch, so I suspect compatibility.
- python3.7+ Python version as f-strings are used in the library
- numpy Library for efficient storage and processing of arrays
- pyvisa Visa communication protocol
- tqdm Command line progress bar
- pipenv makes installation of requirements easier and separates python environments reducing the probability of package dependency conflicts. To install run the following commands from your working directory
pip install pipenv
pipenv install
import pyvisa as visa
from rigol1000z import Rigol1000z
from time import sleep
from rigol1000z.constants import *
# Initialize the visa resource manager
rm = visa.ResourceManager()
# Get the first visa device connected
osc_resource = rm.open_resource(rm.list_resources()[0])
# Create oscilloscope interface using with statement!
with Rigol1000z(osc_resource) as osc:
osc.ieee488.reset() # start with known state by restoring default settings
# osc.autoscale() # Autoscale the scope
# Set the horizontal timebase
osc.timebase.mode = ETimebaseMode.Main # Set the timebase mode to main (normal operation)
osc.timebase.scale = 10 * 10 ** -6 # Set the timebase scale
# Go through each channel
for i in range(1, 5):
osc[i].enabled = True # Enable the channel
osc[i].scale_v = 1000e-3 # Change voltage range of the channel to 1.0V/div.
osc.run() # Run the scope if not already
sleep(0.5) # Let scope collect the waveform
osc.stop() # Stop the scope in order to collect data.
osc.get_screenshot('./screenshot.png') # Take a screenshot of the scope's display
osc.get_data(EWaveformMode.Raw, './channels.csv') # Collect and save waveform data from all enabled channels
osc.run() # Move back to run mode when data collection is complete
Based on the original work by @jtambasco which was further developed by @jeanyvesb9.
I have heavily modified the work to be closer to a full implementation of a Rigol1000z library.
My goal for the rewrite has been to make the device as easy as possible to control by:
- Type hinting function parameters, and return values.
- Developing a command hierarchy as it is found in the Rigol programming manual and adding docstrings describing the effect of the function.
- Implementing most set/get commands as properties and related setters for a more organic device interface.
- Defining discrete string constants separately so that autocompletion of constants can be preformed from the corresponding enumeration class
I began this project to create the best library to control the Rigol1000z series of scopes. This is a huge project and I suspect there will be issues with some commands.
If any issues are discovered, please submit an issue to the issues page with the oscilloscope model you are using, and code you were running.
Feedback will keep this project growing and I encourage all suggestions.
There are menus that aren't yet implemented completely. If you would like to implement one of these menus feel free to submit a pull request.
If you are having an issue and want to fix it, please create the issue first with the model and code so that problems are addressed and tracked properly :)