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:
+8
-9
@@ -22,8 +22,8 @@ void PowerPort::init_solar()
|
||||
chg_current_limit = 0; // no current towards solar panel allowed
|
||||
|
||||
// also initialize the connected bus
|
||||
bus->dis_voltage_start = 16.0;
|
||||
bus->dis_voltage_stop = 14.0;
|
||||
dis_voltage_start = 16.0;
|
||||
dis_voltage_stop = 14.0;
|
||||
}
|
||||
|
||||
void PowerPort::init_nanogrid()
|
||||
@@ -35,11 +35,11 @@ void PowerPort::init_nanogrid()
|
||||
chg_droop_res = 0.1; // 1 Ohm means 1V change of target voltage per amp
|
||||
|
||||
// also initialize the connected bus
|
||||
bus->dis_voltage_start = 30.0; // starting buck mode above this point
|
||||
bus->dis_voltage_stop = 20.0; // stopping buck mode below this point
|
||||
dis_voltage_start = 30.0; // starting buck mode above this point
|
||||
dis_voltage_stop = 20.0; // stopping buck mode below this point
|
||||
|
||||
bus->chg_voltage_target = 28.0; // starting idle mode above this point
|
||||
bus->chg_voltage_min = 10.0;
|
||||
chg_voltage_target = 28.0; // starting idle mode above this point
|
||||
chg_voltage_min = 10.0;
|
||||
}
|
||||
|
||||
// must be called exactly once per second, otherwise energy calculation gets wrong
|
||||
@@ -47,10 +47,9 @@ void PowerPort::energy_balance()
|
||||
{
|
||||
// remark: timespan = 1s, so no multiplication with time necessary for energy calculation
|
||||
if (current >= 0) {
|
||||
chg_energy_Wh += bus->voltage * current / 3600.0;
|
||||
chg_energy_Wh += voltage * current / 3600.0;
|
||||
}
|
||||
else {
|
||||
dis_energy_Wh -= bus->voltage * current / 3600.0;
|
||||
dis_energy_Wh -= voltage * current / 3600.0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user