From 19d87180da1b12f1a30db9b32feced4551fa2ac7 Mon Sep 17 00:00:00 2001 From: Christoph Schleifenbaum Date: Sat, 29 Oct 2022 20:54:14 +0200 Subject: [PATCH] Add another check whether we exceeded the maximum I We have ++I after the first check so add another one at the end. --- src/i3LIM.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/i3LIM.cpp b/src/i3LIM.cpp index 9a527195..2a9ed4c1 100644 --- a/src/i3LIM.cpp +++ b/src/i3LIM.cpp @@ -808,6 +808,11 @@ void i3LIMClass::CCS_Pwr_Con() //here we control ccs charging during state 6. if(Tmp_Vbatt>Tmp_Vbatt_Spnt)CCSI_Spnt--;//decrement if voltage equal to or greater than setpoint. if(CCS_Ilim==0x1)CCSI_Spnt--;//decrement if current limit flag is set if(CCS_Plim==0x1)CCSI_Spnt--;//decrement if Power limit flag is set + + // force once more that we stay within our maximum bounds + if(CCSI_Spnt>=Tmp_ICCS_Avail)CCSI_Spnt=Tmp_ICCS_Avail; //never exceed available current + if(CCSI_Spnt>Tmp_ICCS_Lim)CCSI_Spnt=Tmp_ICCS_Lim; //clamp setpoint to current lim paramater. + Param::SetInt(Param::CCS_Ireq,CCSI_Spnt); }