Skip to content

Commit

Permalink
Changed derating to start at MaxPinTemp-10
Browse files Browse the repository at this point in the history
  • Loading branch information
jsphuebner committed Jun 27, 2024
1 parent 51341e8 commit 7a9f854
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions ccs/temperatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void temperatures_calculateTemperatures(void) {
Param::SetFloat(Param::temp3, temp);
tempMax = MAX(tempMax, temp);
Param::SetFloat(Param::MaxTemp, tempMax);

/* Calculate the pin-temperature-dependent derating of the charge current.
Goal: Prevent overheating of the inlet and cables.
Strategy: Three cases.
Expand All @@ -73,9 +73,8 @@ void temperatures_calculateTemperatures(void) {
shall reach nearly zero (let's say allow just 2A).
3. If nothing helps and the temperature further increases, terminate the
session ("emergency stop") */
float diffTemp_K = tempMax - Param::GetFloat(Param::MaxAllowedPinTemperature); /* good case is negative diffTemp */
float maxAllowedCurrent_A;
#define AMPS_PER_KELVIN 5 /* proportional gain: five amperes per Kelvin */
float diffTemp_K = tempMax - Param::GetFloat(Param::MaxPinTemperature); /* good case is negative diffTemp */
float maxAllowedCurrent_A = Param::GetFloat(Param::ChargeCurrent);
#define MINIMUM_SENSEFUL_CURRENT_A 2 /* charging below this amperage makes no sense */
if (diffTemp_K > 10) {
/* very high temperature (much above the configured limit) --> stop charging completely */
Expand All @@ -84,10 +83,11 @@ void temperatures_calculateTemperatures(void) {
/* temperature limit is reached. Try to stabilize, using a minimum charging current. */
maxAllowedCurrent_A = MINIMUM_SENSEFUL_CURRENT_A;
} else {
/* normal temperature, linear derating */
maxAllowedCurrent_A = -diffTemp_K * AMPS_PER_KELVIN;
/* normal temperature, linear derating 10K below maximum temperature */
float limit = -diffTemp_K * maxAllowedCurrent_A / 10;
/* but not below the minimum current: */
if (maxAllowedCurrent_A < MINIMUM_SENSEFUL_CURRENT_A) maxAllowedCurrent_A = MINIMUM_SENSEFUL_CURRENT_A;
maxAllowedCurrent_A = MIN(maxAllowedCurrent_A, limit);
maxAllowedCurrent_A = MAX(maxAllowedCurrent_A, 2);
}
Param::SetFloat(Param::TempLimitedCurrent, maxAllowedCurrent_A);
}
Expand Down
6 changes: 3 additions & 3 deletions include/param_prj.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/

//Define a version string of your firmware here
#define VERSION 0.39
#define VERSION 0.40

#include "myLogging.h"

Expand All @@ -63,7 +63,7 @@
PARAM_ENTRY(CAT_CHARGE, MaxPower, "kW", 0, 1000, 100, 17 ) \
PARAM_ENTRY(CAT_CHARGE, MaxVoltage, "V", 0, 1000, 410, 18 ) \
PARAM_ENTRY(CAT_CHARGE, MaxCurrent, "A", 0, 500, 125, 19 ) \
PARAM_ENTRY(CAT_CHARGE, MaxAllowedPinTemperature, "°C", 0, 120, 70, 31 ) \
PARAM_ENTRY(CAT_CHARGE, MaxPinTemperature, "°C", 0, 120, 70, 31 ) \
TESTP_ENTRY(CAT_CHARGE, TargetVoltage, "V", 0, 1000, 0, 3 ) \
TESTP_ENTRY(CAT_CHARGE, ChargeCurrent, "A", 0, 500, 0, 4 ) \
TESTP_ENTRY(CAT_CHARGE, soc, "%", 0, 100, 0, 5 ) \
Expand Down Expand Up @@ -121,7 +121,7 @@
#define CAT_COMM "Communication"
#define CAT_TEST "Testing"
#define LIMITATIONREASONS "0=None, 1=InletHot"
#define PPVARIANT "0=Foccci4.1_3V3_1k, 1=Foccci4.2_5V_330up_3000down, 2=Foccci4.5_5V_330up_no_down"
#define PPVARIANT "0=Foccci4.1_3V3_1k, 1=Foccci4.2_5V_330up_3000down, 2=Foccci4.5_5V_330up_no_down"

#define PARAM_ID_SUM_START_OFFSET GITHUB_RUN_NUMBER

Expand Down
2 changes: 1 addition & 1 deletion libopeninv

0 comments on commit 7a9f854

Please sign in to comment.