Skip to content

Commit

Permalink
Add non standard option to pause IMD during precharge
Browse files Browse the repository at this point in the history
Signed-off-by: Cornelius Claussen <cc@pionix.de>
  • Loading branch information
corneliusclaussen committed Feb 13, 2023
1 parent 2c66780 commit 13e5fa6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 9 deletions.
38 changes: 32 additions & 6 deletions modules/EvseManager/EvseManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ void EvseManager::ready() {

// Isolation monitoring for DC charging handler
if (!r_imd.empty()) {

imd_stop();

r_imd[0]->subscribe_IsolationMeasurement([this](types::isolation_monitor::IsolationMeasurement m) {
// new DC isolation monitoring measurement received
EVLOG_info << fmt::format("Isolation measurement P {} N {}.", m.resistance_P_Ohm,
Expand All @@ -136,9 +139,17 @@ void EvseManager::ready() {
present_values.EVSEPresentCurrent.get() + config.hack_present_current_offset;
}

if (config.hack_pause_imd_during_precharge && m.voltage_V * m.current_A > 1000) {
// Start IMD again as it was stopped after CableCheck
imd_start();
EVLOG_info << "Hack: Restarting Isolation Measurement at " << m.voltage_V << " " << m.current_A;
}

r_hlc[0]->call_set_DC_EVSEPresentVoltageCurrent(present_values);
// publish EV_info

{
// dont publish ev_info here, it will be published when other values change.
// otherwise we will create too much traffic on mqtt
std::scoped_lock lock(ev_info_mutex);
ev_info.present_voltage = present_values.EVSEPresentVoltage;
ev_info.present_current = present_values.EVSEPresentCurrent;
Expand Down Expand Up @@ -185,14 +196,14 @@ void EvseManager::ready() {
r_hlc[0]->subscribe_DC_Open_Contactor([this](bool b) {
if (b)
powersupply_DC_off();
r_imd[0]->call_stop();
imd_stop();
});

// Back up switch off - charger signalled that it needs to switch off now.
// During normal operation this should be done earlier before switching off relais by HLC protocol.
charger->signal_DC_supply_off.connect([this] {
powersupply_DC_off();
r_imd[0]->call_stop();
imd_stop();
});

// Current demand has finished - switch off DC supply
Expand Down Expand Up @@ -810,14 +821,14 @@ void EvseManager::cable_check() {
if (!contactor_open && powersupply_DC_set(config.dc_isolation_voltage, 2)) {

powersupply_DC_on();
r_imd[0]->call_start();
imd_start();

// wait until the voltage has rised to the target value
if (!wait_powersupply_DC_voltage_reached(config.dc_isolation_voltage)) {
EVLOG_info << "Voltage did not rise to 500V within timeout";
powersupply_DC_off();
ok = false;
r_imd[0]->call_stop();
imd_stop();
} else {
// read out one new isolation resistance
isolation_measurement.clear();
Expand Down Expand Up @@ -853,7 +864,7 @@ void EvseManager::cable_check() {
m.resistance_N_Ohm);
ok = false;
r_hlc[0]->call_set_EVSEIsolationStatus(types::iso15118_charger::IsolationStatus::Fault);
r_imd[0]->call_stop();
imd_stop();
} else if (m.resistance_N_Ohm < min_resistance_ok || m.resistance_P_Ohm < min_resistance_ok) {
EVLOG_error << fmt::format("Isolation measurement WARNING P {} N {}.", m.resistance_P_Ohm,
m.resistance_N_Ohm);
Expand All @@ -870,6 +881,9 @@ void EvseManager::cable_check() {
}
}

if (config.hack_pause_imd_during_precharge)
imd_stop();

// Sleep before submitting result to spend more time in cable check. This is needed for some solar inverters
// used as DC chargers for them to warm up.
sleep(config.hack_sleep_in_cable_check);
Expand Down Expand Up @@ -965,4 +979,16 @@ const std::vector<std::unique_ptr<powermeterIntf>>& EvseManager::r_powermeter_en
return r_powermeter_grid_side;
}

void EvseManager::imd_stop() {
if (!r_imd.empty()) {
r_imd[0]->call_stop();
}
}

void EvseManager::imd_start() {
if (!r_imd.empty()) {
r_imd[0]->call_start();
}
}

} // namespace module
4 changes: 4 additions & 0 deletions modules/EvseManager/EvseManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ struct Conf {
bool hack_skoda_enyaq;
int hack_present_current_offset;
std::string connector_type;
bool hack_pause_imd_during_precharge;
};

class EvseManager : public Everest::ModuleBase {
Expand Down Expand Up @@ -197,6 +198,9 @@ class EvseManager : public Everest::ModuleBase {
// EV information
std::mutex ev_info_mutex;
types::evse_manager::EVInfo ev_info;

void imd_stop();
void imd_start();
// ev@211cfdbe-f69a-4cd6-a4ec-f8aaa3d1b6c8:v1
};

Expand Down
13 changes: 10 additions & 3 deletions modules/EvseManager/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,19 @@ config:
type: integer
default: 0
switch_to_minimum_voltage_after_cable_check:
description:
description: >-
When cable check is completed, switch to minimal voltage of DC output.
Normally disabled.
type: boolean
default: false
hack_skoda_enyaq:
description:
description: >-
Skoda Enyaq requests DC charging voltages below its battery level or even below 0 initially.
Set to true to enable dirty workaround.
type: boolean
default: false
hack_present_current_offset:
description:
description: >-
Adds an offset [A] to the present current reported to the car on HLC.
Set to 0 unless you really know what you are doing.
type: integer
Expand All @@ -132,6 +132,13 @@ config:
- IEC62196Type2Cable
- IEC62196Type2Socket
default: IEC62196Type2Cable
hack_pause_imd_during_precharge:
description: >-
Disable IMD at the end of CableCheck and re-enable when current is flowing in CurrentDemand.
Some DCDC power supplies do not start current flow when insulation measurement is active.
Set to true to enable dirty workaround for some IMD hardware.
type: boolean
default: false
provides:
evse:
interface: evse_manager
Expand Down

0 comments on commit 13e5fa6

Please sign in to comment.