---
# ⚡ ForgeDriveMC
A **modular, dual-platform** open-source firmware platform for **PMSM motor control** in electric vehicle applications.
Built for the **Cairo University Eco Racing Team** — validated in real-world racing.
[](LICENSE)
-blue)
---
ForgeDriveMC implements Field-Oriented Control (FOC) and Self-Commissioning (SComm) for PMSM drives with a clean hardware abstraction layer (eldriver) that runs identically on:
| Platform | Purpose | Toolchain |
|---|---|---|
| Host (x86) | SIL simulation, HIL testing, GUI dashboard | Native GCC + CMake |
| STM32F4 | Embedded deployment | GCC ARM Embedded + CMake |
- ⚙️ FOC (Field-Oriented Control) with SVM
- 🔬 SComm (Self-Commissioning) — HFI-based parameter identification
- 📊 Real-time Dashboard — ImGui/ImPlot GUI with scope, triggers, and analytics
- 🧪 SIL Simulation — Full PMSM electrical model with HDF5 logging
- 🔄 ABF Protocol — Asynchronous Binary Frame over USB-CDC/UART/TCP
- 📈 DAQ System — Internal Data Value (IDV) serialization for telemetry
| Directory | Contents |
|---|---|
application/ |
Main entry, PMSM control logic |
application/PmsmControl/ |
FOC, SComm, position drivers, types |
core/ |
Low-level utilities (rstream, smem, math) |
middleware/ |
ABF/IDV protocols, DAQ, scope stream |
platform/host/ |
Host eldrivers, SIL engine, GUI |
platform/stm32f4/ |
STM32F4 HAL, USB, FreeRTOS config |
ForgeTool/ |
PC utility for USB communication |
test/ |
SIL integration tests |
| Mode | Description | Status |
|---|---|---|
Foc |
Field-Oriented Control with Space Vector PWM | ✅ Active |
SComm |
Self-Commissioning (R, Ld, Lq identification via HFI) | ✅ Active |
Idle |
Safe state, motor disabled | ✅ Active |
pwmLoop() ─── PWM rate (e.g., 25 kHz)
├── Read ADC (phase currents, bus voltage)
├── Clarke/Park transforms
├── Current PI controllers (dq frame)
├── Inverse Park/Clarke
└── Write SVM duty cycles
xmcLoop() ─── Slow loop (~1 kHz)
├── Position/speed estimation
├── Speed/position PI controllers
└── Setpoint management
The Software-in-the-Loop engine models:
- PMSM electrical dynamics — saliency, mutual inductances, back-EMF
- Inverter non-idealities — dead-time, diode commutation, on/off resistance
- Discontinuity handling — sub-stepping for drive transitions
- HDF5 logging — compressed, chunked datasets with column metadata
Launch the GUI dashboard:
./build/bin/ForgeDriveMC- Sync byte + ServiceID + Payload + CRC-8 AUTOSAR
- MCOBS encoding for payload
- Supports UART, USB-CDC, and TCP transports
- Self-describing serialization for DAQ channels
- Auto-discovery with MARKER-based session/stream/channel hierarchy
This project is MIT licensed — see LICENSE for details.
Maintainer: Omar Magdy
📧 omar.magdy.om.om@gmail.com
Built with passion by the Cairo University Eco Racing Team 🏁
A modular, open-source platform for developing inverters, controllers, and embedded firmware for electric vehicle applications.
Built with robust engineering principles and driven by passion.
Maintained by Omar Magdy for the Cairo University Eco Racing Team.
ForgeDriveMC implements a range of hardware and software solutions for electric drive systems.
It includes:
- Custom inverters (multi-phase and bidirectional support)
- Firmware for Trapezoidal , FOC, SPWM, SVM, and advanced motor control
- Modular controllers and drivers
- Fully documented software and hardware stacks
- Design iterations built for real-world racing
- ⚙️ Multiple Inverter Designs
- 🧾 Well-documented Firmware using Doxygen
- 💡 Modular & Scalable Design across generations
- 🛠️ Interactive BOMs and Fabrication-Ready Gerbers
- 🔧 Configurable Build System for firmware
- 💻 Simulator & HIL Support
- 🧪 Validated by Real-World Team Use
Specific features are documented in each design subfolder:
- Build your own firmware using the instructions in each firmware folder.
- Or, download the precompiled binaries from the design folders.
- Configure and flash using the README-provided instructions.
- 🏁 Cairo University Eco Racing Team https://cu-eco.org
This project is open source.
📌 License: MIT
You can support the project by:
- Contributing firmware or hardware improvements
- Reviewing documentation and build systems
- Participating in issue tracking and pull requests
- Providing feedback based on hardware tests
- Become a sponsor
- 🐚 Shell
✈️ EgyptAir
Maintainer: Omar Magdy
📧 omar.magdy.om.om@gmail.com
- All engineers and contributors from the Cairo University Eco Racing Team