This project is a real-time Engine Control Unit (ECU) simulator written in C. It runs a detailed engine model and broadcasts live telemetry data via WebSockets to an interactive web-based dashboard.
It's designed to be a professional portfolio piece that demonstrates a deep understanding of embedded systems, control algorithms, and modern web integration for automotive applications.
The system consists of two main parts: a C-based backend that runs the core simulation and a frontend web dashboard for visualization and control. They communicate in real-time using WebSockets.
[ Web Dashboard (HTML/JS) ] <---(WebSocket)---> [ C Backend Server ]
|
V
[ ECU Core Logic ]
- PID Control
- Sensor Models
- CAN Bus Sim
- Safety Checks
- Real-time Engine Model: A state machine manages engine logic with a deterministic 100Hz (10ms) update loop.
- PID Control: Closed-loop PID controllers manage idle speed and air-fuel ratio.
- Sensor Simulation: Generates realistic data for sensors like throttle position, coolant temperature, and oil pressure.
- CAN Bus Communication: Simulates the transmission of CAN messages for vehicle network integration.
- Safety System: Includes over-rev protection, over-temperature limits, and other fault-handling logic.
- Live Telemetry Dashboard: Displays real-time data on responsive gauges and charts (RPM, Temp, etc.).
- Interactive Controls: An interactive throttle slider allows you to control the simulated engine load.
- Fault Injection: Buttons on the dashboard allow you to trigger diagnostic faults to test the ECU's safety logic.
- Data Logging: The web interface logs all incoming data to the browser console for inspection.
- Makefile Build System: A comprehensive
Makefilehandles building, testing, and packaging. - Unit Testing: A test suite validates the functionality of core ECU components.
- Memory Safety: Integrated support for running tests with Valgrind and AddressSanitizer.
- Static Analysis:
make analyzetarget runs static analysis checks to ensure code quality.
Ubuntu/Debian:
sudo apt-get install build-essential git
macOS:
xcode-select --install
Clone the repository, cd into the directory, and run the main command:
# This single command builds the C backend, starts the
# server, and serves the web interface.
make runOnce the server is running, open your browser and navigate to http://localhost:8080.
While make run is the fastest way to start, the Makefile provides several other useful targets for development:
| Command | Description |
|---|---|
make all |
Builds the production executable. |
make debug |
Builds a debug version with AddressSanitizer. |
make test |
Runs the automated unit test suite. |
make memcheck |
Runs the test suite under Valgrind for leak checks. |
make analyze |
Runs static code analysis. |
make clean |
Removes all build artifacts. |
- OBD-II Support: Add support for standard diagnostic trouble codes.
- Hardware-in-the-Loop (HIL): Create a mode to interface with real hardware.
- Cloud Integration: Stream telemetry to a cloud platform like AWS IoT for fleet analysis.
This project is licensed under the MIT License. See the LICENSE file for details.