Skip to main content
Version: FILS English

Simulated Automotive ECU & Trip Computer

This project simulates the core functions of a car's Engine Control Unit and Trip Computer, providing interactive, real-time feedback.

info

Author: MATEI Cosmin-Alecsandru – Group 1222EB
GitHub Project Link: https://github.com/UPB-PMRust-Students/project-kozmy410

Description

This project simulates the core functions of a car's Engine Control Unit (ECU) and Trip Computer. It provides interactive, real-time feedback by dynamically calculating engine operational parameters like fuel injection and ignition timing based on simulated driver input (accelerator position via a potentiometer) and engine conditions (simulated RPM via a DC motor/Hall sensor, and temperature/environmental data via I2C sensors). The system visualizes these engine control actions (e.g., using LEDs for injectors/ignition) and displays key performance metrics and trip data on an I2C display, demonstrating the fundamental logic loops within automotive electronic control systems using embedded Rust and the Embassy framework.

Motivation

The primary motivation behind this project is to gain hands-on experience with embedded systems development using Rust, particularly focusing on real-time data acquisition, processing, and control loops common in automotive applications. It serves as a practical platform to understand the fundamental principles of an Engine Control Unit and Trip Computer, integrating various sensors and actuators, and implementing asynchronous tasks using the Embassy framework on the Raspberry Pi Pico W. Furthermore, it aims to create a tangible, interactive demonstration of these concepts.

Architecture

The system architecture is designed around the Embassy async framework running on the Raspberry Pi Pico W. It comprises several concurrent tasks:

  1. Input Acquisition Task(s):

    • Reads the accelerator position from the potentiometer via ADC.
    • Polls I2C sensors (BMP180, HTU21) for temperature, pressure, and humidity data.
    • Monitors the Hall Effect sensor input (likely via GPIO interrupts and timers) to calculate RPM from the simulated engine (DC motor).
    • Reads user input from the capacitive touch sensor (I2C) or tactile buttons (GPIO).
    • (Optional) Checks for RFID tags via the RC522 module (SPI).
    • These tasks publish sensor readings and input events to other tasks, potentially using Embassy's sync channels or signals.
  2. RPM Simulation Task:

    • Controls the speed of the DC motor using PWM, potentially influenced by the accelerator position input, to simulate varying engine speeds.
  3. ECU Logic Task:

    • Receives processed inputs (RPM, accelerator position, temperature, etc.).
    • Applies control logic (e.g., simplified lookup tables or algorithms) to determine simulated fuel injection timing/duration and ignition timing.
    • Calculates performance metrics (e.g., simulated fuel consumption).
  4. Output & Display Task(s):

    • Updates the I2C display with current data (RPM, temperature, trip information, status messages).
    • Controls status LEDs based on system state.
    • Pulses specific LEDs to simulate injector firing and ignition events based on timing calculated by the ECU Logic Task.
    • Updates the 12-segment LED bar graph to visualize a selected metric (e.g., RPM or engine load).
    • Handles UI interactions based on inputs received (e.g., switching display modes, resetting trip data).

These tasks communicate asynchronously, allowing for responsive input handling, continuous simulation, and timely output updates without blocking execution.

Log

Will be added when I'll have my todo list sorted by date

Hardware

The core of the system is a Raspberry Pi Pico 2 W microcontroller. Inputs include a potentiometer simulating the accelerator pedal, various sensors (temperature, pressure, humidity), and potentially RFID for user identification. Engine RPM is simulated using a small DC motor coupled with a digital Hall effect sensor and magnet(s), driven by a motor driver module. Outputs consist of an I2C display (LCD or OLED) for showing data, LEDs (individual and bar graph) indicating injector firing, ignition events, status, and potentially other metrics, along with current limiting resistors for the LEDs. Prototyping components like breadboards, jumper wires, and a USB cable are also used. A dedicated power supply is required for the motor.

Schematics

Diagram v2

I know there should be a better schematic here but it is not ready now, sorry (blurry because of the size restrictions)

Bill of Materials

DeviceUsagePrice
Raspberry Pi Pico 2 WThe microcontroller-
Small DC MotorSimulates engine rotation for RPM generation-
Digital Hall Effect SensorDetects motor rotation via magnet(s) for RPM-
Magnet(s)Used with Hall Effect Sensor for RPM detection-
Motor Driver ModuleControls the DC motor speed-
Dedicated Power SupplyPowers the DC motor (shared GND with Pico)-
PotentiometerSimulates the Accelerator Pedal input-
BMP180 Temperature and Pressure SensorMeasures temperature and potentially ambient pressure-
GY-21 HTU21 Sensor ModuleMeasures temperature and humidity-
MPR121 / TP229 Capacitive Touch SensorAlternative user input (replacing/augmenting buttons)-
Tactile Push ButtonsUser input (e.g., reset trip, cycle displays)-
20x4 Blue LCDOutputs system status, metrics, trip data-
LEDsVisual indicators (Injectors, Ignition, Status)-
12 Segment LED Bar (4 Red, 8 Green)Visual indicator for a metric (e.g., RPM, load, temp)-
RFID module RC522User identification / profile loading (optional feature)-
Current Limiting ResistorsProtect LEDs-
Breadboard(s)Prototyping circuit construction-
Assorted Jumper WiresConnecting components on the breadboard-

Software

Library/CrateDescriptionUsage
embassy-executorAsync executorRunning concurrent tasks (sensor reading, control, UI)
embassy-timeTime-related utilities for asyncDelays, timeouts, scheduling
embassy-rpHAL for RP2040Accessing peripherals (GPIO, I2C, PWM, ADC, SPI)
embassy-syncAsync synchronization primitivesMutexes, channels for safe data sharing between tasks
Specific I2C DriverDriver for chosen I2C devicesReading data via I2C
defmtEfficient logging frameworkDebugging and logging output
panic-probe / panic-haltPanic handlerHandling program crashes
  1. Embassy Framework
  2. Raspberry Pi Pico Documentation
  3. Awesome Embedded Rust