Technical newsheet

Industrial IoT & MonitoringDevice profile

Synthetic Faults, Real Verdicts: Simscape Twin Streams BMS Telemetry to Edge Impulse

An open-source MATLAB-Simulink bridge streams synthetic fault telemetry to Edge Impulse, trains a 4-class BMS classifier plus anomaly detector, and returns the compiled C++ to the loop — 100% holdout accuracy.

By Amara Osei4 min read783 words

Features

  • A Simscape model of a 27 Ah NMC cell (R0 ≈ 8.5 mΩ) simulated 220 A short circuits and thermal runaway at 20 Hz to generate training data.
  • 480 labeled samples (24 minutes, 3 s each) trained a 4-class classifier plus 32-cluster K-means anomaly detector; holdout accuracy was 100.00% with F1 = 1.00.
  • The Flatten DSP block runs in 1 ms and 628 bytes of peak RAM, per Edge Impulse on-device profiling.
  • The toolbox compiles the exported Edge Impulse C++ library into a native C++20 MEX binary for closed-loop inference in Simulink.
  • The Arrhenius exothermic cascade is capped at 4 kW; cooling plate capacity is hA = 4.0 W/K against a 25 °C coolant source.
EdgeAI BMS System with Edge Impulse & MATLAB
Device photoEdgeAI BMS System with Edge Impulse & MATLAB — unavailable parts / unsplash

Training data for catastrophic EV battery faults usually requires destroying real cells in a blast chamber — which is why a new open-source workflow generates it in simulation instead. An engineer going by the project name EdgeAI BMS has published a MATLAB-to-Edge-Impulse bridge that streamed 24 minutes of labeled fault telemetry from a Simscape battery plant, trained a 4-class classifier plus K-means anomaly detector, and hit 100.00% accuracy with an F1 score of 1.00 on a 20% holdout set. Zero batteries were harmed. Zero CSV files were dragged into a browser.

What does the toolbox actually do?

The core of the project is the EdgeImpulse-MATLAB-Simulink-Toolbox, a two-way plugin with two Simulink blocks. EI_Data_Logger sits on any sensor bus: pick a label, set a window length, paste an Edge Impulse API key, and every completed time window streams over HTTPS directly into your Edge Impulse dataset. EI_Classifier closes the loop in the other direction — it parses the exported C++ library's model_metadata.h, compiles a native C++20 MEX binary, and runs the trained model against live physics signals in real time, with a Live Prediction Monitor HUD on the canvas.

The author's framing is blunt: most MATLAB-to-Edge-Impulse workflows are "clunky and one-way," dumping dozens of CSVs that never get tested back against the physics plant. This one, he says, keeps the loop on the Simulink canvas.

How real is the simulated cell?

The plant model is a 27 Ah NMC lithium-ion EV cell starting at 50% state of charge, with internal resistance R0 ≈ 8.5 mΩ, solved with Simulink's stiff ode23t solver at 20 Hz (MaxStep 0.05 s). Four operating modes — cascaded through three manual switches you can flip mid-run — cover Normal_Drive (+20 A, 0.74 C), Fast_Charging (−50 A, ~1.85 C, terminal voltage rising toward ~4.15 V), Short_Circuit (+220 A, ~8.1 C, voltage sagging below 2.0 V), and Thermal_Runaway (+45 A plus an exothermic trigger).

A 2.5 A, 0.5 Hz sinusoidal ripple rides on the load command so the model never memorizes flat DC lines. The thermal side carries 500 J/K total heat capacity (100 J/K internal, 400 J/K external, starting at 25 °C), an active liquid cooling plate at hA = 4.0 W/K tied to a 25 °C coolant source, and — in Mode 4 only — an Arrhenius feedback cascade capped at 4 kW. Higher temperature accelerates the reaction; the reaction dumps more heat; the cooling plate loses. Classic runaway, minus the fire brigade.

What went into the model?

Three channels — voltage, current, temperature — at 20 Hz, in a 2,000 ms sliding window (40 samples × 3 channels = 120 raw values) with 500 ms stride. The DSP is a Flatten block pulling 7 statistical features per axis (average, min, max, RMS, stddev, skewness, kurtosis): 21 features total, running in 1 ms and 628 bytes of peak RAM on-device. Two learning blocks sit on top: the 4-class neural network and a K-means anomaly detector with 32 clusters over 6 voltage, current, and temperature features, there to flag fault regimes the classifier never saw. Inject an out-of-distribution fault and the anomaly score spikes above zero instead of the model silently guessing wrong.

The dataset: 480 samples, 3 seconds each, split 80/20 train/test. On the unseen holdout, all four classes at 100% accuracy, 0% false anomaly flags. Simulated data, simulated verdicts — take them as a workflow demonstration, not a benchmark on real cells.

Why not just train in MATLAB?

The author's answer centers on deployment. MATLAB training is the easy part; turning it into an int8-quantized C++ binary that fits a Cortex-M, ESP32, STM32, or automotive MCU typically needs paid code-generation add-ons and manual tuning. Edge Impulse ships EON-compiled, int8-quantized C++, Arduino, CMSIS-PACK, or Linux/TensorRT builds with on-device profiling in one click. And because EI_Classifier runs the exact DSP, TFLite Micro, and K-means C++ that will run on the physical MCU, quantization or windowing misfires surface in Simulink before anyone flashes a board.

Everything — Simscape model, verification scripts, and the toolbox itself — is open source on GitHub, with the plant swappable for a motor, drone, or robotic arm. Iteration, the author claims, drops from weeks to an afternoon.

The open question is transfer. A model trained on a Simscape twin still has to survive real sensor noise, cell-to-cell variation, and an Arrhenius law that real chemistry occasionally disagrees with. Simulation-first tinyML is a credible workflow for dangerous faults. The proof will arrive on hardware.

via hackster.io (Source)

Filed under

Share this article:

More from Amara Osei

Amara Osei

Show full bio

Senior reporter covering people, launches and day-to-day practice in Instruments, test and measurement at Testbench Report.

134 articles

Application notes

« Previous articleNext article »