PowerPort member variables renamed
Previous naming with chg/dis didn't make much sense e.g. for load output or solar panels. Voltage targets are now named with source or sink. Current limits are defined based on their direction (negative or positive). ASCII art graphic added for better explanation of passive sign convention.
This commit is contained in:
+20
-20
@@ -18,28 +18,28 @@
|
||||
|
||||
void PowerPort::init_solar()
|
||||
{
|
||||
dis_current_limit = -50; // derating based on max. DC/DC or PWM switch current only
|
||||
chg_current_limit = 0; // no current towards solar panel allowed
|
||||
neg_current_limit = -50; // derating based on max. DC/DC or PWM switch current only
|
||||
pos_current_limit = 0; // no current towards solar panel allowed
|
||||
|
||||
// also initialize the connected bus
|
||||
dis_voltage_start = 16.0;
|
||||
dis_voltage_stop = 14.0;
|
||||
src_voltage_start = 16.0;
|
||||
src_voltage_stop = 14.0;
|
||||
}
|
||||
|
||||
void PowerPort::init_nanogrid()
|
||||
{
|
||||
dis_current_limit = -5.0;
|
||||
dis_droop_res = 0.1; // 1 Ohm means 1V change of target voltage per amp
|
||||
neg_current_limit = -5.0;
|
||||
neg_droop_res = 0.1; // 1 Ohm means 1V change of target voltage per amp
|
||||
|
||||
chg_current_limit = 5.0;
|
||||
chg_droop_res = 0.1; // 1 Ohm means 1V change of target voltage per amp
|
||||
pos_current_limit = 5.0;
|
||||
pos_droop_res = 0.1; // 1 Ohm means 1V change of target voltage per amp
|
||||
|
||||
// also initialize the connected bus
|
||||
dis_voltage_start = 30.0; // starting buck mode above this point
|
||||
dis_voltage_stop = 20.0; // stopping buck mode below this point
|
||||
src_voltage_start = 30.0; // starting buck mode above this point
|
||||
src_voltage_stop = 20.0; // stopping buck mode below this point
|
||||
|
||||
chg_voltage_target = 28.0; // starting idle mode above this point
|
||||
chg_voltage_min = 10.0;
|
||||
sink_voltage_max = 28.0; // starting idle mode above this point
|
||||
sink_voltage_min = 10.0;
|
||||
}
|
||||
|
||||
// must be called exactly once per second, otherwise energy calculation gets wrong
|
||||
@@ -47,28 +47,28 @@ void PowerPort::energy_balance()
|
||||
{
|
||||
// remark: timespan = 1s, so no multiplication with time necessary for energy calculation
|
||||
if (current >= 0) {
|
||||
chg_energy_Wh += voltage * current / 3600.0;
|
||||
pos_energy_Wh += voltage * current / 3600.0;
|
||||
}
|
||||
else {
|
||||
dis_energy_Wh -= voltage * current / 3600.0;
|
||||
neg_energy_Wh -= voltage * current / 3600.0;
|
||||
}
|
||||
}
|
||||
|
||||
void PowerPort::pass_voltage_targets(PowerPort *port)
|
||||
{
|
||||
// droop resistance added only to limits where current actually flows
|
||||
port->chg_voltage_min = chg_voltage_min;
|
||||
port->chg_voltage_target = chg_voltage_target + chg_droop_res * current;
|
||||
port->dis_voltage_start = dis_voltage_start + chg_droop_res * current;
|
||||
port->dis_voltage_stop = dis_voltage_stop + chg_droop_res * current;
|
||||
port->sink_voltage_min = sink_voltage_min;
|
||||
port->sink_voltage_max = sink_voltage_max + pos_droop_res * current;
|
||||
port->src_voltage_start = src_voltage_start + pos_droop_res * current;
|
||||
port->src_voltage_stop = src_voltage_stop + pos_droop_res * current;
|
||||
}
|
||||
|
||||
void ports_update_current_limits(PowerPort *p_dcdc, PowerPort *p_bat, PowerPort *p_load)
|
||||
{
|
||||
p_dcdc->chg_current_limit = p_bat->chg_current_limit - p_bat->current + p_load->current;
|
||||
p_dcdc->pos_current_limit = p_bat->pos_current_limit - p_bat->current + p_load->current;
|
||||
|
||||
// this is a bit tricky... in theory, we could add the available DC/DC current to keep the
|
||||
// load switched on as long as solar power is available, even if the battery is empty. This
|
||||
// needs a fast point-of-load (PoL) control of the DC/DC, which is not possible (yet).
|
||||
p_dcdc->dis_current_limit = p_bat->dis_current_limit - p_bat->current;
|
||||
p_dcdc->neg_current_limit = p_bat->neg_current_limit - p_bat->current;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user