From 6be4e20f045e8ed65e03e52b6efdda4a0a000cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20J=C3=A4ger?= Date: Mon, 17 Aug 2020 18:22:26 +0200 Subject: [PATCH] Make load OC and LVD recovery delay configurable --- boards/arm/mppt_1210_hus/mppt_1210_hus.dts | 1 + boards/arm/mppt_2420_hpx/mppt_2420_hpx.dts | 1 + boards/arm/mppt_2420_lc/mppt_2420_lc.dts | 1 + boards/arm/pwm_2420_lus/pwm_2420_lus.dts | 1 + src/load.cpp | 6 ++++-- test/autoconf.h | 2 ++ zephyr/Kconfig | 17 +++++++++++++++++ 7 files changed, 27 insertions(+), 2 deletions(-) diff --git a/boards/arm/mppt_1210_hus/mppt_1210_hus.dts b/boards/arm/mppt_1210_hus/mppt_1210_hus.dts index 06e720a..67e92af 100644 --- a/boards/arm/mppt_1210_hus/mppt_1210_hus.dts +++ b/boards/arm/mppt_1210_hus/mppt_1210_hus.dts @@ -70,6 +70,7 @@ label = "Load output"; gpios = <&gpioc 13 GPIO_ACTIVE_HIGH>; current-max = <10>; + kconfig-flag; /* make node visible in Kconfig */ }; usb-pwr { diff --git a/boards/arm/mppt_2420_hpx/mppt_2420_hpx.dts b/boards/arm/mppt_2420_hpx/mppt_2420_hpx.dts index f978c51..0339051 100644 --- a/boards/arm/mppt_2420_hpx/mppt_2420_hpx.dts +++ b/boards/arm/mppt_2420_hpx/mppt_2420_hpx.dts @@ -59,6 +59,7 @@ label = "Load output"; gpios = <&gpiob 15 GPIO_ACTIVE_LOW>; current-max = <20>; + kconfig-flag; /* make node visible in Kconfig */ }; charge_pump { diff --git a/boards/arm/mppt_2420_lc/mppt_2420_lc.dts b/boards/arm/mppt_2420_lc/mppt_2420_lc.dts index 1142930..06ce89c 100644 --- a/boards/arm/mppt_2420_lc/mppt_2420_lc.dts +++ b/boards/arm/mppt_2420_lc/mppt_2420_lc.dts @@ -57,6 +57,7 @@ label = "Load output"; gpios = <&gpiob 2 GPIO_ACTIVE_LOW>; current-max = <20>; + kconfig-flag; /* make node visible in Kconfig */ }; uext_en { diff --git a/boards/arm/pwm_2420_lus/pwm_2420_lus.dts b/boards/arm/pwm_2420_lus/pwm_2420_lus.dts index 71f18f5..3b636ce 100644 --- a/boards/arm/pwm_2420_lus/pwm_2420_lus.dts +++ b/boards/arm/pwm_2420_lus/pwm_2420_lus.dts @@ -77,6 +77,7 @@ label = "Load output"; gpios = <&gpiob 2 GPIO_ACTIVE_LOW>; current-max = <15>; + kconfig-flag; /* make node visible in Kconfig */ }; usb-pwr { diff --git a/src/load.cpp b/src/load.cpp index a54fd39..e5bf7ff 100644 --- a/src/load.cpp +++ b/src/load.cpp @@ -34,8 +34,10 @@ LoadOutput::LoadOutput(DcBus *dc_bus, void (*drv_switch_fn)(bool), void (*drv_in switch_set(false); junction_temperature = 25; // starting point: 25°C - oc_recovery_delay = 5*60; // default: 5 minutes - lvd_recovery_delay = 60*60; // default: 1 hour + + oc_recovery_delay = CONFIG_LOAD_OC_RECOVERY_DELAY; + lvd_recovery_delay = CONFIG_LOAD_LVD_RECOVERY_DELAY; + ov_hysteresis = 0.3; enable = true; // switch on in next control() call if everything is fine diff --git a/test/autoconf.h b/test/autoconf.h index e05cab3..747bd5c 100644 --- a/test/autoconf.h +++ b/test/autoconf.h @@ -45,3 +45,5 @@ #define CONFIG_BAT_CHARGE_TEMP_MIN 0 #define CONFIG_BAT_DISCHARGE_TEMP_MAX 50 #define CONFIG_BAT_DISCHARGE_TEMP_MIN -10 +#define CONFIG_LOAD_OC_RECOVERY_DELAY 300 +#define CONFIG_LOAD_LVD_RECOVERY_DELAY 300 diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 860315a..113d6ff 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -291,6 +291,23 @@ endmenu # Custom temperature settings endmenu # Battery default settings + +menu "Load output settings" + depends on $(dt_node_has_bool_prop,/outputs/load,kconfig-flag) + +config LOAD_OC_RECOVERY_DELAY + int "Overcurrent recovery delay (s)" + default 300 + +config LOAD_LVD_RECOVERY_DELAY + int "Low-voltage disconnect recovery delay (s)" + default 300 + help + Prevents toggling load output in case of heavy load and low state of charge. + +endmenu # Load output settings + + endmenu # Charge controller setup