This repository contains the firmware for a custom STM32F405-based board designed to act as a man-in-the-middle speed limiter between an automotive accelerator pedal and the vehicle’s ECU.
The system reads vehicle speed from the CAN bus, monitors pedal input signals, and dynamically attenuates or cuts off the pedal output once speed thresholds are exceeded.
The custom PCB integrates: STM32F405RGT6 microcontroller DAC121S101 (x2) for pedal signal reconstruction (SPI) TCAN337 CAN transceiver USB-C for CANH/CANL connectivity UART headers for debugging (115200 baud) Multiplexer to route DAC outputs back to the ECU
-
Pedal → STM32 ADC Pedal signals are read through ADC channels (with voltage divider adjustment).
-
Speed Readout (CAN bus) Vehicle speed is requested and parsed from CAN frames via the TCAN337 transceiver.
-
Processing (Attenuation Algorithm)
- If speed < 20 km/h → pedal signal is passed directly.
- If 20–30 km/h → pedal signal is progressively attenuated.
- If ≥ 30 km/h → pedal input is effectively cut off.
-
STM32 → DAC → Multiplexer → ECU Processed signals are converted back to analog via DACs and routed through the multiplexer to the ECU.
- Normal Operation (< 20 km/h): Pedal signals are passed through unchanged.
- Scaling Region (20–30 km/h): Pedal signals are scaled down linearly.
- Cut-Off Region (≥ 30 km/h): Pedal signals are suppressed (ECU sees minimal input).
- Device Under Test (DUT) flashed with target firmware
- CAN bus interface adapter connected to OBD-II
- USB-to-UART serial adapter
- Terminal emulator configured for 115200 baud, 8N1
- Ensure vehicle ignition is OFF.
- Connect the DUT to the vehicle’s OBD-II port via CAN.
- Connect the DUT inline between pedal and ECU.
- Attach USB-to-UART adapter to the DUT debug header and open terminal (115200).
- Switch ignition to ON/RUN (engine not started).
- Confirm status LED is illuminated (board powered).
- Confirm UART session is active (ready to display CAN messages).
- Start the engine.
- Press pedal while stationary → verify normal engine response.
- Accelerate to just below 20 km/h.
- Confirm pedal works normally (no scaling yet).
- Cross 20 km/h threshold.
- Gradually accelerate toward 30 km/h.
- Confirm pedal sensitivity decreases progressively with speed.
- Maintain speed ≥ 30 km/h.
- Confirm pedal input is ignored (engine no longer responds to accelerator).
- Reduce speed below 30 km/h.
- Confirm pedal functionality returns to normal.