← Back to Home

⚡ Quick Start - VR Simulator

Start here if you're new to the project.

5-Minute Project Overview

The VR Simulator is an ESP32 firmware that generates realistic automotive variable reluctance crank sensor signals. It outputs authentic Subaru 36-2-2-2 waveforms that can be used for ECU testing, signal conditioning validation, or sensor simulation.

Key Point: Once running, the simulator generates signals automatically with zero CPU overhead using DMA (Direct Memory Access).

Architecture Diagram

┌─────────────────────────────────────────────────────┐
│  ESP32 VR Simulator                                 │
├─────────────────────────────────────────────────────┤
│                                                     │
│  GPIO4 (PWM Input)  ──→  Frequency Detector        │
│                           ↓                         │
│                      Waveform Generator             │
│                           ↓                         │
│  GPIO25 (VR+) ◄──────── DMA Pipeline ──→ GPIO26    │
│                       (48 kHz, 8-bit)   (VR-)       │
│                                                     │
│  UART0 ──→ Serial Console (115200 baud)            │
└─────────────────────────────────────────────────────┘
        

How-To: Building and Running

Prerequisites

Build Steps

  1. Clone or download the project
  2. Open a terminal in the project root
  3. Run: pio run
  4. Connect your ESP32 via USB
  5. Run: pio run -t upload

Monitor Output

pio device monitor --baud 115200

You should see RPM updates every second:

[FREQ] 50.00 Hz | RPM: 1500
[FREQ] 50.00 Hz | RPM: 1500
[FREQ] 50.00 Hz | RPM: 1500

Common Tasks

View the Waveform

Connect an oscilloscope to GPIO25 (VR+) and GPIO26 (VR-) to see the differential signals. The waveform shows realistic sinusoidal teeth with compression-based modulation.

Change the RPM

Connect a PWM signal generator to GPIO4:

The simulator will automatically regenerate the waveform to match the input frequency.

Generate Test Plots

python plot_vr_signals.py

Creates a comparison plot of signals at 1500 and 3000 RPM.

Troubleshooting Quick Reference

Problem Solution
Build fails with "esp-idf not found" Run pio run -c -e esp32 to rebuild everything
No signal on GPIO25/26 Check oscilloscope ground connection and ESP32 power
RPM not updating from GPIO4 Verify PWM frequency is 20-200 Hz and signal is 3.3V compatible
Serial monitor shows garbage Ensure baud rate is set to 115200

What's Next?

Once you have the basic firmware running:

Pro Tip: The DMA pipeline does all the heavy lifting. CPU usage stays below 1% once initialization is complete.