instruments

star 0

LAN-based SCPI instrument control for Rigol DHO924 oscilloscope and DG852 Pro signal generator. Use when you need to configure, measure, capture waveforms, take screenshots, or automate test sequences involving bench instruments over the local network.

ckdfs By ckdfs schedule Updated 3/10/2026

name: instruments description: LAN-based SCPI instrument control for Rigol DHO924 oscilloscope and DG852 Pro signal generator. Use when you need to configure, measure, capture waveforms, take screenshots, or automate test sequences involving bench instruments over the local network.

Instruments

Overview

Control Rigol bench instruments over LAN using raw SCPI (TCP port 5555). No NI-VISA or proprietary drivers required — pure Python via socket.

Supported Instruments

Class Instrument File
DHO924 Rigol DHO924 oscilloscope tools/instruments/dho924.py
DG852 Rigol DG852 Pro signal gen tools/instruments/dg852.py

Dependency

pip install pyvisa pyvisa-py   # optional — raw socket transport used by default

Only pyserial and stdlib are strictly needed; pyvisa not required.

Usage — Oscilloscope (DHO924)

from tools.instruments.dho924 import DHO924

with DHO924("192.168.1.101") as scope:
    print(scope.idn())
    scope.autoscale()

    scope.set_timebase(1e-3)           # 1 ms/div
    scope.set_channel_scale(1, 1.0)    # CH1: 1 V/div
    scope.set_channel_coupling(1, "DC")
    scope.set_trigger(source=1, level=1.0, slope="POS")
    scope.run()

    # Measurements
    freq = scope.measure_freq(ch=1)
    vpp  = scope.measure_vpp(ch=1)
    print(f"Freq: {freq:.1f} Hz  Vpp: {vpp:.3f} V")

    # Save screenshot
    scope.screenshot("reports/scope_capture.png")

    # Download waveform data
    times, volts = scope.get_waveform(channel=1)

Usage — Signal Generator (DG852)

from tools.instruments.dg852 import DG852

with DG852("192.168.1.102") as gen:
    print(gen.idn())

    # CH1: 1 kHz sine, 1 Vpp
    gen.sine(ch=1, freq=1e3, amp=1.0, offset=0.0)
    gen.output_on(1)

    # CH2: 10 kHz square, 3.3 Vpp, 50% duty
    gen.square(ch=2, freq=10e3, amp=3.3, offset=1.65, duty=50.0)
    gen.output_on(2)

    # Frequency sweep on CH1
    gen.sweep(ch=1, start=100, stop=10e3, time_s=1.0)

    # Turn off
    gen.output_off(1)
    gen.output_off(2)

Architecture

tools/instruments/
  __init__.py          # exports DHO924, DG852
  scpi_client.py       # raw TCP socket SCPI transport (send/query/read_binary)
  dho924.py            # oscilloscope driver
  dg852.py             # signal generator driver

Operating Rules

  • Both instruments must have LAN enabled in their network settings.
  • Default TCP port is 5555 for all Rigol instruments.
  • Use context manager (with) to ensure connections are closed cleanly.
  • scope.stop() is called automatically before waveform download to freeze data.
  • Screenshots are PNG (DHO924 supports :DISPlay:DATA? ON,OFF,PNG).
  • SCPI commands follow Rigol's programming guide — use idn() to verify connection first.

Quick Connectivity Test

python -c "
from tools.instruments.dho924 import DHO924
from tools.instruments.dg852 import DG852
with DHO924('192.168.1.101') as s: print('Scope:', s.idn())
with DG852('192.168.1.102') as g: print('Gen:  ', g.idn())
"
Install via CLI
npx skills add https://github.com/ckdfs/mzmmainboard --skill instruments
Repository Details
star Stars 0
call_split Forks 0
navigation Branch main
article Path SKILL.md
More from Creator