How tdmitchell787/hp8903 works
Project Type and Purpose
• This is a desktop Python-based instrumentation control application.
• It provides a GUI front end to automate sweep measurements on an HP 8903 Audio Analyzer via GPIB controllers.
File Structure
• Top‐level script: hp8903.py (the main application).
• hardware_tests/ directory with simple test scripts for supported GPIB controllers (galvant.py, nigpib232cva.py).
• No separate “src” or “lib” folders—most logic lives in hp8903.py, with hardware abstraction inside.
Review the README for Technical Stack
• Python 2.7+
• GUI: GTK3 via gobject
• Plotting: matplotlib
• Data handling: numpy
• Serial communication: pyserial
• Planned future support: pyvisa, additional controller plugins
Extract the Main Architectural Components
a. GUI Layer
• Built with GTK3/gobject, handles menus, parameter forms, “Connect”/“Start” buttons, status bar.
b. Application Controller
• Orchestrates user actions → triggers hardware commands and updates the view.
• Implements an MVC‐style controller.
c. Hardware Abstraction / Driver Layer
• Defines a common interface for GPIB controllers (Galvant, NI‐232CV-A, future Prologix/VISA).
• Each controller script (in hardware_tests) or class implements connect(), send(), receive().
d. Communication Layer
• Uses pyserial to communicate over the serial port to the GPIB adapter.
e. Data Acquisition Module
• Formats HP 8903 commands, sends them, reads raw binary/text responses.
f. Data Processing Module
• Uses numpy to parse and process raw measurement data (THD+n, amplitude vs. frequency).
• Manages filter control and sweep parameter calculations.
g. Visualization Module
• Uses matplotlib to plot time/frequency data and render THD+n vs. frequency graphs.
h. Persistence / I/O
• Saves raw data and plot images to disk (file‐system).
i. External Hardware
• HP 8903 Audio Analyzer
• GPIB controller devices
Relationships and Data Flows
• User clicks “Connect” in GUI → Controller calls Hardware Abstraction → Communication Layer opens serial to GPIB → GPIB adapter ↔ HP 8903.
• User starts a sweep → Controller → Data Acquisition → hardware → raw data back up → Data Processing → Visualization → GUI display.
• On demand, Persistence module writes data/images to disk.
• hardware_tests scripts bypass GUI and call Hardware Abstraction directly for low‐level testing.
Architectural Patterns
• Layered MVC‐style architecture for separation of concerns.
• Plugin/driver pattern for supporting multiple GPIB adapters.
• Clear modular boundaries: GUI, logic, hardware interfaces, processing, visualization.
Final Checklist
• All main components are present and clearly labeled.