-
-
Notifications
You must be signed in to change notification settings - Fork 710
Battery characterization tool #5536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…rization tool [no changelog]
…e check [no changelog]
|
model | device_test | click_test | persistence_test |
---|---|---|---|
T2T1 | |||
T3B1 | |||
T3T1 | |||
T3W1 |
Latest CI run: 17103361519
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a comprehensive battery characterization tool for processing captured data from the automatic battery tester. The tool enables battery model identification and fuel gauge simulation for LiFePO4 batteries.
- Battery model identification from test data to extract internal resistance and open-circuit voltage characteristics
- Fuel gauge simulator with multiple estimator implementations (EKF, Coulomb Counter, Dummy)
- Export functionality for both JSON models and C header files for embedded firmware
Reviewed Changes
Copilot reviewed 19 out of 21 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
tools/style.py.exclude | Excludes battery characterization tool's virtual environment from style checks |
tools/battery_characterization_tool/utils/console_formatter.py | Professional console output formatting utilities with ANSI color support |
tools/battery_characterization_tool/utils/c_lib_generator.py | Generates C header files with battery model data for embedded firmware |
tools/battery_characterization_tool/requirements.txt | Python package dependencies for the tool |
tools/battery_characterization_tool/models/simulator.py | Battery simulation engine and result handling |
tools/battery_characterization_tool/models/identification.py | Battery model parameter identification algorithms and curve fitting |
tools/battery_characterization_tool/models/estimators/*.py | State-of-charge estimation algorithms (EKF, Coulomb Counter, Dummy) |
tools/battery_characterization_tool/models/debug_plots.py | Debug visualization utilities for model identification |
tools/battery_characterization_tool/models/battery_models/JYHPFL333838.toml | Battery model configuration file |
tools/battery_characterization_tool/models/battery_model.py | Core battery model class with interpolation and curve evaluation |
tools/battery_characterization_tool/fuel_gauge_simulator.py | Main simulator script for testing fuel gauge algorithms |
tools/battery_characterization_tool/dataset/*.py | Dataset management and battery profile loading utilities |
tools/battery_characterization_tool/battery_model_identification.py | Main script for extracting battery model parameters from test data |
tools/battery_characterization_tool/README.md | Comprehensive documentation and usage instructions |
tools/battery_characterization_tool/.gitignore | Git ignore rules for generated data and virtual environments |
Comments suppressed due to low confidence (2)
tools/battery_characterization_tool/models/identification.py:186
- Parameter name 'r_int_est' is inconsistent with the function parameter name 'r_int_estim' used in line 198. Consider using consistent naming.
# make r_int estimation by averaging the values estimation from every transition, consider only half of the
tools/battery_characterization_tool/models/identification.py:359
- [nitpick] Use unpacking with explicit parameter names rather than positional unpacking to improve code readability and maintainability.
m, b, a1, b1, c1, a3, b3, c3 = ocv_params
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
tools/battery_characterization_tool/models/estimators/ekf_estimator.py
Outdated
Show resolved
Hide resolved
tools/battery_characterization_tool/models/estimators/dummy_estimator.py
Outdated
Show resolved
Hide resolved
a0e1092
to
3d1bc56
Compare
…haracterization tool
…the estimators to measure time in seconds [no changelog]
3d1bc56
to
c60cd55
Compare
…n + minor plotting fixes. [no changelog]
… config [no changelog]
This PR introduces a set of scripts that process captured data from the automatic_battery_tester tool introduced in https://github.com//pull/5212. This tool serves two main purposes:
1) Battery Model Identification
The fuel gauge estimator design requires an identified battery model to predict battery State of Charge (SoC) based on observable variables (terminal voltage, current, temperature). The first purpose of the Battery Characterization Tool is to extract switching and linear waveforms from the dataset and estimate model parameters including:
The identified model is exported in two formats:
.json
representation for use with the fuel gauge simulatorbattery_data
header file for embedded firmware fuel gauge library2) Fuel Gauge Simulator
The second purpose is to use the identified battery model to simulate fuel gauge behavior on captured data and tune filter parameters without time-consuming tests on physical devices. The tool implements three different estimator models:
While EKF is exclusively used in the final application, the other two estimators provide performance comparison baselines.
Usage
The repository root contains two main scripts:
battery_model_identification.py
fuel_gauge_simulator.py
Comprehensive usage instructions are provided in the README file.
Dataset and battery model config file
The dataset is not included in the repository due to its size, which may exceed 1GB for a single battery type, but it is available in our internal storage.
The tool is ready to distinguish between battery models by defining the battery model config files in the 'models/battery_models' directory. While there is only one at the moment with only basic vendor name information, we may update the other models and extend the list of the battery model parameters from the specification to propagate them into the battery model header file and potentially use them to automate the settings of other power components in the FW (For instance: cold, cool, warm, hot temperature settings in PMIC).