Skip to content

BaseMax/qt-signal-analyzer

Repository files navigation

Qt Signal Analyzer

A professional desktop GUI application for real-time hardware signal analysis. Built with Python, PyQt5, and PyQtGraph.

License Python

Features

  • Real-time Signal Monitoring: Monitor voltage, current, frequency, and power signals in real-time
  • Serial Port Communication: Read data from hardware devices via serial ports
  • JSON Frame Parsing: Parse JSON-formatted data frames from hardware
  • Live Visualization: Real-time plotting using PyQtGraph with professional dark theme
  • Threshold Management: Configure min/max thresholds for each signal type
  • Violation Detection: Automatic detection and logging of threshold violations
  • Test Sessions: Start/stop test sessions with pass/fail status tracking
  • SQLite Storage: Persistent storage of all readings, violations, and test sessions
  • Report Export: Export test reports in both TXT and HTML formats
  • Demo Mode: Built-in demo mode with mock data for testing without hardware
  • Modular Architecture: Clean, well-documented code with separation of concerns

Screenshots

Main Interface

Qt Signal Analyzer

The application features a professional dark theme with real-time plots for all signals:

  • Voltage Plot (green): Real-time voltage monitoring
  • Current Plot (orange): Real-time current monitoring
  • Frequency Plot (cyan): Real-time frequency monitoring
  • Power Plot (magenta): Real-time power monitoring (calculated as V × I)

The interface includes:

  • Connection controls for serial port configuration
  • Test session management (Start/Stop/Pass/Fail)
  • Tabbed interface for plots, thresholds, and violations
  • Status bar with real-time statistics
  • Export functionality for generating reports

Installation

Prerequisites

  • Python 3.7 or higher
  • pip package manager

Install Dependencies

pip install -r requirements.txt

Dependencies

  • PyQt5 >= 5.15.0 - GUI framework
  • pyqtgraph >= 0.13.0 - High-performance plotting library
  • pyserial >= 3.5 - Serial port communication

Usage

Quick Start

The fastest way to see the application in action:

# Install dependencies
pip install -r requirements.txt

# Run the example demonstration (no GUI required)
python example.py

# Launch the GUI application
python main.py

# Click "Demo Mode" to see real-time visualization with simulated data

Running the Application

python main.py

Connecting to Hardware

  1. Click "Refresh Ports" to scan for available serial ports
  2. Select your serial port from the dropdown
  3. Configure the baud rate (default: 9600)
  4. Click "Connect" to establish connection

Demo Mode

To test the application without hardware:

  1. Click "Demo Mode" button
  2. The application will generate realistic mock data
  3. All features will work normally with the simulated data

Starting a Test Session

  1. Click "Start Test" to begin a new test session
  2. All readings and violations will be recorded
  3. Click "Pass" or "Fail" to conclude the test with a result
  4. Or click "Stop Test" to end without a pass/fail result

Configuring Thresholds

  1. Navigate to the "Thresholds" tab
  2. Set minimum and maximum values for each signal type
  3. Use the checkboxes to enable/disable specific thresholds
  4. Violations are detected automatically when values exceed thresholds

Viewing Violations

  1. Navigate to the "Violations" tab
  2. All threshold violations are logged with timestamps
  3. Click "Clear Violations" to reset the violation list

Exporting Reports

  1. Click "Export Report" button
  2. Choose between TXT or HTML format
  3. Select save location
  4. Report includes session info, statistics, and violations

Data Format

JSON Input Format

The application expects JSON frames via serial port in this format:

{
    "voltage": 5.0,
    "current": 1.2,
    "frequency": 60.0
}

Required Fields:

  • voltage (float): Voltage reading in Volts
  • current (float): Current reading in Amperes
  • frequency (float): Frequency reading in Hertz

Derived Metrics:

  • power (float): Automatically calculated as voltage × current

Architecture

Module Overview

qt-signal-analyzer/
├── main.py                 # Main GUI application and entry point
├── models.py               # Data models and business logic
├── database.py             # SQLite database layer
├── serial_reader.py        # Serial port communication
├── report_generator.py     # Report export functionality
├── requirements.txt        # Python dependencies
└── README.md              # This file

Key Components

models.py

  • SignalReading: Represents a single signal measurement
  • Threshold: Defines min/max boundaries for signals
  • ThresholdViolation: Records when thresholds are exceeded
  • TestSession: Manages test session lifecycle and metadata

database.py

  • Database: Handles all SQLite operations
  • Stores readings, violations, and session data
  • Provides query methods for retrieving historical data

serial_reader.py

  • SerialReader: QThread for reading from serial ports
  • MockSerialReader: Generates simulated data for testing
  • JSON frame parsing and validation
  • Signal-based communication with GUI

report_generator.py

  • ReportGenerator: Static methods for report generation
  • TXT format: Plain text with statistics and violations
  • HTML format: Styled report with color-coded status

main.py

  • SignalAnalyzerMainWindow: Main application window
  • Real-time plotting with PyQtGraph
  • Threshold violation detection
  • Test session management
  • Dark theme styling

Database Schema

Tables

test_sessions

  • id (INTEGER PRIMARY KEY)
  • start_time (TEXT)
  • end_time (TEXT)
  • status (TEXT)
  • total_readings (INTEGER)
  • total_violations (INTEGER)
  • notes (TEXT)

signal_readings

  • id (INTEGER PRIMARY KEY)
  • session_id (INTEGER FOREIGN KEY)
  • timestamp (TEXT)
  • voltage (REAL)
  • current (REAL)
  • frequency (REAL)
  • power (REAL)

threshold_violations

  • id (INTEGER PRIMARY KEY)
  • session_id (INTEGER FOREIGN KEY)
  • timestamp (TEXT)
  • signal_type (TEXT)
  • value (REAL)
  • min_threshold (REAL)
  • max_threshold (REAL)

Development

Code Style

  • PEP 8 compliant
  • Type hints where applicable
  • Comprehensive docstrings
  • Modular design with single responsibility principle

Adding New Features

The modular architecture makes it easy to extend:

  1. New Signal Types: Add to SignalType enum in models.py
  2. New Report Formats: Add static methods to ReportGenerator
  3. New Data Sources: Subclass from QThread like SerialReader
  4. New Visualizations: Add plot widgets in main.py

Troubleshooting

No Serial Ports Found

  • Ensure device is connected
  • Check driver installation (especially for USB-to-serial adapters)
  • Run application with appropriate permissions (may need sudo on Linux)
  • Try clicking "Refresh Ports"

Connection Errors

  • Verify correct baud rate
  • Check that port isn't already in use by another application
  • Ensure device is sending data in expected JSON format

Plot Performance

  • Reduce max_points in main.py if experiencing lag
  • Close other resource-intensive applications
  • Consider reducing data transmission rate from hardware

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Authors

  • BaseMax

Acknowledgments

  • PyQt5 for the excellent GUI framework
  • PyQtGraph for high-performance plotting
  • Python community for amazing libraries

About

Real-time hardware signal analyzer with serial input, plots, thresholds, and test reports. Built with Python, PyQt5, and PyQtGraph.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages