From dc394cc198722c692f8c25506efa20d81b2bf20d Mon Sep 17 00:00:00 2001 From: Martin Jaeger <17674105+martinjaeger@users.noreply.github.com> Date: Mon, 27 Jan 2020 14:56:38 +0100 Subject: [PATCH] DC/DC: HS MOSFET fail-safe protection enabled --- src/config.h_template | 5 +++++ src/dcdc.cpp | 21 ++++++++++++++------- src/dcdc.h | 2 +- src/main_mbed.cpp | 7 +++++++ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/config.h_template b/src/config.h_template index 9dabf29..3b3ae9f 100644 --- a/src/config.h_template +++ b/src/config.h_template @@ -32,6 +32,11 @@ #define CONFIG_DEVICE_ID 12345678 +// This enables a safety-feature for the MPPT charge controllers to blow the fuse and disable +// charging in case the HS MOSFET was shorted (e.g. by someone connecting a solar panel with +// too high voltage). +#define CONFIG_HS_MOSFET_FAIL_SAFE_PROTECTION 1 + #define THINGSET_USER_PASSWORD "user123" #define THINGSET_MAKER_PASSWORD "maker456" diff --git a/src/dcdc.cpp b/src/dcdc.cpp index d999234..1e5f012 100644 --- a/src/dcdc.cpp +++ b/src/dcdc.cpp @@ -11,6 +11,7 @@ #include "helper.h" #include "half_bridge.h" +#include "eeprom.h" #include // for fabs function #include // for min/max function @@ -263,13 +264,19 @@ void Dcdc::emergency_stop() off_timestamp = uptime(); } -void Dcdc::self_destruction() +void Dcdc::fuse_destruction() { - print_error("Charge controller self-destruction called!\n"); - //half_bridge_stop(); - //half_bridge_init(50, 0, 0, 0.98); // reset safety limits to allow 0% duty cycle - //half_bridge_start(0); - // now the fuse should be triggered and we disappear + static int counter = 0; + + if (counter > 20) { // wait 20s to be able to send out data + print_error("Charge controller fuse destruction called!\n"); + eeprom_store_data(); + half_bridge_stop(); + half_bridge_init(50, 0, 0, 0.98); // reset safety limits to allow 0% duty cycle + half_bridge_start(0); + // now the fuse should be triggered and we disappear + } + counter++; } -#endif /* CHARGER_TYPE_PWM */ +#endif /* CONFIG_HAS_DCDC_CONVERTER */ diff --git a/src/dcdc.h b/src/dcdc.h index b5f437d..027cd2b 100644 --- a/src/dcdc.h +++ b/src/dcdc.h @@ -90,7 +90,7 @@ public: * reason for self destruction should be logged and stored to EEPROM prior to calling this * function, as the charge controller power supply will be cut after the fuse is destroyed. */ - void self_destruction(); + void fuse_destruction(); DcdcOperationMode mode; ///< DC/DC mode (buck, boost or nanogrid) bool enabled; ///< Can be used to disable the DC/DC power stage diff --git a/src/main_mbed.cpp b/src/main_mbed.cpp index 69a750e..b1db197 100644 --- a/src/main_mbed.cpp +++ b/src/main_mbed.cpp @@ -155,6 +155,7 @@ int main() #if CONFIG_HAS_DCDC_CONVERTER bat_terminal.pass_voltage_targets(&dcdc_lv_port); #endif + #if CONFIG_HAS_PWM_SWITCH bat_terminal.pass_voltage_targets(&pwm_port_int); #endif @@ -166,6 +167,12 @@ int main() ext_mgr.process_1s(); + #if CONFIG_HS_MOSFET_FAIL_SAFE_PROTECTION && CONFIG_HAS_DCDC_CONVERTER + if (dev_stat.has_error(ERR_DCDC_HS_MOSFET_SHORT)) { + dcdc.fuse_destruction(); + } + #endif + last_call = now; } feed_the_dog();