Skip to content

Commit

Permalink
Make soft over current timeout configurable (#864)
Browse files Browse the repository at this point in the history
* Make soft over current timeout configurable
* Make soft over current timeout configurable
* Add minimal value of 6s to avoid IEC61851-1 violation

Signed-off-by: Wojciech Kula <[email protected]>
  • Loading branch information
wku12 authored Sep 16, 2024
1 parent 9780450 commit fd3bf0f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
7 changes: 5 additions & 2 deletions modules/EvseManager/Charger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,8 @@ bool Charger::switch_three_phases_while_charging(bool n) {
void Charger::setup(bool has_ventilation, const ChargeMode _charge_mode, bool _ac_hlc_enabled,
bool _ac_hlc_use_5percent, bool _ac_enforce_hlc, bool _ac_with_soc_timeout,
float _soft_over_current_tolerance_percent, float _soft_over_current_measurement_noise_A,
const int _switch_3ph1ph_delay_s, const std::string _switch_3ph1ph_cp_state) {
const int _switch_3ph1ph_delay_s, const std::string _switch_3ph1ph_cp_state,
const int _soft_over_current_timeout_ms) {
// set up board support package
bsp->setup(has_ventilation);

Expand All @@ -1311,6 +1312,7 @@ void Charger::setup(bool has_ventilation, const ChargeMode _charge_mode, bool _a
ac_hlc_enabled_current_session = config_context.ac_hlc_enabled = _ac_hlc_enabled;
config_context.ac_hlc_use_5percent = _ac_hlc_use_5percent;
config_context.ac_enforce_hlc = _ac_enforce_hlc;
config_context.soft_over_current_timeout_ms = _soft_over_current_timeout_ms;
shared_context.ac_with_soc_timeout = _ac_with_soc_timeout;
shared_context.ac_with_soc_timer = 3600000;
soft_over_current_tolerance_percent = _soft_over_current_tolerance_percent;
Expand Down Expand Up @@ -1649,7 +1651,8 @@ void Charger::check_soft_over_current() {
auto now = std::chrono::steady_clock::now();
auto time_since_over_current_started =
std::chrono::duration_cast<std::chrono::milliseconds>(now - internal_context.last_over_current_event).count();
if (internal_context.over_current and time_since_over_current_started >= SOFT_OVER_CURRENT_TIMEOUT) {
if (internal_context.over_current and
time_since_over_current_started >= config_context.soft_over_current_timeout_ms) {
auto errstr =
fmt::format("Soft overcurrent event (L1:{}, L2:{}, L3:{}, limit {}) triggered",
shared_context.current_drawn_by_vehicle[0], shared_context.current_drawn_by_vehicle[1],
Expand Down
5 changes: 3 additions & 2 deletions modules/EvseManager/Charger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class Charger {
void setup(bool has_ventilation, const ChargeMode charge_mode, bool ac_hlc_enabled, bool ac_hlc_use_5percent,
bool ac_enforce_hlc, bool ac_with_soc_timeout, float soft_over_current_tolerance_percent,
float soft_over_current_measurement_noise_A, const int switch_3ph1ph_delay_s,
const std::string switch_3ph1ph_cp_state);
const std::string switch_3ph1ph_cp_state, const int soft_over_current_timeout_ms);

bool enable_disable(int connector_id, const types::evse_manager::EnableDisableSource& source);

Expand Down Expand Up @@ -320,6 +320,8 @@ class Charger {
int switch_3ph1ph_delay_s{10};
// Use state F if true, otherwise use X1
bool switch_3ph1ph_cp_state_F{false};
// Tolerate soft over current for given time
int soft_over_current_timeout_ms{7000};
} config_context;

// Used by different threads, but requires no complete state machine locking
Expand Down Expand Up @@ -401,7 +403,6 @@ class Charger {
static constexpr int T_STEP_X1 = 3000;
// 4 seconds according to table 3 of ISO15118-3
static constexpr int T_STEP_EF = 4000;
static constexpr int SOFT_OVER_CURRENT_TIMEOUT = 7000;
static constexpr int IEC_PWM_MAX_UPDATE_INTERVAL = 5000;
// EV READY certification requires a small pause of 500-1000 ms in X1 after a t_step_EF sequence before going to X2-
// This is not required by IEC61851-1, but it is allowed by the IEC. It helps some older EVs to start charging
Expand Down
14 changes: 7 additions & 7 deletions modules/EvseManager/EvseManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,11 +812,11 @@ void EvseManager::ready() {
if (config.ac_with_soc) {
setup_fake_DC_mode();
} else {
charger->setup(config.has_ventilation,
(config.charge_mode == "DC" ? Charger::ChargeMode::DC : Charger::ChargeMode::AC), hlc_enabled,
config.ac_hlc_use_5percent, config.ac_enforce_hlc, false,
config.soft_over_current_tolerance_percent, config.soft_over_current_measurement_noise_A,
config.switch_3ph1ph_delay_s, config.switch_3ph1ph_cp_state);
charger->setup(
config.has_ventilation, (config.charge_mode == "DC" ? Charger::ChargeMode::DC : Charger::ChargeMode::AC),
hlc_enabled, config.ac_hlc_use_5percent, config.ac_enforce_hlc, false,
config.soft_over_current_tolerance_percent, config.soft_over_current_measurement_noise_A,
config.switch_3ph1ph_delay_s, config.switch_3ph1ph_cp_state, config.soft_over_current_timeout_ms);
}

telemetryThreadHandle = std::thread([this]() {
Expand Down Expand Up @@ -1002,7 +1002,7 @@ void EvseManager::setup_fake_DC_mode() {
charger->setup(config.has_ventilation, Charger::ChargeMode::DC, hlc_enabled, config.ac_hlc_use_5percent,
config.ac_enforce_hlc, false, config.soft_over_current_tolerance_percent,
config.soft_over_current_measurement_noise_A, config.switch_3ph1ph_delay_s,
config.switch_3ph1ph_cp_state);
config.switch_3ph1ph_cp_state, config.soft_over_current_timeout_ms);

types::iso15118_charger::EVSEID evseid = {config.evse_id, config.evse_id_din};

Expand Down Expand Up @@ -1040,7 +1040,7 @@ void EvseManager::setup_AC_mode() {
charger->setup(config.has_ventilation, Charger::ChargeMode::AC, hlc_enabled, config.ac_hlc_use_5percent,
config.ac_enforce_hlc, true, config.soft_over_current_tolerance_percent,
config.soft_over_current_measurement_noise_A, config.switch_3ph1ph_delay_s,
config.switch_3ph1ph_cp_state);
config.switch_3ph1ph_cp_state, config.soft_over_current_timeout_ms);

types::iso15118_charger::EVSEID evseid = {config.evse_id, config.evse_id_din};

Expand Down
1 change: 1 addition & 0 deletions modules/EvseManager/EvseManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ struct Conf {
int initial_meter_value_timeout_ms;
int switch_3ph1ph_delay_s;
std::string switch_3ph1ph_cp_state;
int soft_over_current_timeout_ms;
};

class EvseManager : public Everest::ModuleBase {
Expand Down
6 changes: 6 additions & 0 deletions modules/EvseManager/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ config:
- X1
- F
default: X1
soft_over_current_timeout_ms:
description: >-
Allow for over current to be present for N ms in soft over current checking during AC charging.
type: integer
minimum: 6000
default: 7000
provides:
evse:
interface: evse_manager
Expand Down

0 comments on commit fd3bf0f

Please sign in to comment.