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
+4 -4
View File
@@ -152,7 +152,7 @@ void PwmSwitch::control()
off_timestamp = time(NULL);
printf("PWM charger stop.\n");
}
else if (port_int->bus->voltage > (port_int->bus->chg_voltage_target - port_int->chg_droop_res * port_int->current) // output voltage above target
else if (port_int->voltage > (port_int->chg_voltage_target - port_int->chg_droop_res * port_int->current) // output voltage above target
|| port_int->current > port_int->chg_current_limit // output current limit exceeded
|| terminal->current < terminal->dis_current_limit) // input current (negative signs) above limit
{
@@ -184,10 +184,10 @@ void PwmSwitch::control()
}
else {
if (port_int->chg_current_limit > 0 // charging allowed
&& port_int->bus->voltage < port_int->bus->chg_voltage_target
&& port_int->bus->voltage > port_int->bus->chg_voltage_min
&& port_int->voltage < port_int->chg_voltage_target
&& port_int->voltage > port_int->chg_voltage_min
&& terminal->dis_current_limit < 0 // dischraging allowed
&& terminal->bus->voltage > port_int->bus->voltage + offset_voltage_start
&& terminal->voltage > port_int->voltage + offset_voltage_start
&& time(NULL) > (off_timestamp + restart_interval)
&& enabled == true)
{