Charging management is mainly used for monitoring and managing the battery charging process, ensuring safe and fast charging of the battery. Currently, many IoT products come with batteries, and the charging circuits and chips have a certain degree of reusability. Therefore, implementing a universal charging management framework that integrates the characteristics of different charging circuits and chips enhances software reusability and maintainability.
Configuration Application of chargerd
The chargerd application in NuttX requires the following configuration.
Configuration for chargerd
To enable the chargerd service, the following configurations need to be set:
# Enable the chargerd service
CONFIG_CHARGERD=y
# If battery data from the fuel gauge requires b16 conversion, enable this configuration
CONFIG_CHARGERD_HWINTF_CONVERSION=y
# Default path for the chargerd configuration file, fill in the correct value if changed
CONFIG_CHARGERD_CONFIGURATION_FILE_PATH=/etc/chargerd_parameters.json
Starting chargerd
Add the startup process for the chargerd service in the startup script rcS as follows:
#ifdef CONFIG_CHARGERD
chargerd &
#endif
Packaging chargerd
Include the configuration file for chargerd in the ROMFS packaging script:
The chargerd configuration file is in JSON format. When chargerd starts, it reads the configuration file and initializes the chargerd service according to the configuration.
Parameters in Configuration File
Parameter Name
Parameter Format
Description
charger_supply
Parameter Value
Adjusts the power supply voltage device node for the charger chip
charger_adapter
Parameter Value
Device node for detecting charger plug/unplug events and charging types
charger
Parameter Value
Device node for the charging chip, multiple chips separated by ‘;’
fuel_gauge
Parameter Value
Device node for the battery fuel gauge
algo
Parameter Value
Charging algorithm used by the charging chip, multiple chips separated by ‘;’
polling_interval_ms
Parameter Value
Self-check timer polling interval
fullbatt_capacity
Parameter Value
Full charge condition (%)
fullbatt_current
Parameter Value
Full charge current condition (mA)
fullbatt_duration_ms
Parameter Value
Recovery time after full charge cutoff (ms)
fault_duration_ms
Parameter Value
Recovery time after fault protection (ms)
temp_min
Parameter Value
Low temperature protection threshold (0.1 Celsius)
temp_min_r
Parameter Value
Low temperature protection recovery threshold (0.1 Celsius)
temp_max
Parameter Value
High temperature protection threshold (0.1 Celsius)
temp_max_r
Parameter Value
High temperature protection recovery threshold (0.1 Celsius)
temp_skin
Parameter Value
Thermal shell temperature overheat threshold (0.1 Celsius)
temp_skin_r
Parameter Value
Thermal shell temperature overheat recovery threshold (0.1 Celsius)
enable_delay_ms
Parameter Value
Delay time (ms) for normal access after adapter is enabled
temp_rise_hys
Parameter Value
Temperature rise hysteresis value (0.1 Celsius)
temp_fall_hys
Parameter Value
Temperature fall hysteresis value (0.1 Celsius)
vol_rise_hys
Parameter Value
Voltage rise hysteresis value (mV)
vol_fall_hys
Parameter Value
Voltage fall hysteresis value (mV)
battery_default_param
Default battery parameters, see template
Information configured as battery when unable to obtain battery info via ioctl
charger_fault_plot_table
Charging error values, see template
Used when charging errors occur; parameters represent: {temperature range start (0.1 Celsius), temperature range end (0.1 Celsius), voltage range start (mV), voltage range end (mV), charger index (0 start, -1 indicates no charging), charging current (mA), charging voltage (mV)}
Charging Curve Table
Charging curve table, see template
1. name: name of the charging curve table; 2. mask: value obtained from left shift operation based on 1, e.g., 1 << 3, then mask is 8, indicating charging protocol corresponding to kernel data structure battery_protocol_e; 3. element_num: number of elements in the charging curve table; 4. your_plot_name_xxx: custom name for the charging curve table, must match the name parameter filled after the above name; 5. Curve table elements: placed after brackets, e.g., [-500,0,0,65535,-1,0,0], if there are multiple elements, write them in similar lines.
temperature_termination_voltage_table
Voltage table adjusted dynamically according to temperature
Cut-off voltage values adjusted dynamically based on temperature: 1. temp_vterm_enable: whether to enable this function; 2. temp_rise_hys: temperature rise hysteresis value; 3. temp_fall_hys: temperature fall hysteresis value; 4. relation_table: relationship between temperature range and cut-off voltage, e.g., [-100,0,3000], indicates that when the temperature is in the range of -10℃ ~ 0℃, the cut-off voltage is set to 3000mV.
Overview of chargerd
[ English | 简体中文 ]
Charging management is mainly used for monitoring and managing the battery charging process, ensuring safe and fast charging of the battery. Currently, many IoT products come with batteries, and the charging circuits and chips have a certain degree of reusability. Therefore, implementing a universal charging management framework that integrates the characteristics of different charging circuits and chips enhances software reusability and maintainability.
Configuration Application of chargerd
The chargerd application in NuttX requires the following configuration.
Configuration for chargerd
To enable the chargerd service, the following configurations need to be set:
Starting chargerd
Add the startup process for the chargerd service in the startup script rcS as follows:
Packaging chargerd
Include the configuration file for chargerd in the ROMFS packaging script:
Configuration File for chargerd
The chargerd configuration file is in JSON format. When chargerd starts, it reads the configuration file and initializes the chargerd service according to the configuration.
Parameters in Configuration File
Example of the chargerd Configuration File
Example configuration for chargerd:
Code Locations
The chargerd framework involves related code: