Skip to main content

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.

DigiScope GUI Example

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

  1. Install the Digilent Waveforms SDK from Digilent's website
  2. 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:

DigiScope GUI Example

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dwfpy_ux-0.3.11.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dwfpy_ux-0.3.11-py3-none-any.whl (28.1 kB view details)

Uploaded Python 3

File details

Details for the file dwfpy_ux-0.3.11.tar.gz.

File metadata

  • Download URL: dwfpy_ux-0.3.11.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

Hashes for dwfpy_ux-0.3.11.tar.gz
Algorithm Hash digest
SHA256 63cb64093f3a371bd230b8e37b3493b27c0d5c7f03cbeaa39fa46731b6e371a5
MD5 7eba272e91362f1252c26ac8f422bdbc
BLAKE2b-256 a940ce2ebd1009a154f9fc6152a3cf5b2f1ef844acf64e7deeab8460ef5d309e

See more details on using hashes here.

File details

Details for the file dwfpy_ux-0.3.11-py3-none-any.whl.

File metadata

  • Download URL: dwfpy_ux-0.3.11-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

Hashes for dwfpy_ux-0.3.11-py3-none-any.whl
Algorithm Hash digest
SHA256 4361d1b21a4ec4c63446012113b34a75399a48b3d3dac0ec095b905884d763d3
MD5 e93bb58020f466c393cd72ff51427d49
BLAKE2b-256 bae0e95cdbf8500493b972016fd0ca3ac8772c84632fb175c07b5bf60942f164

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page