Skip to main content

Simple library for Tektronix MSO4000 series oscilloscopes

Project description

MSO4000 Library

Simple, clean library for Tektronix MSO4000 series oscilloscopes.

Features

  • ✅ Connection checking
  • ✅ Single waveform capture
  • ✅ Multiple waveform recording to CSV
  • ✅ Simple, clean API

Installation

Install from PyPI:

pip install mso4000

Quick Start

1. Check Connection

from mso4000 import check_connection

success, info = check_connection()
if success:
    print(f"Connected: {info}")
else:
    print(f"Error: {info}")

2. Record Waveforms to CSV (One-liner)

from mso4000 import quick_record

# Record 10 waveforms and save to CSV
filename = quick_record(channel=1, max_records=10)
print(f"Saved to: {filename}")

3. Full Control

from mso4000 import MSO4000

# Create scope interface
scope = MSO4000(channel=1)

# Connect
if scope.connect():
    # Capture single waveform
    waveform = scope.capture_waveform()
    print(f"Captured {len(waveform)} samples")
    
    # Or record multiple to CSV
    filename = scope.record_to_csv(max_records=20)
    print(f"Saved to: {filename}")
    
    # Close connection
    scope.close()

API Reference

MSO4000 Class

__init__(channel=1)

Initialize the oscilloscope interface.

Parameters:

  • channel (int): Channel number (1-4), default 1

check_connection() -> Tuple[bool, Optional[str]]

Check if oscilloscope is connected.

Returns:

  • (True, device_info) if connected
  • (False, error_message) if not connected

connect() -> bool

Connect to oscilloscope and configure for waveform transfer.

Returns:

  • True if successful
  • False if failed

capture_waveform() -> Optional[np.ndarray]

Capture a single waveform.

Returns:

  • numpy.ndarray of voltage values, or None if failed

record_to_csv(filename=None, max_records=None, delay=0.5) -> Optional[str]

Record multiple waveforms and save to CSV.

Parameters:

  • filename (str, optional): Output filename (auto-generated if None)
  • max_records (int, optional): Maximum waveforms to record (None = until Ctrl+C)
  • delay (float): Delay between captures in seconds (default 0.5)

Returns:

  • Filename of saved CSV, or None if failed

close()

Close connection to oscilloscope.

Convenience Functions

check_connection() -> Tuple[bool, Optional[str]]

Quick function to check connection.

quick_record(channel=1, max_records=None, filename=None) -> Optional[str]

Quick function to connect and record waveforms.

Parameters:

  • channel (int): Channel number (1-4)
  • max_records (int, optional): Maximum waveforms (None = until Ctrl+C)
  • filename (str, optional): Output filename (auto-generated if None)

Returns:

  • Filename of saved CSV, or None if failed

CSV Output Format

The CSV file contains:

  • Column 1: Sample index (0 to N-1)
  • Column 2: Time in seconds (relative to waveform start)
  • Columns 3+: Voltage values for each recorded waveform

Example:

Sample_Index,Time_sec,Waveform_1_V,Waveform_2_V,Waveform_3_V
0,0.000000,-0.123456,0.234567,-0.345678
1,0.000010,-0.125432,0.236789,-0.347890
...

Examples

See example_mso4000.py for complete examples.

Requirements

  • Python 3.6+
  • pyvisa
  • numpy

Notes

  • The library automatically selects USB resources (skips serial ports)
  • Uses binary encoding (RIBINARY) for efficient data transfer
  • Default timeout is 30 seconds for waveform transfers
  • Press Ctrl+C to stop recording

License

MIT License - See LICENSE file for details

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

mso4000-0.1.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

mso4000-0.1.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file mso4000-0.1.0.tar.gz.

File metadata

  • Download URL: mso4000-0.1.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for mso4000-0.1.0.tar.gz
Algorithm Hash digest
SHA256 97355cfc640b756c4ddd9613369a6554bce74aad477bbdda32d9f9ccf71b2c49
MD5 bf94485f61d234763bd445b1a66d0226
BLAKE2b-256 58ed287085c2e12cea469b4b572f638f073d7c7eb5cf941ee5b5651212d6c171

See more details on using hashes here.

File details

Details for the file mso4000-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mso4000-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for mso4000-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d212f7943b976b4883920cf8e4ed3b4129b6bb4eb8e2515de69f654f04340f4c
MD5 74aaaee559de839bb58f1a48ac07b9f4
BLAKE2b-256 58c26dc3bb123a5d3c0b1b14e5aef6274e0b9130dbe922047286caee30b96177

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