DC bus integrated into PowerPort class

Reason: Previous idea with storing the voltage only once and not in every port
doesn't work well for droop settings, e.g. the DC/DC output port doesn't know
the actual battery current, which should be used to calculate the droop caued
by wire resistance.
This commit is contained in:
Martin Jaeger
2019-10-22 18:23:19 +02:00
parent a89ac7ff4b
commit f879dc9c5d
22 changed files with 191 additions and 234 deletions
+8 -12
View File
@@ -42,21 +42,17 @@
#include "thingset_serial.h" // UART or USB serial communication
#include "thingset_can.h" // CAN bus communication
DcBus lv_bus;
PowerPort lv_terminal(&lv_bus); // low voltage terminal (battery for typical MPPT)
PowerPort lv_terminal; // low voltage terminal (battery for typical MPPT)
#if FEATURE_DCDC_CONVERTER
DcBus hv_bus;
PowerPort hv_terminal(&hv_bus); // high voltage terminal (solar for typical MPPT)
PowerPort dcdc_port_hv(&hv_bus); // internal high voltage side port of DC/DC converter
PowerPort dcdc_port_lv(&lv_bus); // internal low voltage side of DC/DC converter
Dcdc dcdc(&dcdc_port_hv, &dcdc_port_lv, DCDC_MODE_INIT);
PowerPort hv_terminal; // high voltage terminal (solar for typical MPPT)
PowerPort dcdc_lv_port; // internal low voltage side of DC/DC converter
Dcdc dcdc(&hv_terminal, &dcdc_lv_port, DCDC_MODE_INIT);
#endif
#if FEATURE_PWM_SWITCH
DcBus pwm_bus;
PowerPort pwm_terminal(&pwm_bus); // external terminal of PWM switch port (normally solar)
PowerPort pwm_port_int(&lv_bus); // internal side of PWM switch
PowerPort pwm_terminal; // external terminal of PWM switch port (normally solar)
PowerPort pwm_port_int; // internal side of PWM switch
PwmSwitch pwm_switch(&pwm_terminal, &pwm_port_int);
PowerPort &solar_terminal = pwm_terminal;
#else
@@ -64,7 +60,7 @@ PowerPort &solar_terminal = SOLAR_TERMINAL; // defined in config.h
#endif
#if FEATURE_LOAD_OUTPUT
PowerPort load_terminal(&lv_bus); // load terminal (also connected to lv_bus)
PowerPort load_terminal; // load terminal (also connected to lv_bus)
LoadOutput load(&load_terminal);
#endif
@@ -152,7 +148,7 @@ int main()
charger.charge_control(&bat_conf);
#if FEATURE_DCDC_CONVERTER
update_dcdc_current_targets(&dcdc_port_lv, &bat_terminal, &load_terminal);
update_dcdc_current_targets(&dcdc_lv_port, &bat_terminal, &load_terminal);
#endif
load.state_machine();