Skip to content

About

POC Vehicle Management Unit (VMU) for a power-split hybrid powertrain. This supervisory ECU coordinates the ICE and electric motor, selecting EV, ICE, hybrid, and regenerative modes based on driver demand, vehicle speed, battery SOC, and system limits, while applying basic protections for smooth, efficient operation.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

VMU — Vehicle Management Unit

CI

Supervisory mode control for a power-split hybrid electric vehicle. A Simulink/Stateflow reference model and a hand-written C implementation select STANDSTILL, EV, REGENB, START, ICE, or HYBRID from driver power demand, vehicle speed, battery state of charge, and engine speed.

Open the interactive simulator · Verification results · Build and test

Context and my contribution

This project began as a five-person final project in the UFPE/Stellantis Technological Residency in Automotive Software Development (2026), using a MathWorks power-split HEV example as its starting point.

I’m Gustavo Igor da Silva. During the residency, I adapted the reference model, scoped and linked the requirements, established the C module architecture, and implemented and tested the engine-supported external transitions and the internal ICE/Hybrid transitions. I also worked on the build and static-analysis pipeline.

After the team baseline, I continued the project independently:

  • Fixed-point C interface: replaced floating-point inputs with explicitly scaled integers and aligned the model, requirements, and regression tests.
  • Model-to-code verification: added live Stateflow/C co-simulation, boundary probes, active-state comparison, and coverage evidence.
  • Simulator verification: extracted the browser simulator’s logic into a testable module and added a C/JavaScript differential check to CI.

The contribution record separates this continuation from the team’s work and links to the relevant commits. The original browser simulator was created by Danilo Varini.

What to inspect

Area Entry point
C controller and fixed-point API Implementation, header, design notes
Reference model Model setup and snapshots
Requirements and transitions Requirements PDF, transition reference, ownership mapping
Unit tests Five transition suites
Live model/C comparison Harness and instructions
Browser logic/C comparison Differential harness
Static analysis Scope and commands

Verification evidence

These figures describe the saved verification baseline. Reproduction commands and tool versions are in the report index.

Check Recorded result
C unit tests 141 tests, zero failures
C MC/DC condition outcomes 86/86, measured with GCC/gcov 14
Stateflow MC/DC 39/39, measured with Simulink Coverage
Live Stateflow/C comparison 469 exact matches and 4 documented sub-LSB quantization differences across 473 rows; zero unexpected grid mismatches
JavaScript/C comparison 473/473 rows match on state and outputs

Coverage counts describe the exercised logic; they do not establish vehicle-level safety or formal MISRA/ISO 26262 compliance. Platform timing and dedicated hysteresis-cycle verification remain outside or incomplete in this baseline; see the verification limits.

Run locally

The browser simulator opens directly from mode_logic_sim.html; no build is needed.

Watch the 90-second Dynamic demo, set an operating point and apply a controller step, explore six controller test presets, or replay UrbanCycle1/UrbanCycle2 recorded from the full Simulink/Simscape vehicle model. The demo supplies continuously varying synthetic speed, RPM, demand, and SOC inputs; the JavaScript supervisor calculates its modes and enable commands. These inputs illustrate controller behavior, not vehicle dynamics or energy consumption. Model playback preserves the recorded synchronized inputs, modes, and enable commands. All cycles support pause/resume, 1×/4×/10× speed, and full-precision CSV export with distinct demo/model sources. The browser runs no live vehicle dynamics. See recording provenance and model/C comparisons, including the observed quantization differences.

For the C and JavaScript checks, install Node.js, Python 3, and GCC, then run from the repository root:

git clone --depth 1 https://github.com/ThrowTheSwitch/Unity.git unity
npm ci
npm run test:c
npm test

npm run test:c runs the C unit suites. npm test checks JavaScript/C equivalence, controller coverage, recording integrity, and simulator session behavior. Generated output goes to build/ and coverage/. See testing instructions for tool overrides, C coverage, recorded-stimulus replay, and MATLAB setup.

Repository layout

Model/          Simulink model, requirements source, and upstream assets
src/            C controller
inc/            Public C interface and calibrations
test/           C unit tests
verification/   Model/C and JavaScript/C harnesses
web/            Browser interface, styles, and simulator session logic
scripts/        Test and coverage runners
docs/           Design, setup, requirements, and contribution records
reports/        Selected verification evidence

mode_logic.js and mode_logic_sim.html remain at the root so the published simulator URL stays stable. Reports include the assets needed to read them; compiled programs, object files, and coverage counters are generated locally.

Development uses short-lived pull requests into main. See the development workflow for reviews, CI, and releases.

Credits and licensing

The residency team was Danilo Varini, Marinel Almeida, Bruna, Hugo, and Gustavo Igor da Silva. See contributions for the division of work.

MathWorks-derived model assets retain their included license. No repository-wide license is declared for the original project code.

About

POC Vehicle Management Unit (VMU) for a power-split hybrid powertrain. This supervisory ECU coordinates the ICE and electric motor, selecting EV, ICE, hybrid, and regenerative modes based on driver demand, vehicle speed, battery SOC, and system limits, while applying basic protections for smooth, efficient operation.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages