From 6d6cca179a9a61dbc4dad2288b9583e88c2eaf8b Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 2 Jan 2024 20:01:04 +0200 Subject: [PATCH 1/2] Fix power W calculation --- Software/src/battery/TESLA-MODEL-3-BATTERY.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp b/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp index c7313433..cd3c1902 100644 --- a/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp +++ b/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp @@ -30,6 +30,7 @@ static uint32_t total_discharge = 0; static uint32_t total_charge = 0; static uint16_t volts = 0; // V static int16_t amps = 0; // A +static int16_t power = 0; // W static uint16_t raw_amps = 0; // A static int16_t max_temp = 6; // C* static int16_t min_temp = 5; // C* @@ -202,7 +203,8 @@ void update_values_tesla_model_3_battery() { //This function maps all the value max_target_charge_power = MAXCHARGEPOWERALLOWED; } - stat_batt_power = (volts * amps); //TODO: check if scaling is OK + power = (volts * amps); + stat_batt_power = convert2unsignedInt16(power); min_temp = (min_temp * 10); temperature_min = convert2unsignedInt16(min_temp); From 6b06132607e9e00539ac3b27a95d9786567132ab Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 2 Jan 2024 21:37:48 +0200 Subject: [PATCH 2/2] Decimal fix --- Software/src/battery/TESLA-MODEL-3-BATTERY.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp b/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp index cd3c1902..3aae61dc 100644 --- a/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp +++ b/Software/src/battery/TESLA-MODEL-3-BATTERY.cpp @@ -203,7 +203,7 @@ void update_values_tesla_model_3_battery() { //This function maps all the value max_target_charge_power = MAXCHARGEPOWERALLOWED; } - power = (volts * amps); + power = ((volts / 10) * amps); stat_batt_power = convert2unsignedInt16(power); min_temp = (min_temp * 10);