Rename src/sink_voltage_bound to _intercept

These variables define the voltage at zero current, which is the y axis
intercept of the droop curve (voltage vs. current).
As they do not always specifiy minimum or maximum boundary depending on
the sign of the droop resistance, intercept is a more suitable name.
This commit is contained in:
Martin Jäger
2020-11-05 20:42:00 +01:00
parent 7cd89bc04a
commit 0756341b29
7 changed files with 32 additions and 32 deletions
+10 -10
View File
@@ -462,7 +462,7 @@ void Charger::charge_control(BatConf *bat_conf)
&& bat_temperature < bat_conf->charge_temp_max - 1
&& bat_temperature > bat_conf->charge_temp_min + 1)
{
port->bus->sink_voltage_bound = bat_conf->topping_voltage +
port->bus->sink_voltage_intercept = bat_conf->topping_voltage +
bat_conf->temperature_compensation * (bat_temperature - 25);
port->pos_current_limit = bat_conf->charge_current_max;
full = false;
@@ -475,7 +475,7 @@ void Charger::charge_control(BatConf *bat_conf)
}
case CHG_STATE_BULK: {
// continuously adjust voltage setting for temperature compensation
port->bus->sink_voltage_bound = bat_conf->topping_voltage +
port->bus->sink_voltage_intercept = bat_conf->topping_voltage +
bat_conf->temperature_compensation * (bat_temperature - 25);
if (port->bus->voltage > port->bus->sink_control_voltage()) {
@@ -486,7 +486,7 @@ void Charger::charge_control(BatConf *bat_conf)
}
case CHG_STATE_TOPPING: {
// continuously adjust voltage setting for temperature compensation
port->bus->sink_voltage_bound = bat_conf->topping_voltage +
port->bus->sink_voltage_intercept = bat_conf->topping_voltage +
bat_conf->temperature_compensation * (bat_temperature - 25);
if (port->bus->voltage >= port->bus->sink_control_voltage() - 0.05F) {
@@ -515,12 +515,12 @@ void Charger::charge_control(BatConf *bat_conf)
num_deep_discharges - deep_dis_last_equalization
>= bat_conf->equalization_trigger_deep_cycles))
{
port->bus->sink_voltage_bound = bat_conf->equalization_voltage;
port->bus->sink_voltage_intercept = bat_conf->equalization_voltage;
port->pos_current_limit = bat_conf->equalization_current_limit;
enter_state(CHG_STATE_EQUALIZATION);
}
else if (bat_conf->trickle_enabled) {
port->bus->sink_voltage_bound = bat_conf->trickle_voltage +
port->bus->sink_voltage_intercept = bat_conf->trickle_voltage +
bat_conf->temperature_compensation * (bat_temperature - 25);
enter_state(CHG_STATE_TRICKLE);
}
@@ -533,7 +533,7 @@ void Charger::charge_control(BatConf *bat_conf)
}
case CHG_STATE_TRICKLE: {
// continuously adjust voltage setting for temperature compensation
port->bus->sink_voltage_bound = bat_conf->trickle_voltage +
port->bus->sink_voltage_intercept = bat_conf->trickle_voltage +
bat_conf->temperature_compensation * (bat_temperature - 25);
if (port->bus->voltage >= port->bus->sink_control_voltage()) {
@@ -553,7 +553,7 @@ void Charger::charge_control(BatConf *bat_conf)
}
case CHG_STATE_EQUALIZATION: {
// continuously adjust voltage setting for temperature compensation
port->bus->sink_voltage_bound = bat_conf->equalization_voltage +
port->bus->sink_voltage_intercept = bat_conf->equalization_voltage +
bat_conf->temperature_compensation * (bat_temperature - 25);
// current or time limit for equalization reached
@@ -566,7 +566,7 @@ void Charger::charge_control(BatConf *bat_conf)
discharged_Ah = 0; // reset coulomb counter again
if (bat_conf->trickle_enabled) {
port->bus->sink_voltage_bound = bat_conf->trickle_voltage +
port->bus->sink_voltage_intercept = bat_conf->trickle_voltage +
bat_conf->temperature_compensation * (bat_temperature - 25);
enter_state(CHG_STATE_TRICKLE);
}
@@ -582,8 +582,8 @@ void Charger::charge_control(BatConf *bat_conf)
void Charger::init_terminal(BatConf *bat) const
{
port->bus->sink_voltage_bound = bat->topping_voltage;
port->bus->src_voltage_bound = bat->voltage_load_disconnect;
port->bus->sink_voltage_intercept = bat->topping_voltage;
port->bus->src_voltage_intercept = bat->voltage_load_disconnect;
port->neg_current_limit = -bat->discharge_current_max;
port->pos_current_limit = bat->charge_current_max;
+3 -3
View File
@@ -231,10 +231,10 @@ static DataNode data_nodes[] = {
#endif
#if CONFIG_HV_TERMINAL_NANOGRID
TS_NODE_FLOAT(0x65, "GridSink_V", &hv_bus.sink_voltage_bound, 2,
TS_NODE_FLOAT(0x65, "GridSink_V", &hv_bus.sink_voltage_intercept, 2,
ID_INPUT, TS_ANY_R | TS_ANY_W, 0),
TS_NODE_FLOAT(0x66, "GridSrc_V", &hv_bus.src_voltage_bound, 2,
TS_NODE_FLOAT(0x66, "GridSrc_V", &hv_bus.src_voltage_intercept, 2,
ID_INPUT, TS_ANY_R | TS_ANY_W, 0),
#endif
@@ -273,7 +273,7 @@ static DataNode data_nodes[] = {
ID_OUTPUT, TS_ANY_R, 0),
#endif
TS_NODE_FLOAT(0x7A, "ChgTarget_V", &bat_bus.sink_voltage_bound, 2,
TS_NODE_FLOAT(0x7A, "ChgTarget_V", &bat_bus.sink_voltage_intercept, 2,
ID_OUTPUT, TS_ANY_R, 0),
TS_NODE_FLOAT(0x7B, "ChgTarget_A", &bat_terminal.pos_current_limit, 2,
+1 -1
View File
@@ -129,7 +129,7 @@ int Dcdc::perturb_observe_controller()
"out: %.2fV (target %.2fV) %.2fA (limit %.2fA), "
"PWM: %.1f, chg_state: %d, pwr_inc: %d, buck/boost: %d\n",
out->power, power_prev, in->bus->voltage, in->current, in->neg_current_limit,
out->bus->voltage, out->bus->sink_voltage_bound, out->current, out->pos_current_limit,
out->bus->voltage, out->bus->sink_voltage_intercept, out->current, out->pos_current_limit,
half_bridge_get_duty_cycle() * 100.0, state, pwr_inc_goal, pwr_inc_pwm_direction);
#endif
+2 -2
View File
@@ -22,8 +22,8 @@ void PowerPort::init_nanogrid()
bus->src_droop_res = 0.1;
// also initialize the connected bus
bus->src_voltage_bound = 30.0; // starting buck mode above this point
bus->sink_voltage_bound = 28.0; // boost mode until this voltage is reached
bus->src_voltage_intercept = 30.0; // starting buck mode above this point
bus->sink_voltage_intercept = 28.0; // boost mode until this voltage is reached
}
void PowerPort::energy_balance()
+6 -6
View File
@@ -45,7 +45,7 @@ public:
* This value is the voltage at zero current. Values for other currents are calculated
* using the droop resistance.
*/
float sink_voltage_bound;
float sink_voltage_intercept;
/**
* Lower voltage boundary where this bus may be used to source current.
@@ -53,7 +53,7 @@ public:
* This value is the voltage at zero current. Values for other currents are calculated
* using the droop resistance.
*/
float src_voltage_bound;
float src_voltage_intercept;
/**
* Droop resistance to adjust voltage bounds for current in sourcing direction
@@ -91,11 +91,11 @@ public:
* Calculate current-compensated src control voltage, considering droop and series multiplier
*
* @param voltage_zero_current Voltage at zero current (without droop). If this parameter is
* left empty, the src_voltage_bound is considered.
* left empty, the src_voltage_intercept is considered.
*/
inline float src_control_voltage(float voltage_zero_current = 0)
{
float v0 = (voltage_zero_current == 0) ? src_voltage_bound : voltage_zero_current;
float v0 = (voltage_zero_current == 0) ? src_voltage_intercept : voltage_zero_current;
if (ref_current != nullptr) {
return (v0 - src_droop_res * (*ref_current)) * series_multiplier;
}
@@ -108,11 +108,11 @@ public:
* Calculate current-compensated sink control voltage, considering droop and series multiplier
*
* @param voltage_zero_current Voltage at zero current (without droop). If this parameter is
* left empty, the sink_voltage_bound is considered.
* left empty, the sink_voltage_intercept is considered.
*/
inline float sink_control_voltage(float voltage_zero_current = 0)
{
float v0 = (voltage_zero_current == 0) ? sink_voltage_bound : voltage_zero_current;
float v0 = (voltage_zero_current == 0) ? sink_voltage_intercept : voltage_zero_current;
if (ref_current != nullptr) {
return (v0 - sink_droop_res * (*ref_current)) * series_multiplier;
}
+6 -6
View File
@@ -19,7 +19,7 @@ static void init_structs_buck(int num_batteries = 1)
dev_stat.error_flags = 0;
hv_terminal.init_solar();
hv_terminal.bus->voltage = 20 * num_batteries;
hv_terminal.bus->src_voltage_bound = 18 * num_batteries;
hv_terminal.bus->src_voltage_intercept = 18 * num_batteries;
hv_terminal.bus->series_multiplier = 1;
hv_terminal.current = 0;
hv_terminal.update_bus_current_margins();
@@ -57,7 +57,7 @@ static void init_structs_boost(int num_batteries = 1)
hv_terminal.init_solar();
dcdc_lv_port.bus->voltage = 20;
dcdc_lv_port.bus->src_voltage_bound = 18;
dcdc_lv_port.bus->src_voltage_intercept = 18;
dcdc_lv_port.bus->series_multiplier = 1;
dcdc_lv_port.current = 0;
dcdc_lv_port.power = 0;
@@ -213,7 +213,7 @@ void buck_derating_output_voltage_too_high()
{
start_buck();
float pwm_before = half_bridge_get_duty_cycle();
dcdc_lv_port.bus->voltage = dcdc_lv_port.bus->sink_voltage_bound + 0.1;
dcdc_lv_port.bus->voltage = dcdc_lv_port.bus->sink_voltage_intercept + 0.1;
dcdc.control();
float pwm_after = half_bridge_get_duty_cycle();
TEST_ASSERT(pwm_after < pwm_before); // less duty cycle = higher voltage
@@ -235,7 +235,7 @@ void buck_derating_input_voltage_too_low()
{
start_buck();
float pwm_before = half_bridge_get_duty_cycle();
hv_terminal.bus->voltage = hv_terminal.bus->src_voltage_bound - 0.1;
hv_terminal.bus->voltage = hv_terminal.bus->src_voltage_intercept - 0.1;
dcdc_lv_port.current = 0.2;
dcdc.control();
float pwm_after = half_bridge_get_duty_cycle();
@@ -314,7 +314,7 @@ void boost_derating_output_voltage_too_high()
{
start_boost();
float pwm_before = half_bridge_get_duty_cycle();
hv_terminal.bus->voltage = hv_terminal.bus->sink_voltage_bound + 0.5;
hv_terminal.bus->voltage = hv_terminal.bus->sink_voltage_intercept + 0.5;
dcdc.control();
float pwm_after = half_bridge_get_duty_cycle();
TEST_ASSERT(pwm_after > pwm_before); // higher duty cycle = less power
@@ -334,7 +334,7 @@ void boost_derating_input_voltage_too_low()
{
start_boost();
float pwm_before = half_bridge_get_duty_cycle();
dcdc_lv_port.bus->voltage = dcdc_lv_port.bus->src_voltage_bound - 0.1;
dcdc_lv_port.bus->voltage = dcdc_lv_port.bus->src_voltage_intercept - 0.1;
hv_terminal.current = 0.2;
dcdc.control();
float pwm_after = half_bridge_get_duty_cycle();
+4 -4
View File
@@ -33,8 +33,8 @@ static void load_init(LoadOutput *l, bool on = false, int num_batteries = 1)
l->pos_current_limit = 10;
l->bus->series_multiplier = num_batteries;
l->bus->voltage = 14 * num_batteries;
l->bus->sink_voltage_bound = 14.4;
l->bus->src_voltage_bound = 12;
l->bus->sink_voltage_intercept = 14.4;
l->bus->src_voltage_intercept = 12;
l->bus->sink_current_margin = 10;
l->bus->src_current_margin = -10;
l->junction_temperature = 25;
@@ -93,7 +93,7 @@ void control_on_to_off_overvoltage()
LoadOutput load_out(&bus, &load_drv_set, &load_drv_init);
load_init(&load_out, true);
bus.voltage = bus.sink_voltage_bound + 0.6;
bus.voltage = bus.sink_voltage_intercept + 0.6;
// increase debounce counter to 1 before limit
for (int i = 0; i < CONFIG_CONTROL_FREQUENCY; i++) {
@@ -114,7 +114,7 @@ void control_on_to_off_overvoltage_dual_battery()
LoadOutput load_out(&bus, &load_drv_set, &load_drv_init);
load_init(&load_out, true, 2);
bus.voltage = (bus.sink_voltage_bound + 0.6) * bus.series_multiplier;
bus.voltage = (bus.sink_voltage_intercept + 0.6) * bus.series_multiplier;
// increase debounce counter to 1 before limit
for (int i = 0; i < CONFIG_CONTROL_FREQUENCY; i++) {