The problem
Pack sizing is repeated for every new vehicle, cell and supplier, and spreadsheet errors are common. A small, tested tool that takes requirements and cell data and returns a justified series–parallel configuration, with every check visible, speeds up early design and teaches the underlying calculations.
Objectives
- Write tested MATLAB functions for series–parallel sizing and electrical checks.
- Include voltage window, energy, peak and continuous current, mass and volume checks.
- Build an App Designer interface with inputs, results and warnings.
- Allow comparison of several cells for the same requirements.
- Verify the tool against hand calculations and boundary cases.
What you need
Tools and toolboxes
- MATLAB — Sizing functions, unit tests with the matlab.unittest framework, and data handling.
- App Designer — The graphical tool with numeric fields, drop-downs, tables, axes and warning labels (part of MATLAB).
- MATLAB Compiler (optional) — Packaging the app as a standalone application for users without MATLAB; not needed for the project itself.
Software
- MATLAB R2023b or later
- Published cell datasheet values for two or three cell formats (cylindrical, prismatic, pouch)
Extra parts and data
None beyond the software above.
Key concepts
- Series count
- Pack voltage = Ns × cell voltage. Ns is chosen so the pack voltage at full and empty charge stays inside the motor controller's input range.
- Parallel count
- Pack capacity = Np × cell capacity. Np is chosen for energy and for current: pack current divided by Np must stay within the cell's continuous and peak ratings.
- Gravimetric and volumetric factors
- Pack mass and volume are larger than the sum of cells because of busbars, housing, cooling and electronics. Factors from benchmarks or assumptions convert cell totals into pack totals.
- Usable energy
- Nominal energy multiplied by the usable SOC window and adjusted for end-of-life capacity fade, so the vehicle still meets its range late in life.
Step-by-step guide
- 1
Define inputs and outputs
List inputs: required usable energy, nominal and allowable pack voltage window, peak and continuous power, usable SOC window, end-of-life capacity fraction, and cell data (nominal, maximum and minimum voltage, capacity, continuous and peak current, mass, dimensions). Outputs: Ns, Np, pack energy, voltage range, cell currents, mass, volume and a pass/fail list. Use an example 72 V, 3 kWh scooter pack as the first test case.
Checkpoint: An input/output specification table with units and an example case.
- 2
Write the sizing functions
Write sizePack(req, cell) that computes Ns from the voltage window (ceil or floor with a check on both ends), Np from usable energy at end of life and from current limits, then takes the larger Np. Return a struct of results and a list of checks with pass/fail and margins. Keep the function free of user-interface code so it can be tested on its own.
Checkpoint: For the example 72 V, 3 kWh case with 4.8 Ah, 3.6 V cells, the function returns 20S and about 9P, matching a hand calculation.
- 3
Add mass, volume and thermal checks
Compute cell mass and volume totals and apply packaging factors entered by the user. Estimate heat generation at continuous current as I²·R per cell times the cell count and report it. Add a check against the user's allowable mass and volume. Show results as cell-level and pack-level values side by side. Show the packaging factors used next to the results so users understand that they are assumptions.
Checkpoint: Mass, volume and heat values for the example case match a hand calculation within rounding.
- 4
Write unit tests
Use matlab.unittest to write tests for normal cases, a voltage window that no integer Ns fits, a current-limited case where Np is set by power not energy, and invalid inputs (negative capacity). Run them with runtests and keep them passing as you add features. Each test states the expected result and the reason. Add a test for the 3 kWh example so the reference case is protected against later changes.
Checkpoint: All unit tests pass, including at least four edge cases.
- 5
Build the App Designer interface
Create an app with a requirements panel, a cell panel with a drop-down of saved cells plus a custom option, and a results panel with a table of outputs and a colour-coded checks list. Call sizePack in a button callback or on value change. Validate numeric fields with limits so impossible values cannot be entered. Disable the results panel until all required inputs are valid, so users are not misled.
Checkpoint: The app reproduces the example results and shows a clear failure message for an impossible voltage window.
- 6
Add comparison and plots
Let the user select several cells and show a comparison table of Ns, Np, cell count, mass, volume and margins. Add a bar chart of mass and volume per cell option and a plot of pack voltage range against the controller window. Allow export of results to CSV or an Excel file with writetable. Highlight the option with the largest margins in each column, without ranking options on cost.
Checkpoint: A comparison of three cell options in the app with exported results matching the screen.
- 7
Verify against hand calculations
Prepare three worked examples by hand (scooter, three-wheeler, small car), each with a different limiting factor, and compare the app's results with them. Include a case where end-of-life capacity fade forces an extra parallel string. Document any differences and fix the cause. Store the three worked examples as unit tests too, with their hand calculations in comments, so the tool's agreement with them is checked automatically every time the code changes.
Checkpoint: App results match all three worked examples exactly for Ns and Np and within rounding for other values.
- 8
Usability check
Ask two classmates to size a pack using the app with only a short instruction sheet, and record where they hesitate or make errors. Improve labels, units and default values accordingly. Add tooltips that explain each check in one line, so the tool teaches the calculation as well as doing it. Record the time each user took and the questions they asked, as evidence for the changes you made.
Checkpoint: A short usability note with changes made, and both test users completing the task correctly.
- 9
Report and release
Document the calculations, assumptions (packaging factors, end-of-life fraction), tests, app layout and worked examples. Package the app as a .mlappinstall file for other MATLAB users. State clearly that the tool is for early sizing and does not replace detailed electrical, thermal and mechanical design or safety standards compliance. Include a short user guide with screenshots of each panel and an explanation of every warning message.
Checkpoint: A report, a passing test suite and an installable app.
Testing & validation
- Unit tests pass, including edge cases.
- Three worked examples match by hand.
- Impossible requirements produce clear failure messages.
- Exported results match the on-screen values.
Expected results
A tested App Designer pack-sizing tool that turns vehicle requirements and cell data into a justified series–parallel configuration with energy, voltage, current, mass, volume and heat checks, and compares cell options.
Take it further
- Add a cost-per-kWh input to compare cell options on cost under stated assumptions.
- Link to a Simulink drive-cycle model to check range directly.
- Add module-level grouping and busbar resistance estimation.
- Add a simple thermal model for the continuous-current case.
Viva and review questions
How do you choose the series count?
So the pack voltage at full charge stays below the controller's maximum and at minimum cell voltage stays above its minimum, choosing a nominal voltage close to the target.
When is the parallel count set by current rather than energy?
When the required peak or continuous power divided by pack voltage, shared across Np strings, would exceed the cell's current rating at the Np needed for energy alone.
Why separate the sizing function from the app?
So it can be unit-tested and reused in scripts, while the app only handles input and display.
Learn it at DIYguru
These DIYguru courses and programmes teach what this project needs.
