Designing a Battery Management System Around a Domestic ARM Microcontroller for Lithium Battery Energy Storage

Lithium cells dominate new energy battery storage designs because their energy density, cycle life and low-temperature behaviour are markedly better than those of lead-acid equivalents. The same electrochemistry that makes them attractive also makes them fragile: an over-discharged pack can lose capacity permanently, and an overcharged cell can enter thermal runaway. A storage system therefore needs a battery management system (BMS) that measures every cell and every ampere in real time, decides quickly, and can physically disconnect the pack when a limit is crossed. The design discussed here implements that function set on the CS32F407VG, a domestically developed ARM-core microcontroller, together with an isolated auxiliary supply, a shunt-based current channel and a PC host application.

Lithium battery energy storage modules in a rack cabinet

Requirements that shape a lithium storage BMS

The starting point for the architecture is the failure mode, not the feature list. A cell held below its minimum voltage for a long period degrades irreversibly; a cell held above its maximum voltage accumulates heat and, in the worst case, ignites. Both conditions are avoided only if the BMS knows the individual cell voltages — not just the pack terminal voltage — and can open the charge or discharge path independently. Current must be sensed in both directions, because charging and discharging have different limits and different fault signatures. Temperature completes the triad, since the safe current window shrinks as the cells heat up.

The application context that motivated this design is equipment where mass and volume are constrained and where the storage subsystem must run autonomously while reporting its state to a higher-level controller. The BMS is therefore expected to do four things: protect, balance, communicate and log.

System architecture

A typical lithium storage architecture consists of a series–parallel cell matrix and a control section built from four blocks: cell voltage detection, bus current detection, an auxiliary bias supply for the BMS board, and the BMS board itself.

  • Cell voltage detection keeps each cell inside its window; it is the block that prevents both the capacity loss of chronic under-voltage and the ignition risk of sustained over-voltage.
  • Bus current detection measures magnitude and direction of the current between the pack and the DC bus. If the measured current exceeds a software-defined threshold, the BMS board turns off the main power MOSFETs and reports a fault code that the host can use to classify the event.
  • The auxiliary supply converts the high-voltage bus down to the low rails required by the BMS board, so that the board stays alive and in control across the whole charge and discharge cycle.
  • The BMS board coordinates the protection logic, adjusts the charge and discharge V–I profile according to cell state, exchanges data with the host, and reports operating quality and fault status.

High-side versus low-side main switch placement

The placement of the main charge/discharge power MOSFETs splits BMS designs into two families. In both, the current sampling point is normally placed on the same side as the switch, which keeps the sensing amplifier referenced to a stable node.

In the low-side arrangement the shunt sits between the negative terminal of the pack and the negative terminal of the DC bus. The circuit is simple and inexpensive, but once the MOSFETs open, the BMS board and the bus no longer share a ground reference, and communication between them is lost. In the high-side arrangement the shunt sits between the positive terminal of the pack and the positive terminal of the bus. The hardware is more involved, but the board and the bus remain galvanically tied at ground even with the MOSFETs off, so communication survives a protective disconnect.

Property Low-side switching High-side switching
Shunt / switch position Pack negative to bus negative Pack positive to bus positive
Hardware complexity Low Higher
Common ground after trip Lost Retained
Communication during protection Not possible Maintained
Typical use Cost-sensitive systems Systems requiring diagnostics or remote supervision

Current sensing: shunt, transconductance amplifier and ADC

The bus current channel is built from a precision shunt $R_S$ and a current sense amplifier. The loop current develops a small differential voltage across the shunt, the amplifier converts that differential input into an output current, and a resistor $R_3$ turns the current back into a voltage that the ADC can digitise.

$$I_O = g_m\left(V_{IN+}-V_{IN-}\right)$$

$$I_S R_S = V_{IN+}-V_{IN-}$$

$$V_O = I_O R_3$$

Combining the three relationships gives the end-to-end transfer function of the channel:

$$V_O = I_S R_S g_m R_3$$

Here $I_S$ is the sampled bus current, $R_S$ the shunt resistance, $g_m$ the transconductance of the current sense amplifier, and $V_O$ the voltage presented to the ADC. The product $R_S g_m R_3$ is the single gain term that sets the full-scale range versus resolution trade-off: a larger shunt or a larger $R_3$ increases sensitivity but reduces the headroom available for high currents. Selecting $R_S$, $R_1$, $R_2$ and $R_3$ together therefore fixes both the measurable current span and the fault-comparison thresholds used by the firmware.

Cell voltage acquisition

Individual cell voltages are taken through resistor dividers feeding either an operational-amplifier front end or an analog front end, with the divider outputs routed to the ADC or to MCU pins. For two adjacent cells in the stack the scaled readings are

$$V_{ADC3} = \frac{R_5}{R_1}V_3 \qquad V_{ADC4} = \frac{R_5}{R_1}V_4$$

where $V_3$ and $V_4$ are the true cell voltages and the resistor ratio sets the attenuation. The divider network must be matched across channels, because the balancing decision compares one cell against another: a systematic gain error between channels would be read as a persistent state-of-imbalance and would trigger unnecessary balancing.

Auxiliary bias supply: isolated forward converter

The bias supply has to survive the full bus voltage and still deliver a well-regulated low rail. The design uses a forward converter built around the CPC5034 PWM controller, an independently developed device that integrates soft start, over-current protection and short-circuit protection. The converter provides isolated output and accepts a DC bus of up to 100 V, which covers the range of pack voltages that most lithium storage modules present.

In continuous forward operation the output voltage follows the duty cycle and the transformer turns ratio:

$$V_O = \frac{V_{IN}}{N}D$$

with $V_{IN}$ the bus voltage, $N$ the primary-to-secondary turns ratio and $D$ the duty cycle. The soft-start ramp is set by the external capacitor and follows the empirical relationship

$$t_{ss} = 3\times10^{4}\,C_{ss}$$

where $t_{ss}$ is the soft-start time in seconds and $C_{ss}$ the soft-start capacitance in farads. This gives the designer a direct handle on how quickly the 3.3 V rail is allowed to come up, which matters when the MCU and its peripherals must initialise in a defined order after the bus is energised.

Control board and firmware structure

The BMS board is built around the CS32F407VG, a domestically produced ARM-core microcontroller, together with the conditioning circuits described above. Its job is to supervise cell voltages, pack current and temperatures, run balancing when the cells diverge, and maintain a bidirectional link to the host.

Two firmware flows carry most of the behaviour:

  • Acquisition and balancing. The voltage and current channels are sampled continuously. On detecting a state of imbalance the module starts balancing on its own initiative, while the same data drive the charge and discharge control decisions.
  • Protection state machine. Three protection classes — voltage, current and temperature — are evaluated against parameters that can be loaded from the host or pre-programmed into flash. A temperature sensor tracks the thermal state; when any parameter crosses its limit the firmware switches off the main power MOSFETs and pushes the corresponding fault code to the host.

Putting the thresholds in configurable storage rather than in fixed hardware means one board design can be re-targeted to different cell chemistries and string lengths without a layout change, which is the practical definition of “suitable for most lithium storage schemes”.

Host-side monitoring software

The PC application is written in VB and exposes five functions: live data display and logging, board identity and basic information, log retrieval, parameter setting, and firmware upgrade. Voltages of each cell, instantaneous charge/discharge current, the historical minimum voltage recorded at full charge and cell temperatures are shown on one screen, so a commissioning engineer can see pack consistency at a glance.

Because logs are retained, an inconsistency between cells or a past fault can be located after the fact rather than reconstructed from memory. The application also applies algorithmic processing to the collected history to characterise ageing, which turns the BMS from a pure protection device into a source of state-of-health information.

Measured behaviour of the prototype

The auxiliary supply was built as a demonstration board using the CPC5034 controller and characterised on the bench.

  • Start-up. With the enable signal (EN) asserted, the 3.3 V output rises with a ramp set by the soft-start capacitor. Adjusting $C_{ss}$ changes the output-establishment time, allowing the rail to be matched to the system initialisation sequence.
  • Dynamic response. For a load step from 0 A to 2 A, the output deviation was 30–40 mV peak-to-peak, a disturbance small enough for the logic and analog front end to keep operating within specification.

With the board connected to the host application, cell voltages, charge and discharge current, the historical minimum voltage at full charge and cell temperature were displayed as expected, and fault logs could be retrieved for diagnosis. Functional integration of the boards confirmed that the architecture protects, balances and reports as intended.

What the design implies for storage integrators

Three engineering choices in this design are worth generalising. First, keeping the current shunt on the same side as the main switch preserves the signal reference, and choosing the high side keeps the communication link alive through a protective trip — a decisive advantage when a remote controller must know why the pack disconnected. Second, expressing the current channel as a single product $R_S g_m R_3$ makes the range-versus-resolution trade-off explicit and lets the fault thresholds be derived rather than guessed. Third, moving protection limits into configurable parameters, combined with an isolated bias supply rated to 100 V, allows a single hardware platform to cover a family of energy battery storage products instead of one.

The limitations follow from the same architecture: the cell voltage path depends on matched resistor dividers for balancing accuracy, the protection response is bounded by the sampling and firmware cycle rather than by hardware comparators, and the isolation barrier exists in the bias supply but not in the measurement front end. For storage systems where these boundaries match the application — moderate string lengths, supervised operation, and a need for domestic silicon — the combination of an ARM-core MCU, a shunt-based current channel and an isolated forward bias supply provides a compact and reproducible basis for the BMS.

Scroll to Top