Skip to content

clausqr/pps-gen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPS PPS + LIDAR Signal Generator for HIL development and testing.

ESP32-based Ground Support Equipment (GSE) for Hardware-in-the-Loop (HIL) development and testing of subsystems that process PPS and LIDAR data

This project provides a cost-effective GSE solution using ESP32 microcontroller to generate timing signals for HIL testing of subsystems that process PPS and LIDAR data:

  • PPS Signal: 1Hz Pulse Per Second with 100ms pulse width for GPS time synchronization
  • LIDAR Signal: 20Hz with configurable Gaussian jitter for realistic sensor timing variations
  • Configurable Parameters: Easy modification of timing values for different HIL testing scenarios

PPS and LIDAR Signals

Purpose: HIL Testing GSE

This signal generator serves as Ground Support Equipment (GSE) for Hardware-in-the-Loop (HIL) testing of subsystems without requiring actual GPS and LIDAR hardware:

  • HIL Testing: Test complete subsystems in a controlled environment with simulated sensor inputs
  • Hardware Integration: Validate subsystem hardware interfaces and timing requirements in HIL setup
  • Jitter Testing: Simulate realistic sensor timing variations for subsystem validation
  • Integration Testing: Test complete subsystem behavior with simulated signals in HIL environment
  • Cost-Effective HIL: Avoid expensive GPS and LIDAR hardware during HIL development and testing

Key Features

  • Hardware-based signal generation using ESP32 LEDC for precise timing
  • Configurable Gaussian jitter for realistic LIDAR timing variations
  • Dual independent signals with separate GPIO outputs
  • Easy configuration through compile-time parameters
  • PlatformIO/ESP-IDF compatible for straightforward development

HIL Testing Use Cases

This GSE is designed for Hardware-in-the-Loop (HIL) testing scenarios where you need to process PPS and LIDAR data:

  • HIL Subsystem Testing: Test complete subsystems in controlled HIL environment with simulated sensor inputs
  • Hardware Integration: Validate subsystem hardware interfaces and signal processing capabilities in HIL setup
  • Timing Synchronization: Validate subsystem timing requirements and synchronization behavior in HIL environment
  • Jitter Handling: Test subsystem response to realistic sensor timing variations in HIL testing
  • HIL Integration Testing: Validate complete subsystem behavior without real GPS/LIDAR hardware in HIL environment
  • Performance Testing: Measure subsystem performance with consistent timing inputs in HIL setup
  • Interface Validation: Test subsystem communication protocols and data handling in HIL environment

Technical Implementation

The GSE uses ESP32 hardware for reliable signal generation:

  • PPS Signal: ESP32 LEDC hardware PWM for consistent 1Hz timing
  • LIDAR Signal: ESP32 hardware timers with configurable Gaussian jitter for realistic variations
  • Independent Operation: Separate LEDC timers prevent signal interference
  • Configurable Parameters: Easy adjustment of timing and jitter through code constants

How It Works

The code uses a hybrid approach for signal generation:

  1. PPS Signal (1Hz)

    • Uses LEDC_TIMER_0 and LEDC_CHANNEL_0
    • Configured in LOW_SPEED_MODE (sufficient for 1Hz)
    • Output on GPIO 4
    • 100ms pulse width (10% duty cycle)
    • Hardware PWM for precise timing
  2. LIDAR Signal (20Hz) with Jitter

    • Uses hardware timer (GPTimer) for precise timing
    • Output on GPIO 21
    • 5ms pulse width with 1μs resolution
    • Configurable Gaussian jitter for realistic timing variations
    • Each pulse has independent random timing variation

Both signals use hardware-based generation for maximum precision and efficiency.

Why This Design?

  1. Hardware-Based Approach for Maximum Performance

    • PPS signal: Hardware PWM for maximum precision (GPS synchronization)
    • LIDAR signal: Hardware timer (GPTimer) for precise timing with configurable jitter
    • Both signals use dedicated hardware for optimal performance
  2. Jitter Implementation

    • Gaussian distribution for realistic timing variations
    • Configurable mean and standard deviation
    • Clamping to prevent extreme values
    • Independent jitter for each pulse
    • Hardware timer ensures precise timing even with jitter
  3. Configurable Parameters

    • All timing parameters are defined at the top of the file
    • Jitter parameters easily adjustable
    • No need to change code logic for different timing requirements

Customization

Changing Signal Parameters

All timing parameters are defined at the top of src/main.c:

// Timing parameters
#define PPS_FREQ_HZ 1        // PPS frequency in Hz
#define PPS_PULSE_MS 100     // PPS pulse width in milliseconds
#define LIDAR_FREQ_HZ 20     // LIDAR frequency in Hz
#define LIDAR_PULSE_MS 5     // LIDAR pulse width in milliseconds

// Jitter configuration for LIDAR pulse
#define LIDAR_JITTER_ENABLED 1           // Enable/disable jitter (1=enabled, 0=disabled)
#define LIDAR_JITTER_MEAN_MS 0.0         // Mean jitter in milliseconds (0.0 = no bias)
#define LIDAR_JITTER_STDDEV_MS 0.5       // Standard deviation of jitter in milliseconds
#define LIDAR_JITTER_MAX_MS 2.0          // Maximum jitter value in milliseconds (clamping)

// Pulse polarity configuration
#define PPS_POLARITY_ACTIVE_HIGH 1       // PPS pulse polarity (1=active high, 0=active low)
#define LIDAR_POLARITY_ACTIVE_HIGH 1     // LIDAR pulse polarity (1=active high, 0=active low)

Changing GPIO Pins

Pin assignments can be modified in the pin definitions:

#define PPS_PIN GPIO_NUM_4
#define LIDAR_PIN GPIO_NUM_19

Jitter Configuration

The LIDAR signal includes configurable random jitter for realistic timing variations:

  • LIDAR_JITTER_ENABLED: Set to 1 to enable jitter, 0 to disable
  • LIDAR_JITTER_MEAN_MS: Mean jitter value (0.0 = no bias)
  • LIDAR_JITTER_STDDEV_MS: Standard deviation of jitter (controls variation amount)
  • LIDAR_JITTER_MAX_MS: Maximum jitter value (prevents extreme timing)

Example configurations:

  • No jitter: LIDAR_JITTER_ENABLED 0
  • Small jitter: LIDAR_JITTER_STDDEV_MS 0.5 (0.5ms standard deviation)
  • Large jitter: LIDAR_JITTER_STDDEV_MS 2.0 (2.0ms standard deviation)
  • Biased jitter: LIDAR_JITTER_MEAN_MS 1.0 (1ms positive bias)

Pulse Polarity Configuration

Both PPS and LIDAR signals support configurable polarity:

  • PPS_POLARITY_ACTIVE_HIGH: Set to 1 for active-high pulses, 0 for active-low
  • LIDAR_POLARITY_ACTIVE_HIGH: Set to 1 for active-high pulses, 0 for active-low

Example configurations:

  • Active-high pulses (default): PPS_POLARITY_ACTIVE_HIGH 1, LIDAR_POLARITY_ACTIVE_HIGH 1
  • Active-low pulses: PPS_POLARITY_ACTIVE_HIGH 0, LIDAR_POLARITY_ACTIVE_HIGH 0
  • Mixed polarity: PPS active-high, LIDAR active-low

Duty Cycle Calculation

The duty cycle is automatically calculated based on the frequency and pulse width:

#define PPS_DUTY ((PPS_PULSE_MS * PPS_FREQ_HZ * (1 << LEDC_RESOLUTION)) / 1000)```

## Quick Start

### Hardware Requirements

- **ESP32 Development Board** (ESP32, ESP32-S2, ESP32-S3, or ESP32-C3)
- **USB Cable** for programming and power
- **Oscilloscope or Logic Analyzer** for signal verification (optional)
- **Breadboard and Jumper Wires** for connections

### Software Requirements

- **PlatformIO IDE** (recommended) or **ESP-IDF**
- **Git** for cloning the repository
- **ESP32 Toolchain** (automatically installed with PlatformIO)

### Installation and Setup

1. **Clone the repository**:
   ```bash
   git clone https://github.com/yourusername/pps-gen.git
   cd pps-gen
  1. Open in PlatformIO:

    • Install PlatformIO IDE or use PlatformIO Core
    • Open the project folder
  2. Build and Upload:

    platformio run --target upload
  3. Monitor Output (optional):

    platformio device monitor

Signal Verification

PPS Signal (GPIO 4):

  • Frequency: 1.000 Hz (exact)
  • Pulse Width: 100ms
  • Duty Cycle: 10%
  • Polarity: Configurable (active high/low)

LIDAR Signal (GPIO 21):

  • Frequency: 20 Hz (with configurable jitter)
  • Pulse Width: Configurable duty cycle
  • Jitter: Gaussian distribution with configurable parameters
  • Polarity: Configurable (active high/low)

Testing with Oscilloscope

  1. Connect probes to GPIO 4 (PPS) and GPIO 21 (LIDAR)
  2. Verify PPS timing: Should show exactly 1.000 Hz with 100ms pulses
  3. Test LIDAR jitter: Enable jitter and observe timing variations
  4. Measure accuracy: Use high-resolution oscilloscope for microsecond precision verification

Troubleshooting

  • If signals are not appearing, check:
    • GPIO pin connections
    • Power supply to ESP32
    • Serial monitor for any error messages
  • If timing is inaccurate:
    • Verify the ESP32's clock configuration
    • Check for any interference on the GPIO pins
  • If jitter behavior is unexpected:
    • Verify jitter parameters are within reasonable ranges
    • Check that LIDAR_JITTER_MAX_MS is not too restrictive
    • Ensure LIDAR_JITTER_STDDEV_MS is positive

Technical Specifications

Parameter PPS Signal LIDAR Signal
Frequency 1.000 Hz 20 Hz (base)
Pulse Width 100ms Configurable
Duty Cycle 10% Configurable
GPIO Pin GPIO 4 GPIO 21
Timing Precision Hardware PWM Hardware Timer
Jitter None Gaussian (configurable)
Polarity Configurable Configurable

GSE Performance

  • Timing Accuracy: Consistent timing suitable for software development and testing
  • Jitter Simulation: Gaussian distribution with configurable parameters for realistic testing
  • Low Cost: ESP32-based solution for cost-effective development
  • Easy Setup: Simple configuration and deployment for development environments
  • Reliable Operation: Hardware-based timing ensures consistent signal generation

Advanced Configuration

Jitter Parameters

The LIDAR signal supports sophisticated jitter modeling:

#define LIDAR_JITTER_ENABLED 1           // Enable/disable jitter
#define LIDAR_JITTER_MEAN_MS 0.0         // Mean jitter (bias)
#define LIDAR_JITTER_STDDEV_MS 5.0       // Standard deviation
#define LIDAR_JITTER_MAX_MS 15.0         // Maximum jitter (clamping)

Development Configuration

  • Hardware PWM: Reliable PPS signal generation
  • ESP Timer: Precise LIDAR timing with jitter simulation
  • Independent Channels: Separate signal generation without interference
  • Easy Configuration: Adjustable parameters for different testing scenarios

License

This project is open source and available under the MIT License.

Contributing

Contributions are welcome! This GSE project follows embedded systems best practices:

  • Clean Code: Allman bracket style, comprehensive documentation
  • Modular Design: Deterministic, no heap allocation
  • Hardware Focus: Direct hardware control for reliable operation
  • Testing: Hardware verification with oscilloscope recommended

Development Guidelines

  • Follow ESP32/ESP-IDF coding standards
  • Document all functions with purpose and behavior
  • Use hardware-based solutions for consistent operation
  • Test with actual hardware and oscilloscope verification

Keywords

ESP32, PPS, LIDAR, signal generator, GSE, ground support equipment, HIL testing, hardware-in-the-loop, subsystem development, GPS synchronization, embedded systems, timing simulation, hardware PWM, ESP-IDF, PlatformIO, Gaussian jitter, sensor testing, data processing, subsystem integration, hardware testing, signal processing subsystems, HIL development

About

ESP32-based Ground Support Equipment (GSE) for Hardware-in-the-Loop (HIL) development and testing of subsystems that process PPS and LIDAR data. Hardware PWM and timer implementation for reliable timing simulation.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors