Overvoltage limit overflow fix (#80)
The bat config calculation did calculate the absolute max voltage too high, it was doing an unnecessary multiplication. This triggered an issue in the voltage limit set code, which did not handle the overflow of the 16bit limit value properly. Both are fixed now. We limit the limit value to what the ADC is able to deliver, so that we detect overvoltage for sure, even if the setting is out of ADC range.
This commit is contained in:
+2
-2
@@ -111,7 +111,7 @@ void battery_conf_init(BatConf *bat, BatType type, int num_cells, float nominal_
|
||||
case BAT_TYPE_NMC:
|
||||
case BAT_TYPE_NMC_HV:
|
||||
bat->topping_voltage = num_cells * ((type == BAT_TYPE_NMC_HV) ? 4.35 : 4.20);
|
||||
bat->voltage_absolute_max = num_cells * (bat->topping_voltage + 0.05);
|
||||
bat->voltage_absolute_max = bat->topping_voltage + num_cells * 0.05;
|
||||
bat->voltage_recharge = num_cells * 3.9;
|
||||
|
||||
bat->voltage_load_disconnect = num_cells * 3.3;
|
||||
@@ -191,7 +191,7 @@ void battery_conf_overwrite(BatConf *source, BatConf *destination, Charger *char
|
||||
destination->voltage_absolute_min = source->voltage_absolute_min;
|
||||
destination->charge_current_max = source->charge_current_max;
|
||||
destination->topping_current_cutoff = source->topping_current_cutoff;
|
||||
destination->topping_duration = source->topping_duration;
|
||||
destination->topping_duration = source->topping_duration;
|
||||
destination->trickle_enabled = source->trickle_enabled;
|
||||
destination->trickle_voltage = source->trickle_voltage;
|
||||
destination->trickle_recharge_time = source->trickle_recharge_time;
|
||||
|
||||
Reference in New Issue
Block a user