Skip to content

Commit

Permalink
feature: high inlet temperature derates the charge current
Browse files Browse the repository at this point in the history
  • Loading branch information
uhi22 committed Jun 25, 2024
1 parent 480f499 commit f2fd516
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 5 deletions.
24 changes: 23 additions & 1 deletion ccs/hardwareInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,21 @@ int16_t hardwareInterface_getChargingTargetCurrent(void)
only important thing is that configured current can drive the load. Let's say 10A is good. */
Param::SetInt(Param::ChargeCurrent, 10);
}
return Param::GetInt(Param::ChargeCurrent);
int16_t iOriginalDemand = Param::GetInt(Param::ChargeCurrent); /* the current demand from BMS */
int16_t iLimit = Param::GetInt(Param::TempLimitedCurrent); /* the limit due to inlet temperature */
int16_t iEVTarget;
if (iOriginalDemand>iLimit) {
/* We are limiting. Set a spot value "LimitationReason=LimitedDueToHighInletTemperature" so that the
user has a chance to understand what happens. */
Param::SetInt(Param::LimitationReason, LIMITATIONREASON_INLET_HOT);
iEVTarget = iLimit;
} else {
/* no limitation */
Param::SetInt(Param::LimitationReason, LIMITATIONREASON_NONE);
iEVTarget = iOriginalDemand;
}
Param::SetInt(Param::EVTargetCurrent, iEVTarget);
return iEVTarget;
}

uint8_t hardwareInterface_getSoc(void)
Expand Down Expand Up @@ -205,14 +219,22 @@ bool hardwareInterface_stopChargeRequested()
if (pushbutton_isPressed500ms()) {
stopReason = STOP_REASON_BUTTON;
Param::SetInt(Param::StopReason, stopReason);
addToTrace(MOD_HWIF, "User pressed the stop button.");
}
if (!Param::GetBool(Param::enable)) {
stopReason = STOP_REASON_MISSING_ENABLE;
Param::SetInt(Param::StopReason, stopReason);
addToTrace(MOD_HWIF, "Got enable=false.");
}
if ((Param::GetInt(Param::CanWatchdog) >= CAN_TIMEOUT) && (Param::GetInt(Param::DemoControl) != DEMOCONTROL_STANDALONE)) {
stopReason = STOP_REASON_CAN_TIMEOUT;
Param::SetInt(Param::StopReason, stopReason);
addToTrace(MOD_HWIF, "Timeout of CanWatchdog.");
}
if (Param::GetFloat(Param::TempLimitedCurrent)<0.1) { /* overheat of the inlet shall stop the session */
stopReason = STOP_REASON_INLET_OVERHEAT;
Param::SetInt(Param::StopReason, stopReason);
addToTrace(MOD_HWIF, "Inlet overheated.");
}
return (stopReason!=STOP_REASON_NONE);
}
Expand Down
29 changes: 29 additions & 0 deletions ccs/temperatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,34 @@ 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.
1. If the maximum of the three sensors is below the configured threshold,
the allowed charge current shall be proportional to the gap.
At the moment hardcoded AMPS_PER_KELVIN = 5, this means with a gap of 20K we allow 100A.
2. If the maximum of the three temperature sensors reaches the
parametrized MaxAllowedPinTemperature, the allowed charge current
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 */
#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 */
maxAllowedCurrent_A = 0; /* this will stop the session, evaluated in hardwareInterface_stopChargeRequested() */
} else if (diffTemp_K >= 0) {
/* 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;
/* but not below the minimum current: */
if (maxAllowedCurrent_A < MINIMUM_SENSEFUL_CURRENT_A) maxAllowedCurrent_A = MINIMUM_SENSEFUL_CURRENT_A;
}
Param::SetFloat(Param::TempLimitedCurrent, maxAllowedCurrent_A);
}

20 changes: 16 additions & 4 deletions include/param_prj.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@

#include "myLogging.h"

//Next param id (increase when adding new parameter!): 31
//Next value Id: 2027
//Next param id (increase when adding new parameter!): 32
//Next value Id: 2030
/* category name unit min max default id */
#define PARAM_LIST \
PARAM_ENTRY(CAT_HARDWARE,UdcDivider, "dig/V", 0, 100, 10, 1 ) \
Expand All @@ -63,6 +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 ) \
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 All @@ -78,6 +79,9 @@
VALUE_ENTRY(lasterr, errorListString, 2002 ) \
VALUE_ENTRY(EvseVoltage, "V", 2006 ) \
VALUE_ENTRY(EvseCurrent, "A", 2010 ) \
VALUE_ENTRY(TempLimitedCurrent, "A", 2027 ) \
VALUE_ENTRY(EVTargetCurrent, "A", 2029 ) \
VALUE_ENTRY(LimitationReason, LIMITATIONREASONS, 2028 ) \
VALUE_ENTRY(InletVoltage, "V", 2007 ) \
VALUE_ENTRY(EvseMaxCurrent, "A", 2008 ) \
VALUE_ENTRY(EvseMaxVoltage, "V", 2009 ) \
Expand Down Expand Up @@ -110,12 +114,13 @@
#define CANSPEEDS "0=125k, 1=250k, 2=500k, 3=800k, 4=1M"
#define OFFON "0=Off, 1=On"
#define DEMOCTRL "0=CAN, 234=StandAlone"
#define STOPREASONS "0=None, 1=Button, 2=MissingEnable, 3=CANTimeout, 4=ChargerShutdown, 5=AccuFull, 6=ChargerEmergency"
#define STOPREASONS "0=None, 1=Button, 2=MissingEnable, 3=CANTimeout, 4=ChargerShutdown, 5=AccuFull, 6=ChargerEmergency, 7=InletOverheat"
#define WAKEUP "0=Level, 1=Pulse, 2=LevelOnValidCp, 3=PulseOnValidCp, 4=LevelOnValidPP"
#define CAT_HARDWARE "Hardware Config"
#define CAT_CHARGE "Charge parameters"
#define CAT_COMM "Communication"
#define CAT_TEST "Testing"
#define LIMITATIONREASONS "0=None, 1=InletHot"

#define PARAM_ID_SUM_START_OFFSET GITHUB_RUN_NUMBER

Expand Down Expand Up @@ -154,7 +159,14 @@ enum _stopreasons
STOP_REASON_CAN_TIMEOUT,
STOP_REASON_CHARGER_SHUTDOWN,
STOP_REASON_ACCU_FULL,
STOP_REASON_CHARGER_EMERGENCY_SHUTDOWN
STOP_REASON_CHARGER_EMERGENCY_SHUTDOWN,
STOP_REASON_INLET_OVERHEAT
};

enum _limitationreasons
{
LIMITATIONREASON_NONE,
LIMITATIONREASON_INLET_HOT
};

enum _actuatortest
Expand Down

0 comments on commit f2fd516

Please sign in to comment.