Move thermal model parameters to DTS

This commit is contained in:
Martin Jäger
2020-05-06 12:53:26 +02:00
parent 38125f3da3
commit 4e6f6c7365
14 changed files with 220 additions and 243 deletions
+164 -3
View File
@@ -1,9 +1,170 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2019 Martin Jäger (Libre Solar)
#
# Generic Libre Solar Charge Controller configuration
# Invisible (board-specific) Kconfig symbols
#
rsource "Kconfig.hidden"
config HAS_LOAD_OUTPUT
bool
help
PCB has a load output.
rsource "Kconfig.user"
config HAS_USB_PWR_OUTPUT
bool
help
PCB has a USB power output.
config CONTROL_FREQUENCY
int
default 10
help
Main control function frequency (Hz)
Frequencies higher than 10 Hz caused issues with MPPT control during lab test with
PV simulator. Might be different with actual solar panel.
#
# Visible (user-configurable) Kconfig symbols
#
choice
prompt "High-voltage terminal"
depends on $(dt_compat_enabled,dcdc)
help
Select the device connected to the high-voltage
side terminal of the DC/DC converter.
config HV_TERMINAL_SOLAR
bool "Solar panel"
config HV_TERMINAL_NANOGRID
bool "DC nanogrid"
config HV_TERMINAL_GENERATOR
bool "DC generator, e.g. wind turbine"
config HV_TERMINAL_BATTERY
bool "Battery, e.g. electric bicycle"
endchoice
choice
prompt "Low-voltage terminal"
help
Select the device connected to the low-voltage side
of the charge controller (usually battery terminal).
config LV_TERMINAL_BATTERY
depends on !HV_TERMINAL_BATTERY
bool "Battery 12V/24V"
config LV_TERMINAL_SOLAR
depends on HV_TERMINAL_BATTERY || HV_TERMINAL_NANOGRID
bool "Solar panel"
endchoice
choice
prompt "PWM terminal"
depends on $(dt_compat_enabled,pwm-switch)
help
Select the device connected to the PWM switch (currently
only solar panel possible)
config PWM_TERMINAL_SOLAR
depends on LV_TERMINAL_BATTERY && !HV_TERMINAL_SOLAR
bool "Solar panel"
endchoice
menu "Battery configuration"
choice
prompt "Default battery cell type"
default BAT_DEFAULT_TYPE_GEL
help
Select the type of the single cells inside the battery
to determine voltage set points. Total voltage set points
are multiplied with the selected number of cells.
config BAT_DEFAULT_TYPE_FLOODED
bool "Flooded (wet) lead-acid"
config BAT_DEFAULT_TYPE_GEL
bool "VRLA gel, maintainance-free"
config BAT_DEFAULT_TYPE_AGM
bool "AGM, maintainance-free"
config BAT_DEFAULT_TYPE_LFP
bool "LiFePO4 Li-ion, 3.3V nominal"
config BAT_DEFAULT_TYPE_NMC
bool "NMC/Graphite Li-ion, 3.7V nominal, 4.2V max"
config BAT_DEFAULT_TYPE_NMC_HV
bool "NMC/Graphite High Voltage Li-ion, 3.7V nominal, 4.35 max"
endchoice
config BAT_DEFAULT_NUM_CELLS
int "Default number of battery cells"
default 6
range 3 16
help
Typical choices:
- 6 for 12V lead-acid battery
- 4 for 12V LiFePO4 battery
- 3 for 12V NMC Li-ion battery
Remarks:
- If you choose settings for 12V system, 24V systems
(2 batteries in series) are recognized automatically
- Make sure the voltage of the used charge controller
is not exceeded.
config BAT_DEFAULT_CAPACITY_AH
int "Default battery capacity in Ah"
range 10 200
default 50
endmenu
menu "Extensions and interfaces"
config EXT_OLED_DISPLAY
bool "OLED display at UEXT"
config EXT_OLED_BRIGHTNESS
depends on EXT_OLED_DISPLAY
int "OLED display brightness"
range 1 255
default 1
config EXT_THINGSET_SERIAL
bool "ThingSet serial interface"
config EXT_THINGSET_SERIAL_RX_BUF_SIZE
depends on EXT_THINGSET_SERIAL
int "ThingSet serial RX buffer size"
range 64 2048
default 512
config EXT_THINGSET_SERIAL_TX_BUF_SIZE
depends on EXT_THINGSET_SERIAL
int "ThingSet serial TX buffer size"
range 256 2048
default 1024
config EXT_THINGSET_CAN
depends on CAN
bool "ThingSet CAN interface"
config DEVICE_ID
int "Initial device ID for communication interfaces"
default 0
endmenu
-67
View File
@@ -1,67 +0,0 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2019 Martin Jäger (Libre Solar)
#
# Invisible (hardware-specific) Kconfig symbols
#
config DEVICE_TYPE
string
help
Device type name, e.g. MPPT-2420-LC
config HARDWARE_VERSION
string
help
Version of the PCB
config HAS_LOAD_OUTPUT
bool
help
PCB has a load output.
config HAS_USB_PWR_OUTPUT
bool
help
PCB has a USB power output.
config CONTROL_FREQUENCY
int
default 10
help
Main control function frequency (Hz)
Frequencies higher than 10 Hz caused issues with MPPT control during lab test with
PV simulator. Might be different with actual solar panel.
config MOSFET_MAX_JUNCTION_TEMP
int
default 120
help
Maximum Tj of MOSFETs (°C)
This value is used for model-based control of overcurrent protection. It represents
the steady-state junction temperature for max. continuous current at ambient
temperature of 25°C.
config INTERNAL_MAX_REFERENCE_TEMP
int
default 50
help
Internal reference temperature at full load (°C)
This value is used for model-based control of overcurrent protection. It represents
the steady-state internal temperature for max. continuous current at ambient
temperature of 25°C. Value here is conservative and can be overwritten in PCB
configuration.
config MOSFET_THERMAL_TIME_CONSTANT
int
default 5
help
Thermal time constant junction to ambient (s)
This value is used for model-based control of overcurrent protection. It does not reflect
the much lower MOSFET-internal time constant junction to case, but includes thermal
inertia of the board.
Around 5s seems to be a good conservative estimation for 5x6 type SMD MOSFETs
-146
View File
@@ -1,146 +0,0 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2019 Martin Jäger (Libre Solar)
#
# Visible (user-configurable) Kconfig symbols
#
choice
prompt "High-voltage terminal"
depends on $(dt_compat_enabled,dcdc)
help
Select the device connected to the high-voltage
side terminal of the DC/DC converter.
config HV_TERMINAL_SOLAR
bool "Solar panel"
config HV_TERMINAL_NANOGRID
bool "DC nanogrid"
config HV_TERMINAL_GENERATOR
bool "DC generator, e.g. wind turbine"
config HV_TERMINAL_BATTERY
bool "Battery, e.g. electric bicycle"
endchoice
choice
prompt "Low-voltage terminal"
help
Select the device connected to the low-voltage side
of the charge controller (usually battery terminal).
config LV_TERMINAL_BATTERY
depends on !HV_TERMINAL_BATTERY
bool "Battery 12V/24V"
config LV_TERMINAL_SOLAR
depends on HV_TERMINAL_BATTERY || HV_TERMINAL_NANOGRID
bool "Solar panel"
endchoice
choice
prompt "PWM terminal"
depends on $(dt_compat_enabled,pwm-switch)
help
Select the device connected to the PWM switch (currently
only solar panel possible)
config PWM_TERMINAL_SOLAR
depends on LV_TERMINAL_BATTERY && !HV_TERMINAL_SOLAR
bool "Solar panel"
endchoice
menu "Battery configuration"
choice
prompt "Default battery cell type"
default BAT_DEFAULT_TYPE_GEL
help
Select the type of the single cells inside the battery
to determine voltage set points. Total voltage set points
are multiplied with the selected number of cells.
config BAT_DEFAULT_TYPE_FLOODED
bool "Flooded (wet) lead-acid"
config BAT_DEFAULT_TYPE_GEL
bool "VRLA gel, maintainance-free"
config BAT_DEFAULT_TYPE_AGM
bool "AGM, maintainance-free"
config BAT_DEFAULT_TYPE_LFP
bool "LiFePO4 Li-ion, 3.3V nominal"
config BAT_DEFAULT_TYPE_NMC
bool "NMC/Graphite Li-ion, 3.7V nominal, 4.2V max"
config BAT_DEFAULT_TYPE_NMC_HV
bool "NMC/Graphite High Voltage Li-ion, 3.7V nominal, 4.35 max"
endchoice
config BAT_DEFAULT_NUM_CELLS
int "Default number of battery cells"
default 6
range 3 16
help
Typical choices:
- 6 for 12V lead-acid battery
- 4 for 12V LiFePO4 battery
- 3 for 12V NMC Li-ion battery
Remarks:
- If you choose settings for 12V system, 24V systems
(2 batteries in series) are recognized automatically
- Make sure the voltage of the used charge controller
is not exceeded.
config BAT_DEFAULT_CAPACITY_AH
int "Default battery capacity in Ah"
range 10 200
default 50
endmenu
menu "Extensions and interfaces"
config EXT_OLED_DISPLAY
bool "OLED display at UEXT"
config EXT_OLED_BRIGHTNESS
depends on EXT_OLED_DISPLAY
int "OLED display brightness"
range 1 255
default 1
config EXT_THINGSET_SERIAL
bool "ThingSet serial interface"
config EXT_THINGSET_SERIAL_RX_BUF_SIZE
depends on EXT_THINGSET_SERIAL
int "ThingSet serial RX buffer size"
range 64 2048
default 512
config EXT_THINGSET_SERIAL_TX_BUF_SIZE
depends on EXT_THINGSET_SERIAL
int "ThingSet serial TX buffer size"
range 256 2048
default 1024
config EXT_THINGSET_CAN
depends on CAN
bool "ThingSet CAN interface"
config DEVICE_ID
int "Initial device ID for communication interfaces"
default 0
endmenu
@@ -11,7 +11,7 @@
model = "Libre Solar MPPT 1210 HUS v0.4";
compatible = "st,stm32l073";
charge-controller {
pcb {
compatible = "charge-controller";
hs-voltage-max = <40>;
ls-voltage-max = <16>;
@@ -11,7 +11,7 @@
model = "Libre Solar MPPT 1210 HUS v0.7";
compatible = "st,stm32l073";
charge-controller {
pcb {
compatible = "charge-controller";
hs-voltage-max = <40>;
ls-voltage-max = <16>;
+1 -1
View File
@@ -42,7 +42,7 @@
};
};
charge-controller {
pcb {
compatible = "charge-controller";
hs-voltage-max = <80>;
ls-voltage-max = <32>;
@@ -11,7 +11,7 @@
model = "Libre Solar MPPT 2420 LC v0.10";
compatible = "st,stm32f072";
charge-controller {
pcb {
compatible = "charge-controller";
hs-voltage-max = <55>;
ls-voltage-max = <32>;
-6
View File
@@ -17,12 +17,6 @@
#define LOAD_CURRENT_MAX 15 // PCB maximum load switch current
// The MCU, where internal temperature is measured, is close to the MOSFETs. Tests showed that
// temperature at heat sink is only 10-20°C above measured internal temp. As PWM CC doesn't
// use electrolytic cap for core charging function, internal temperature of 70°C can be allowed.
// This value is used for thermal overcurrent model.
#define INTERNAL_MAX_REFERENCE_TEMP 70
#define PIN_UEXT_TX PA_2
#define PIN_UEXT_RX PA_3
#define PIN_UEXT_SCL PB_6
@@ -11,10 +11,15 @@
model = "Libre Solar PWM 2420 LUS v0.3";
compatible = "st,stm32l073";
charge-controller {
pcb {
compatible = "charge-controller";
hs-voltage-max = <55>;
ls-voltage-max = <32>;
// The MCU, where internal temperature is measured, is close to the MOSFETs. Tests
// showed that temperature at heat sink is only 10-20°C above measured internal
// temp. As PWM CC doesn't use electrolytic cap for core charging function,
// internal temperature of 70°C can be allowed (instead of default 50°C).
internal-tref-max = <70>;
};
pwm-switch {
+2 -2
View File
@@ -39,8 +39,8 @@ Dcdc::Dcdc(PowerPort *hv_side, PowerPort *lv_side, DcdcOperationMode op_mode)
lvs->neg_current_limit = -DT_INST_0_DCDC_CURRENT_MAX;
lvs->pos_current_limit = DT_INST_0_DCDC_CURRENT_MAX;
ls_current_max = DT_INST_0_DCDC_CURRENT_MAX;
hs_voltage_max = DT_INST_0_CHARGE_CONTROLLER_HS_VOLTAGE_MAX;
ls_voltage_max = DT_INST_0_CHARGE_CONTROLLER_LS_VOLTAGE_MAX;
hs_voltage_max = DT_CHARGE_CONTROLLER_PCB_HS_VOLTAGE_MAX;
ls_voltage_max = DT_CHARGE_CONTROLLER_PCB_LS_VOLTAGE_MAX;
ls_voltage_min = 9.0;
output_power_min = 1; // switch off if power < 1 W
restart_interval = 60;
+7 -8
View File
@@ -43,13 +43,12 @@ void LoadOutput::control()
// junction temperature calculation model for overcurrent detection
junction_temperature = junction_temperature + (
dev_stat.internal_temp - junction_temperature +
current * current /
(LOAD_CURRENT_MAX * LOAD_CURRENT_MAX) *
(CONFIG_MOSFET_MAX_JUNCTION_TEMP - CONFIG_INTERNAL_MAX_REFERENCE_TEMP)
) / (CONFIG_MOSFET_THERMAL_TIME_CONSTANT * CONFIG_CONTROL_FREQUENCY);
dev_stat.internal_temp - junction_temperature + current * current /
(LOAD_CURRENT_MAX * LOAD_CURRENT_MAX) *
(DT_CHARGE_CONTROLLER_PCB_MOSFETS_TJ_MAX - DT_CHARGE_CONTROLLER_PCB_INTERNAL_TREF_MAX)
) / (DT_CHARGE_CONTROLLER_PCB_MOSFETS_TAU_JA * CONFIG_CONTROL_FREQUENCY);
if (junction_temperature > CONFIG_MOSFET_MAX_JUNCTION_TEMP ||
if (junction_temperature > DT_CHARGE_CONTROLLER_PCB_MOSFETS_TJ_MAX ||
current > LOAD_CURRENT_MAX * 2)
{
flags_set(&error_flags, ERR_LOAD_OVERCURRENT);
@@ -69,7 +68,7 @@ void LoadOutput::control()
// long-term overvoltage (overvoltage transients are detected as an ADC alert and switch
// off the solar input instead of the load output)
if (bus->voltage > overvoltage || bus->voltage >
DT_INST_0_CHARGE_CONTROLLER_LS_VOLTAGE_MAX)
DT_CHARGE_CONTROLLER_PCB_LS_VOLTAGE_MAX)
{
ov_debounce_counter++;
if (ov_debounce_counter > CONFIG_CONTROL_FREQUENCY) {
@@ -108,7 +107,7 @@ void LoadOutput::control()
if (flags_check(&error_flags, ERR_LOAD_OVERVOLTAGE) &&
bus->voltage < (overvoltage - ov_hysteresis) &&
bus->voltage < (DT_INST_0_CHARGE_CONTROLLER_LS_VOLTAGE_MAX - ov_hysteresis))
bus->voltage < (DT_CHARGE_CONTROLLER_PCB_LS_VOLTAGE_MAX - ov_hysteresis))
{
flags_clear(&error_flags, ERR_LOAD_OVERVOLTAGE);
}
+5 -5
View File
@@ -42,14 +42,14 @@
// Values that are otherwise defined by Kconfig
#define CONFIG_CONTROL_FREQUENCY 10 // Hz
#define CONFIG_MOSFET_MAX_JUNCTION_TEMP 120
#define CONFIG_INTERNAL_MAX_REFERENCE_TEMP 50
#define CONFIG_MOSFET_THERMAL_TIME_CONSTANT 5
#define DT_CHARGE_CONTROLLER_PCB_MOSFETS_TJ_MAX 120
#define DT_CHARGE_CONTROLLER_PCB_INTERNAL_TREF_MAX 50
#define DT_CHARGE_CONTROLLER_PCB_MOSFETS_TAU_JA 5
#define LOAD_CURRENT_MAX 20 // PCB maximum load switch current
#define DT_INST_0_CHARGE_CONTROLLER_LS_VOLTAGE_MAX 32 // Maximum voltage at battery port (V)
#define DT_INST_0_CHARGE_CONTROLLER_HS_VOLTAGE_MAX 55 // Maximum voltage at PV input port (V)
#define DT_CHARGE_CONTROLLER_PCB_LS_VOLTAGE_MAX 32 // Maximum voltage at battery port (V)
#define DT_CHARGE_CONTROLLER_PCB_HS_VOLTAGE_MAX 55 // Maximum voltage at PV input port (V)
#define PIN_UEXT_TX 0
#define PIN_UEXT_RX 0
+1 -1
View File
@@ -106,7 +106,7 @@ void control_on_to_off_overcurrent()
TEST_ASSERT_EQUAL(LOAD_STATE_ON, load_out.state);
// almost 2x current = 4x heat generation: Should definitely trigger after waiting one time constant
int trigger_steps = CONFIG_MOSFET_THERMAL_TIME_CONSTANT * CONFIG_CONTROL_FREQUENCY;
int trigger_steps = DT_CHARGE_CONTROLLER_PCB_MOSFETS_TAU_JA * CONFIG_CONTROL_FREQUENCY;
for (int i = 0; i <= trigger_steps; i++) {
load_out.control();
}
@@ -14,3 +14,34 @@ properties:
type: int
required: true
description: Maximum voltage at low-side (typically battery) in volts
internal-tref-max:
type: int
default: 50
description: |
Internal reference temperature at full load (°C)
This value is used for model-based control of overcurrent protection. It represents
the steady-state internal temperature for max. continuous current at ambient
temperature of 25°C. Default value is conservative and can be overwritten in PCB
configuration.
mosfets-tj-max:
type: int
default: 120
description: |
Maximum Tj of MOSFETs (°C)
This value is used for model-based control of overcurrent protection. It represents
the steady-state junction temperature for max. continuous current at ambient
temperature of 25°C.
mosfets-tau-ja:
type: int
default: 5
description: |
Thermal time constant junction to ambient (s)
This value is used for model-based control of overcurrent protection. It does not reflect
the much lower MOSFET-internal time constant junction to case, but includes thermal
inertia of the board.
Around 5s seems to be a good conservative estimation for 5x6 type SMD MOSFETs. Take larger
values for big heat sinks.