Skip to content

Commit

Permalink
nrf_fuel_gauge: Update nrf_fuel_gauge to v0.11.1
Browse files Browse the repository at this point in the history
Update nrf_fuel_gauge to v0.11.1, which brings
improvements to TTE, reduced RAM usage, and other tweaks.

Signed-off-by: Audun Korneliussen <[email protected]>
  • Loading branch information
nordic-auko committed Sep 12, 2024
1 parent 56a4bd3 commit b90ef6e
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 6 deletions.
23 changes: 23 additions & 0 deletions nrf_fuel_gauge/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,29 @@ Changelog

All notable changes to this project are documented on this page.

Main branch
**********************

Changes
=======

* Update to library version 0.11.1.
* The :c:func:`nrf_fuel_gauge_init` function no longer copies the battery model pointed to in :c:struct:`nrf_fuel_gauge_init_parameters`. This means that the user must ensure that the battery model is kept valid while using the library, either in ROM or RAM.
* The :c:func:`nrf_fuel_gauge_process` function has a new argument to specify when bus voltage is present. That is, when system is powered by vbus instead of or in addition to the battery.

Added
=====

* :c:func:`nrf_fuel_gauge_opt_params_default_get` convenience function to initialize :c:struct:`nrf_fuel_gauge_config_parameters` structure.
* :c:func:`nrf_fuel_gauge_opt_params_adjust` function to adjust certain parameters without re-initializing the library.
* New configuration parameters in :c:struct:`nrf_fuel_gauge_config_parameters` structure.
* New configuration parameter in :c:struct:`nrf_fuel_gauge_runtime_parameters` structure.

Bug fixes
=========

* Fixed issue where battery models with less than 3 temperature points could generate wrong state-of-charge after using :c:func:`nrf_fuel_gauge_idle_set`.

nRF Connect SDK v2.6.0
**********************

Expand Down
42 changes: 36 additions & 6 deletions nrf_fuel_gauge/include/nrf_fuel_gauge.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extern const char *nrf_fuel_gauge_version;
extern const char *nrf_fuel_gauge_build_date;

/**
* @brief Battery model parameters.
* @brief Secondary cell (rechargeable) battery model parameters.
*
* @details Parameter details purposefully not documented.
*/
Expand Down Expand Up @@ -84,13 +84,22 @@ struct nrf_fuel_gauge_state_info {
/**
* @brief Optional static configuration parameters.
*
* @details Parameter details purposefully not documented.
* @details Some parameter details purposefully not documented.
*/
struct nrf_fuel_gauge_config_parameters {
float tau;
float tau1;
float tau2;
float neta1;
float neta2;
float neta3;
float beta1;
float beta2;
/**@brief Minimum duration of battery charge/discharge before TTE becomes available [s] */
float tte_min_time;
/**@brief Reset threshold for TTE calculation. If short-term state-of-charge gradient differs
* from the long-term state-of-charge by this factor or more, the TTE state is reset.
*/
float tte_reset_threshold;
};

/**
Expand All @@ -103,6 +112,7 @@ struct nrf_fuel_gauge_runtime_parameters {
float b;
float c;
float d;
bool discard_positive_deltaz;
};

/**
Expand All @@ -115,15 +125,25 @@ struct nrf_fuel_gauge_init_parameters {
float i0;
/** Initial temperature in centigrades [C]. */
float t0;
/** Battery model */
/** Pointer to static battery model. The model is not copied and must be kept valid. */
const struct battery_model *model;
/** Optional configuration parameters. Set to NULL to use default values. */
const struct nrf_fuel_gauge_config_parameters *opt_params;
};

/**
* @brief Initialize optional configuration parameters to default values.
*
* @param[out] opt_params Pointer to the parameter structure.
*/
void nrf_fuel_gauge_opt_params_default_get(struct nrf_fuel_gauge_config_parameters *opt_params);

/**
* @brief Initialize the nRF Fuel Gauge library.
*
* @note The battery model referenced in @ref parameters must be kept valid as long as the library
* is in use.
*
* @param[in] parameters Pointer to the parameter structure.
* @param[out] v0 Adjusted battery voltage (optional, for logging purposes).
*
Expand All @@ -139,12 +159,13 @@ int nrf_fuel_gauge_init(const struct nrf_fuel_gauge_init_parameters *parameters,
* @param i Measured battery current [A].
* @param T Measured battery temperature [C].
* @param t_delta Time delta since previous processed measurement [s].
* @param vbus_present True if vbus voltage is present, for devices that supports this.
* @param state Pointer to state info struct (optional, set to null to ignore).
*
* @retval Predicted state-of-charge [%].
*/
float nrf_fuel_gauge_process(
float v, float i, float T, float t_delta, struct nrf_fuel_gauge_state_info *state);
float nrf_fuel_gauge_process(float v, float i, float T, float t_delta, bool vbus_present,
struct nrf_fuel_gauge_state_info *state);

/**
* @brief Get predicted "time-to-empty" discharge duration.
Expand Down Expand Up @@ -199,6 +220,15 @@ void nrf_fuel_gauge_idle_set(float v, float T, float i_avg);
*/
void nrf_fuel_gauge_param_adjust(const struct nrf_fuel_gauge_runtime_parameters *params);

/**
* @brief Update optional parameters.
*
* @details Parameter details purposefully not documented.
*
* @param opt_params New parameter values.
*/
void nrf_fuel_gauge_opt_params_adjust(const struct nrf_fuel_gauge_config_parameters *opt_params);

#ifdef __cplusplus
}
#endif
Expand Down
Binary file modified nrf_fuel_gauge/lib/cortex-m3/soft-float/libnrf_fuel_gauge.a
Binary file not shown.
Binary file modified nrf_fuel_gauge/lib/cortex-m33/hard-float/libnrf_fuel_gauge.a
Binary file not shown.
Binary file modified nrf_fuel_gauge/lib/cortex-m33/soft-float/libnrf_fuel_gauge.a
Binary file not shown.
Binary file modified nrf_fuel_gauge/lib/cortex-m4/hard-float/libnrf_fuel_gauge.a
Binary file not shown.
Binary file modified nrf_fuel_gauge/lib/cortex-m4/soft-float/libnrf_fuel_gauge.a
Binary file not shown.

0 comments on commit b90ef6e

Please sign in to comment.