Commercial and industrial (C&I) energy battery storage systems provide peak shaving, grid peak regulation, and distributed energy integration. Their safe operation depends on the battery management system (BMS) detecting cell-level and system-level abnormalities before they propagate. Lithium iron phosphate (LFP) cells are attractive because of thermal stability and long cycle life, but their flat open-circuit voltage (OCV) plateau between roughly 10% and 90% state of charge (SOC) makes both SOC estimation and fault classification difficult. The same controller that runs diagnostics is usually a resource-constrained microcontroller, so accuracy, latency, and memory must be designed together rather than optimized in isolation.

The diagnostic bottleneck in LFP storage
Around mid-SOC, OCV changes little with SOC. A small voltage measurement error therefore maps to a large SOC error, and a linearized estimator can lose local observability. Fault signatures are also weaker: cell voltage deviation, temperature deviation, sensor drift, internal resistance change, and relaxation behavior can overlap. The BMS must sample voltage, current, and temperature synchronously, estimate SOC online, classify faults, and issue protection actions within a deterministic control period. For the architecture considered here, the design targets are end-to-end diagnosis within 10 ms, RAM below 300 KB, and a task set that satisfies a rate-monotonic schedulability bound.
Three-layer modular architecture
The software is split into data acquisition, diagnostic inference, and decision output. The acquisition layer conditions cell voltage, pack current, and temperature signals; an analog-to-digital converter (ADC) is triggered by a hardware timer, and direct memory access (DMA) transfers results into the inference buffer. Because the CPU does not copy each sample, the acquisition path imposes roughly 30% less CPU load than an interrupt-service-routine copy scheme. The layers exchange data through real-time operating system (RTOS) message queues, so communication tasks do not preempt the diagnostic path.
The inference layer runs the equivalent-circuit model (ECM), extended Kalman filter (EKF), and support vector machine (SVM) classifier. The decision layer assigns a fault level, publishes SOC and fault status over a controller area network (CAN) interface, commands local protection, and writes fault records to on-chip Flash. A representative target uses an STM32H743 microcontroller, with CAN reporting every 200 ms; the internal diagnostic path is faster and is not limited by that reporting period.
Battery model and SOC estimation on a flat OCV curve
A first-order resistor-capacitance (RC) ECM represents the LFP cell. With discharge current positive, the terminal voltage is
$$
U_t = U_{\mathrm{OCV}}(SOC) – I R_0 – U_{RC}
$$
where $U_{\mathrm{OCV}}$ is the SOC-dependent open-circuit voltage, $R_0$ is the ohmic resistance, $I$ is the current, and $U_{RC}$ is the polarization voltage across the RC branch.
Model parameters were identified by hybrid pulse power characterization (HPPC) on a 100 Ah LFP cell in a temperature-controlled environment at 25 °C ± 1 °C. The cell was charged to full at 0.5C, rested for 2 h, and then subjected to 10% SOC steps, each with a 60 s discharge pulse and a 40 s recovery interval. The ohmic resistance $R_0$ was calculated from the instantaneous voltage step divided by the current. The polarization resistance $R_1$ and polarization capacitance $C_1$ were obtained by exponential fitting of the relaxation voltage. The OCV–SOC relationship was built from the steady-state voltage after 2 h of rest at each SOC point. The identified values are $R_0 = 2\ \mathrm{m\Omega}$, $R_1 = 1.5\ \mathrm{m\Omega}$, and $C_1 = 3{,}500\ \mathrm{F}$, giving a time constant $\tau = R_1 C_1 = 5.25\ \mathrm{s}$, within the 3–8 s range typical of LFP polarization dynamics.
The EKF uses SOC and $U_{RC}$ as state variables. With $C_n$ in Ah, $\Delta t$ in s, and current positive on discharge, the discrete state transition is
$$
\begin{bmatrix} SOC_k \\ U_{RC,k} \end{bmatrix}
=
\begin{bmatrix} 1 & 0 \\ 0 & e^{-\Delta t/\tau} \end{bmatrix}
\begin{bmatrix} SOC_{k-1} \\ U_{RC,k-1} \end{bmatrix}
+
\begin{bmatrix} -\dfrac{\Delta t}{3600 C_n} \\ R_1\left(1-e^{-\Delta t/\tau}\right) \end{bmatrix} I_{k-1}
$$
With $C_n = 100\ \mathrm{Ah}$ and $\Delta t = 0.1\ \mathrm{s}$, the model preserves the identified 5.25 s relaxation behavior. Instead of linearizing the OCV–SOC curve once over the full operating range, the estimator uses segmented local linearization across the plateau. This raises the sensitivity of the correction step where the OCV slope is small and reduces the tendency of the filter to rely on a weak voltage signal.
Feature design and SVM fault classifier
The classifier uses six input features selected to separate the dominant fault mechanisms in C&I storage:
- cell terminal voltage deviation from the pack mean;
- cell temperature deviation;
- difference between EKF-estimated SOC and coulomb-counting SOC;
- rate of change of ohmic resistance from online ECM/EKF parameter identification;
- voltage relaxation time constant from relaxation-segment fitting;
- charge/discharge ampere-hour integration deviation.
These features represent over-temperature, sensor drift, SOC estimation bias, internal resistance anomaly, and cell voltage anomaly. The classifier distinguishes five fault classes plus normal operation using a radial basis function (RBF) SVM.
Training data combined laboratory bench tests with Simulink fault-injection simulations. The set contained five fault classes and normal operation, with at least 500 samples per class and 3,200 samples in total. It covered 0.2C–1C charge and discharge rates, 0–45 °C, and 10%–90% SOC, with an 80:20 train–test split and five-fold cross-validation. After constrained optimization, the selected parameters were penalty coefficient $C_{\mathrm{svm}} = 8.5$, kernel width $\gamma = 0.12$, and feature dimension $d = 6$, giving a classification error of 2.8% and an inference time of 5.1 ms per sample. On the held-out test set, the average classification accuracy was 97.2%, with per-class recall of at least 96.0%.
Constrained multi-objective tuning
The diagnostic task set must remain schedulable on the target MCU. For $n$ tasks with worst-case execution time $C_i$ and period $T_i$, the rate-monotonic utilization bound is
$$
U = \sum_{i=1}^{n}\frac{C_i}{T_i} \le n\left(2^{1/n}-1\right)
$$
RAM is bounded by task stacks $S_i$, the global data segment $M_{\mathrm{data}}$, and the dynamic heap $M_{\mathrm{heap}}$:
$$
\sum_{i=1}^{n} S_i + M_{\mathrm{data}} + M_{\mathrm{heap}} \le 300\ \mathrm{KB}
$$
The SVM tuning problem treats classification error $f_1$ and inference time $f_2$ as competing objectives:
$$
\min_{\mathbf{x}}\;[f_1(\mathbf{x}),f_2(\mathbf{x})],\quad \mathbf{x}=[C_{\mathrm{svm}},\gamma,d]^{T}
$$
subject to
$$
M_{\mathrm{SVM}}\le 300\ \mathrm{KB},\qquad C_{\mathrm{svm}}\in[0.1,100],\qquad \gamma\in[0.001,10]
$$
Although $d$ appears in the design vector, it is fixed at 6 by the feature set; the effective search is over $C_{\mathrm{svm}}$ and $\gamma$. The optimizer was non-dominated sorting genetic algorithm II (NSGA-II), with population size 100, 200 generations, crossover probability 0.9, mutation probability 0.1, and tournament selection. The selected solution was the knee point with the smallest Euclidean distance to the ideal point in the $f_1$–$f_2$ objective space. This constrained Pareto search avoids a common failure mode of single-objective grid search: driving classification error down while pushing inference time or memory beyond the embedded budget.
Acquisition and real-time scheduling
The acquisition chain is timer-driven at a 100 ms period. The ADC conversion is triggered by hardware, and DMA moves the results into the inference-layer input buffer without a per-sample CPU copy. The inference task runs at the highest application priority under FreeRTOS, executing the ECM–EKF estimate and the SVM classification sequentially. The complete EKF–SVM path must finish within the 10 ms hard constraint. The decision layer publishes fault level and SOC over CAN every 200 ms and writes fault records to Flash for offline analysis; this reporting cadence is slower than the diagnostic loop and does not define its latency.
The integration produces an end-to-end diagnostic response of 6.3 ms. The result depends on both sides of the co-design: DMA removes sample-copy load from the CPU, while the constrained SVM tuning keeps classifier inference at 5.1 ms rather than consuming the full diagnostic budget.
Validation and measured performance
Validation used an LFP battery test module, an STM32H743 target board, signal-conditioning and acquisition circuitry, a CAN module, a MATLAB/Simulink fault-injection environment, and PC monitoring software. Simulink generated voltage, current, and temperature excitations for five fault modes and injected them through a data acquisition card. The baseline condition was 25 °C ± 1 °C. Additional tests covered 0 °C, 25 °C, and 45 °C, charge and discharge rates of 0.2C, 0.5C, and 1C, and the 10%–90% SOC interval. Threshold-based and lightweight artificial neural network (ANN) diagnostics were built as comparison baselines.
Each fault mode was injected 20 times. Table 1 gives the per-class results available for three representative modes; the five-class system-level comprehensive detection rate reached 97.8%.
| Fault mode | Injections | Detection rate (%) | False-alarm rate (%) | Mean response (ms) |
|---|---|---|---|---|
| SOC estimation bias | 20 | 97.5 | 1.2 | 6.3 |
| Over-temperature | 20 | 98.5 | 0.8 | 5.1 |
| Sensor drift | 20 | 96.5 | 1.5 | 7.1 |
Across the three modes, detection was at least 96.5% and mean response was no more than 7.1 ms. The five-class held-out classifier reached 97.2% average accuracy and at least 96.0% recall per class. Generalization testing across the LFP plateau produced a lowest comprehensive detection rate of 95.8% at 0 °C and 0.2C, defining the weakest point of the tested operating envelope.
Closed-loop tests were repeated 20 times per group. Table 2 compares the architecture before and after constrained multi-objective optimization.
| Metric | Unoptimized configuration | Optimized architecture | Change |
|---|---|---|---|
| Comprehensive fault detection rate (%) | 85.3 | 97.8 | +12.5 percentage points |
| End-to-end response time (ms) | 14.2 | 6.3 | −7.9 ms (−55.6%) |
| RAM usage (KB) | 387 | 214 | −173 KB (−44.7%) |
| False-negative rate (%) | 4.2 | 2.2 | −2.0 percentage points (−47.6%) |
The optimized architecture satisfies all three hard constraints: 6.3 ms end-to-end response against a 10 ms limit, 214 KB RAM against a 300 KB limit, and a task set within the rate-monotonic utilization bound. The response margin is 3.7 ms and the RAM margin is 86 KB. Relative to the threshold-based baseline, the architecture delivered an 18.3% higher comprehensive detection rate with comparable response time. Relative to the lightweight ANN baseline, it achieved similar detection while using 31.2% less RAM and 28.4% less response time.
Deployment envelope and open issues
The results support deployment within the tested envelope of 0–45 °C, 0.2C–1C, and 10%–90% SOC, with the 0 °C/0.2C case showing the lowest detection rate of 95.8%. The architecture’s advantage is not a single algorithmic component but the combination of plateau-aware SOC estimation, feature-based classification, constrained multi-objective tuning, and CPU-free sample movement. Each part protects a different constraint: the EKF addresses observability, the SVM separates overlapping fault signatures, NSGA-II keeps inference inside the memory and latency budget, and DMA preserves CPU time for diagnosis.
The evidence base also marks the boundary of the claim. Faults were injected under laboratory and simulation conditions; natural degradation of retired batteries was not included, and coupled or compound faults remain difficult for a conventional SVM. A practical next step is lightweight deep learning, such as TinyML deployment, combined with transfer learning for adaptation across operating conditions. Multi-pack joint diagnosis would extend the same constrained architecture from a single battery assembly to a larger storage station, where sensor count, communication load, and fault correlation all increase.
