From 7bf56f8e0ddcb76e37f85402d61f49b91f5d3e82 Mon Sep 17 00:00:00 2001 From: Michael Balzer Date: Wed, 8 Nov 2017 21:53:00 +0100 Subject: [PATCH] - Fix: sanitize temperature compensation results --- KlausBMS.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/KlausBMS.ino b/KlausBMS.ino index 26d2e8f..7aa30a3 100644 --- a/KlausBMS.ino +++ b/KlausBMS.ino @@ -1065,11 +1065,11 @@ public: float dt = 20 - min(temp_f, temp_r); float dy; dy = (max_drive_power - max_drive_power_0c) / 20; - drvpwr -= dt * dy; + drvpwr = max(drvpwr - dt * dy, 0); dy = (max_recup_power - max_recup_power_0c) / 20; - recpwr -= dt * dy; + recpwr = max(recpwr - dt * dy, 0); dy = (max_charge_current - max_charge_current_0c) / 20; - chgcur -= dt * dy; + chgcur = max(chgcur - dt * dy, 5); } #endif // CALIBRATION_MODE