Voltage replaced by DcBus ptr in PowerPort class
Preparation to separate current and voltage measurements and control parameters into DcBus and PowerPort classes. This will help to manage current from different sources (grid, solar) going towards one bus and control the battery voltage. It will also help to align multiple charge controllers in parallel, communicating via CAN bus.
This commit is contained in:
+19
-19
@@ -17,13 +17,13 @@
|
||||
static void init_structs_buck()
|
||||
{
|
||||
hv_terminal.init_solar();
|
||||
hv_terminal.voltage = 20;
|
||||
hv_terminal.bus->voltage = 20;
|
||||
hv_terminal.src_voltage_start = 18;
|
||||
hv_terminal.current = 0;
|
||||
|
||||
battery_conf_init(&bat_conf, BAT_TYPE_GEL, 6, 100);
|
||||
battery_init_dc_bus(&dcdc_lv_port, &bat_conf, 1);
|
||||
dcdc_lv_port.voltage = 14;
|
||||
dcdc_lv_port.bus->voltage = 14;
|
||||
dcdc_lv_port.current = 0;
|
||||
|
||||
dcdc.mode = MODE_MPPT_BUCK;
|
||||
@@ -49,14 +49,14 @@ static void init_structs_boost()
|
||||
half_bridge_stop();
|
||||
|
||||
hv_terminal.init_solar();
|
||||
dcdc_lv_port.voltage = 20;
|
||||
dcdc_lv_port.bus->voltage = 20;
|
||||
dcdc_lv_port.src_voltage_start = 18;
|
||||
dcdc_lv_port.current = 0;
|
||||
dcdc_lv_port.power = 0;
|
||||
|
||||
battery_conf_init(&bat_conf, BAT_TYPE_NMC, 10, 9);
|
||||
battery_init_dc_bus(&hv_terminal, &bat_conf, 1);
|
||||
hv_terminal.voltage = 3.7 * 10;
|
||||
hv_terminal.bus->voltage = 3.7 * 10;
|
||||
hv_terminal.current = 0;
|
||||
hv_terminal.power = 0;
|
||||
|
||||
@@ -109,7 +109,7 @@ void no_start_if_dcdc_disabled()
|
||||
void no_start_if_dcdc_lv_voltage_low()
|
||||
{
|
||||
init_structs_buck();
|
||||
dcdc_lv_port.voltage = dcdc.ls_voltage_min - 0.5;
|
||||
dcdc_lv_port.bus->voltage = dcdc.ls_voltage_min - 0.5;
|
||||
TEST_ASSERT_EQUAL(0, dcdc.check_start_conditions());
|
||||
}
|
||||
|
||||
@@ -118,14 +118,14 @@ void no_start_if_dcdc_lv_voltage_low()
|
||||
void no_buck_start_if_bat_voltage_low()
|
||||
{
|
||||
init_structs_buck();
|
||||
dcdc_lv_port.voltage = bat_conf.voltage_absolute_min - 0.1;
|
||||
dcdc_lv_port.bus->voltage = bat_conf.voltage_absolute_min - 0.1;
|
||||
TEST_ASSERT_EQUAL(0, dcdc.check_start_conditions());
|
||||
}
|
||||
|
||||
void no_buck_start_if_bat_voltage_high()
|
||||
{
|
||||
init_structs_buck();
|
||||
dcdc_lv_port.voltage = bat_conf.topping_voltage + 0.1;
|
||||
dcdc_lv_port.bus->voltage = bat_conf.topping_voltage + 0.1;
|
||||
TEST_ASSERT_EQUAL(0, dcdc.check_start_conditions());
|
||||
}
|
||||
|
||||
@@ -139,14 +139,14 @@ void no_buck_start_if_bat_chg_not_allowed()
|
||||
void no_buck_start_if_solar_voltage_high()
|
||||
{
|
||||
init_structs_buck();
|
||||
hv_terminal.voltage = dcdc.hs_voltage_max + 1;
|
||||
hv_terminal.bus->voltage = dcdc.hs_voltage_max + 1;
|
||||
TEST_ASSERT_EQUAL(0, dcdc.check_start_conditions());
|
||||
}
|
||||
|
||||
void no_buck_start_if_solar_voltage_low()
|
||||
{
|
||||
init_structs_buck();
|
||||
hv_terminal.voltage = 17;
|
||||
hv_terminal.bus->voltage = 17;
|
||||
TEST_ASSERT_EQUAL(0, dcdc.check_start_conditions());
|
||||
}
|
||||
|
||||
@@ -155,14 +155,14 @@ void no_buck_start_if_solar_voltage_low()
|
||||
void no_boost_start_if_bat_voltage_low()
|
||||
{
|
||||
init_structs_boost();
|
||||
hv_terminal.voltage = bat_conf.voltage_absolute_min - 0.1;
|
||||
hv_terminal.bus->voltage = bat_conf.voltage_absolute_min - 0.1;
|
||||
TEST_ASSERT_EQUAL(0, dcdc.check_start_conditions());
|
||||
}
|
||||
|
||||
void no_boost_start_if_bat_voltage_high()
|
||||
{
|
||||
init_structs_boost();
|
||||
hv_terminal.voltage = bat_conf.topping_voltage + 0.1;
|
||||
hv_terminal.bus->voltage = bat_conf.topping_voltage + 0.1;
|
||||
TEST_ASSERT_EQUAL(0, dcdc.check_start_conditions());
|
||||
}
|
||||
|
||||
@@ -176,14 +176,14 @@ void no_boost_start_if_bat_chg_not_allowed()
|
||||
void no_boost_start_if_solar_voltage_high()
|
||||
{
|
||||
init_structs_boost();
|
||||
dcdc_lv_port.voltage = dcdc.ls_voltage_max + 1;
|
||||
dcdc_lv_port.bus->voltage = dcdc.ls_voltage_max + 1;
|
||||
TEST_ASSERT_EQUAL(0, dcdc.check_start_conditions());
|
||||
}
|
||||
|
||||
void no_boost_start_if_solar_voltage_low()
|
||||
{
|
||||
init_structs_boost();
|
||||
dcdc_lv_port.voltage = 17;
|
||||
dcdc_lv_port.bus->voltage = 17;
|
||||
TEST_ASSERT_EQUAL(0, dcdc.check_start_conditions());
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ void buck_derating_output_voltage_too_high()
|
||||
{
|
||||
start_buck();
|
||||
float pwm_before = half_bridge_get_duty_cycle();
|
||||
dcdc_lv_port.voltage = dcdc_lv_port.sink_voltage_max + 0.1;
|
||||
dcdc_lv_port.bus->voltage = dcdc_lv_port.sink_voltage_max + 0.1;
|
||||
dcdc.control();
|
||||
float pwm_after = half_bridge_get_duty_cycle();
|
||||
TEST_ASSERT(pwm_after < pwm_before); // less duty cycle = higher voltage
|
||||
@@ -224,7 +224,7 @@ void buck_derating_input_voltage_too_low()
|
||||
{
|
||||
start_buck();
|
||||
float pwm_before = half_bridge_get_duty_cycle();
|
||||
hv_terminal.voltage = hv_terminal.src_voltage_stop - 0.1;
|
||||
hv_terminal.bus->voltage = hv_terminal.src_voltage_stop - 0.1;
|
||||
dcdc_lv_port.current = 0.2;
|
||||
dcdc.control();
|
||||
float pwm_after = half_bridge_get_duty_cycle();
|
||||
@@ -264,7 +264,7 @@ void buck_stop_input_power_too_low()
|
||||
void buck_stop_high_voltage_emergency()
|
||||
{
|
||||
start_buck();
|
||||
dcdc_lv_port.voltage = dcdc.ls_voltage_max + 0.1;
|
||||
dcdc_lv_port.bus->voltage = dcdc.ls_voltage_max + 0.1;
|
||||
dcdc.control();
|
||||
TEST_ASSERT(half_bridge_enabled() == false);
|
||||
}
|
||||
@@ -303,7 +303,7 @@ void boost_derating_output_voltage_too_high()
|
||||
{
|
||||
start_boost();
|
||||
float pwm_before = half_bridge_get_duty_cycle();
|
||||
hv_terminal.voltage = hv_terminal.sink_voltage_max + 0.5;
|
||||
hv_terminal.bus->voltage = hv_terminal.sink_voltage_max + 0.5;
|
||||
dcdc.control();
|
||||
float pwm_after = half_bridge_get_duty_cycle();
|
||||
TEST_ASSERT(pwm_after > pwm_before); // higher duty cycle = less power
|
||||
@@ -323,7 +323,7 @@ void boost_derating_input_voltage_too_low()
|
||||
{
|
||||
start_boost();
|
||||
float pwm_before = half_bridge_get_duty_cycle();
|
||||
dcdc_lv_port.voltage = dcdc_lv_port.src_voltage_stop - 0.1;
|
||||
dcdc_lv_port.bus->voltage = dcdc_lv_port.src_voltage_stop - 0.1;
|
||||
hv_terminal.current = 0.2;
|
||||
dcdc.control();
|
||||
float pwm_after = half_bridge_get_duty_cycle();
|
||||
@@ -361,7 +361,7 @@ void boost_stop_input_power_too_low()
|
||||
void boost_stop_high_voltage_emergency()
|
||||
{
|
||||
start_boost();
|
||||
hv_terminal.voltage = dcdc.hs_voltage_max + 0.1;
|
||||
hv_terminal.bus->voltage = dcdc.hs_voltage_max + 0.1;
|
||||
dcdc.control();
|
||||
TEST_ASSERT(half_bridge_enabled() == false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user