Digilent Waveforms API facade with optional UIX
Project description
dwfpy_ux
Digilent Waveforms API facade with optional UIX
While the WaveForms software is quite mature, more direct/programmatic communication with these devices might be needed for some experiments. This library is intended to provide both a lightweight display and communication interface to the oscilloscope.
from DwfInterface import DigiScope
ds = DigiScope()
ds.configure_all(params)
ds.graph()
ds.acquire_continuous()
Overview
dwfpy_ux provides a Python interface to Digilent oscilloscope hardware using the Waveforms SDK. This library simplifies device connection, configuration, and data acquisition for Digilent oscilloscope devices.
Features
- Easy configuration with a single dictionary passed to
configure_all() - Data export as pandas DataFrames
- Real-time data visualization GUI for monitoring oscilloscope signals
Requirements
- Python 3.6+
- NumPy
- Pandas
- Digilent Waveforms SDK (dwf library)
- PyQt5
- pyqtgraph
- pglive
Installation
- Install the Digilent Waveforms SDK from Digilent's website
- Install the package using pip:
pip install dwfpy_ux
Or install from source:
git clone https://github.com/snmendoza/dwfpy_ux.git
cd dwfpy_ux
pip install -e .
Quick Start
from DwfInterface import DigiScope
from DwfInterface import dwfconstants as DConsts
# Create a DigiScope instance
ds = DigiScope()
# Configure oscilloscope parameters
params = {
1: {
"range": 5.0, # ambipolar range relative to offset
"offset": 0.0, # offset from ground
"enable": 1, # Boolean
"coupling": "dc", # "ac", "dc", "gnd"
},
2: {
"range": 5.0,
"offset": 0.0,
"enable": 1,
"coupling": "dc",
},
"scope": {
"frequency": 1e6, #Sampling rate
"samples": 8000, #Number of samples to acquire
# Acquisition time = samples / frequency
},
"trigger": {
"type": "edge", # "edge", "pulse", "auto", other not implemented
"channel": 1,
"level": 2.0,
"position": 0.01,
"hysteresis": 0.01,
# for edge, pass channel, level, position, hysteresis, polarity (+/-)
# for pulse, pass channel, level, polarity (+/-)
# width, condition (>,<)
},
"wavegen": {
"waveform": "sine",
### Implemented:
#"triangle", "ramp", "dc", "noise", "pulse", "sine", #"square",
### Partially Implemented:
# "trap", "rampdown", "sinepower", #"sinena"
"frequency": 1e6, #
"amplitude": 1.0,
"offset": 0.0,
}
}
# Apply configuration
ds.configure_all(params)
# Acquire a single capture
data = ds.acquire_single()
# Data is a pandas DataFrame with time, ch1, ch2 columns
print(data.head())
# Close the device when done
ds.close()
Example for repeated acquisitions:
ds = DigiScope()
# Configure oscilloscope parameters
params = {...}
# Apply configuration
ds.configure_all(params)
# Acquire a single capture
data = ds.acquire_series(10, verbose=1)
# Data is a pandas DataFrame with time, ch1, ch2 columns
print(data.head())
# Close the device when done
ds.close()
Using the GUI
The library includes a real-time visualization interface for monitoring oscilloscope data:
from DwfInterface import DigiScope
from DwfInterface.DigiScopeGraph import OscilloscopeUI
import sys
from PyQt5.QtWidgets import QApplication
# Initialize Qt application in main thread
app = get_qt_app()
# Create DigiScope instance
ds = DigiScope()
ds.configure_all(my_params)
# Create UI (will now show the main window)
ds.graph()
print("UI should be visible now. Starting data acquisition...")
# Start acquiring data in a background thread
def run_acquisition():
# Wait briefly for UI to initialize
time.sleep(0.5)
# Acquire continuous data
ds.acquire_continuous()
acquisition_thread = threading.Thread(target=run_acquisition)
acquisition_thread.daemon = True
acquisition_thread.start()
# This blocks until the window is closed
print("Running Qt event loop in main thread. Close window to exit.")
sys.exit(app.exec_())
The GUI displays real-time waveforms from both channels with the following features:
- Live updating plots for Channel 1 and Channel 2
- Auto-scaling for optimal signal viewing
- Synchronized x-axis between both channels
- Efficient rendering with configurable sample downsampling
Recommended Usage: Jupyter Notebook
For interactive development and experimentation, I recommend using dwfpy_ux within Jupyter notebooks which provides a convenient environment for configuring and controlling your Digilent oscilloscope:
import sys
import os
# Import from package
from DwfInterface import DigiScope
# Import required constants
from DwfInterface.dwfconstants import DwfAnalogCouplingDC
# Create a DigiScope instance
ds = DigiScope()
# Configure oscilloscope parameters
params = {....
}
ds.configure_all(params)
# Launch the UI within Jupyter
ds.jupyter_graph()
# Start continuous acquisition
# (this will show live data in the graph window)
ds.acquire_continuous()
# Alternatively, capture a series of acquisitions
series = ds.acquire_series(20)
The jupyter_graph() method integrates the Qt event loop with Jupyter's event loop, allowing you to interact with both the notebook and the oscilloscope UI simultaneously.
License
None
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dwfpy_ux-0.3.10.tar.gz.
File metadata
- Download URL: dwfpy_ux-0.3.10.tar.gz
- Upload date:
- Size: 26.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e769d9c05f225638489549f5d3752acad9a0273a42e29fafe3e90e1db4c59bb7
|
|
| MD5 |
a055c7f8c493ca132914a8c14e6ac62c
|
|
| BLAKE2b-256 |
49f5d0903e3522d50cf0e927b7d0ab6ba26da53ab392381d28c889e9bc1aaa3f
|
File details
Details for the file dwfpy_ux-0.3.10-py3-none-any.whl.
File metadata
- Download URL: dwfpy_ux-0.3.10-py3-none-any.whl
- Upload date:
- Size: 28.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f1e5f3370779ed0a14d13169a5d06d4dffac2b0ea87578b0543b4cf0d4bfb70
|
|
| MD5 |
a93321af251394e3e666b2206552fff1
|
|
| BLAKE2b-256 |
36418aeb78c7d85bbf4711cee1a5c8e8bb3eca774ff0fcdea9d5cc9fc5b37ac2
|