Battery discharging control restructured
- Discharging control separated from charger state machine - Unit-tests for discharging control added - DC bus chg/dis_enabled flags removed, control now only based on chge/dis_current_limit values - _current_max values renamed to _limit to make more clear that values for discharging direction must be negative - Load output struct now stores pointer to internal and external DC bus objects
This commit is contained in:
+28
-24
@@ -30,8 +30,9 @@ void battery_conf_init(BatConf *bat, BatType type, int num_cells, float nominal_
|
||||
{
|
||||
bat->nominal_capacity = nominal_capacity;
|
||||
|
||||
// common values for all batteries
|
||||
bat->charge_current_max = bat->nominal_capacity; // 1C should be safe for all batteries
|
||||
// 1C should be safe for all batteries
|
||||
bat->charge_current_max = bat->nominal_capacity;
|
||||
bat->discharge_current_max = bat->nominal_capacity;
|
||||
|
||||
bat->time_limit_recharge = 60; // sec
|
||||
bat->topping_duration = 120*60; // sec
|
||||
@@ -275,17 +276,15 @@ static void _enter_state(Charger* charger, int next_state)
|
||||
charger->state = next_state;
|
||||
}
|
||||
|
||||
void charger_state_machine(DcBus *bus, BatConf *bat_conf, Charger *charger)
|
||||
void battery_discharge_control(DcBus *bus, BatConf *bat_conf, Charger *charger)
|
||||
{
|
||||
//printf("time_state_change = %d, time = %d, v_bat = %f, i_bat = %f\n", charger->time_state_changed, time(NULL), voltage, current);
|
||||
|
||||
// load output state is defined by battery bus dis_allowed flag
|
||||
if (bus->dis_allowed == true
|
||||
if (bus->dis_current_limit < 0 // discharging allowed
|
||||
&& bus->voltage < charger->num_batteries *
|
||||
(bat_conf->voltage_load_disconnect - bus->current * bus->dis_droop_res))
|
||||
{
|
||||
// low state of charge
|
||||
bus->dis_allowed = false;
|
||||
bus->dis_current_limit = 0;
|
||||
charger->num_deep_discharges++;
|
||||
|
||||
if (charger->usable_capacity < 0.1) {
|
||||
@@ -303,12 +302,12 @@ void charger_state_machine(DcBus *bus, BatConf *bat_conf, Charger *charger)
|
||||
// simple SOH estimation
|
||||
charger->soh = charger->usable_capacity / bat_conf->nominal_capacity;
|
||||
}
|
||||
else if (bus->dis_allowed == true
|
||||
else if (bus->dis_current_limit < 0
|
||||
&& (charger->bat_temperature > bat_conf->discharge_temp_max
|
||||
|| charger->bat_temperature < bat_conf->discharge_temp_min))
|
||||
{
|
||||
// temperature limits exceeded
|
||||
bus->dis_allowed = false;
|
||||
bus->dis_current_limit = 0;
|
||||
}
|
||||
|
||||
if (bus->voltage >= charger->num_batteries *
|
||||
@@ -316,14 +315,19 @@ void charger_state_machine(DcBus *bus, BatConf *bat_conf, Charger *charger)
|
||||
&& charger->bat_temperature < bat_conf->discharge_temp_max - 1
|
||||
&& charger->bat_temperature > bat_conf->discharge_temp_min + 1)
|
||||
{
|
||||
bus->dis_allowed = true;
|
||||
// discharge current is stored as absolute value in bat_conf, but defined
|
||||
// as negative current for dc_bus
|
||||
bus->dis_current_limit = -bat_conf->discharge_current_max;
|
||||
}
|
||||
}
|
||||
|
||||
void battery_charge_control(DcBus *bus, BatConf *bat_conf, Charger *charger)
|
||||
{
|
||||
// check battery temperature for charging direction
|
||||
if (charger->bat_temperature > bat_conf->charge_temp_max
|
||||
|| charger->bat_temperature < bat_conf->charge_temp_min)
|
||||
{
|
||||
bus->chg_allowed = false;
|
||||
bus->chg_current_limit = 0;
|
||||
_enter_state(charger, CHG_STATE_IDLE);
|
||||
}
|
||||
|
||||
@@ -337,8 +341,7 @@ void charger_state_machine(DcBus *bus, BatConf *bat_conf, Charger *charger)
|
||||
{
|
||||
bus->chg_voltage_target = charger->num_batteries * (bat_conf->topping_voltage +
|
||||
bat_conf->temperature_compensation * (charger->bat_temperature - 25));
|
||||
bus->chg_current_max = bat_conf->charge_current_max;
|
||||
bus->chg_allowed = true;
|
||||
bus->chg_current_limit = bat_conf->charge_current_max;
|
||||
charger->full = false;
|
||||
_enter_state(charger, CHG_STATE_BULK);
|
||||
}
|
||||
@@ -385,7 +388,7 @@ void charger_state_machine(DcBus *bus, BatConf *bat_conf, Charger *charger)
|
||||
>= bat_conf->equalization_trigger_deep_cycles))
|
||||
{
|
||||
bus->chg_voltage_target = bat_conf->equalization_voltage;
|
||||
bus->chg_current_max = bat_conf->equalization_current_limit;
|
||||
bus->chg_current_limit = bat_conf->equalization_current_limit;
|
||||
_enter_state(charger, CHG_STATE_EQUALIZATION);
|
||||
}
|
||||
else if (bat_conf->trickle_enabled) {
|
||||
@@ -394,8 +397,7 @@ void charger_state_machine(DcBus *bus, BatConf *bat_conf, Charger *charger)
|
||||
_enter_state(charger, CHG_STATE_TRICKLE);
|
||||
}
|
||||
else {
|
||||
bus->chg_current_max = 0;
|
||||
bus->chg_allowed = false;
|
||||
bus->chg_current_limit = 0;
|
||||
_enter_state(charger, CHG_STATE_IDLE);
|
||||
}
|
||||
}
|
||||
@@ -414,7 +416,7 @@ void charger_state_machine(DcBus *bus, BatConf *bat_conf, Charger *charger)
|
||||
|
||||
if (time(NULL) - charger->time_voltage_limit_reached > bat_conf->trickle_recharge_time)
|
||||
{
|
||||
bus->chg_current_max = bat_conf->charge_current_max;
|
||||
bus->chg_current_limit = bat_conf->charge_current_max;
|
||||
charger->full = false;
|
||||
_enter_state(charger, CHG_STATE_BULK);
|
||||
}
|
||||
@@ -442,8 +444,7 @@ void charger_state_machine(DcBus *bus, BatConf *bat_conf, Charger *charger)
|
||||
_enter_state(charger, CHG_STATE_TRICKLE);
|
||||
}
|
||||
else {
|
||||
bus->chg_current_max = 0;
|
||||
bus->chg_allowed = false;
|
||||
bus->chg_current_limit = 0;
|
||||
_enter_state(charger, CHG_STATE_IDLE);
|
||||
}
|
||||
}
|
||||
@@ -456,18 +457,16 @@ void battery_init_dc_bus(DcBus *bus, BatConf *bat, unsigned int num_batteries)
|
||||
{
|
||||
unsigned int n = (num_batteries == 2 ? 2 : 1); // only 1 or 2 allowed
|
||||
|
||||
bus->dis_allowed = true;
|
||||
bus->dis_voltage_start = bat->voltage_load_reconnect * n;
|
||||
bus->dis_voltage_stop = bat->voltage_load_disconnect * n;
|
||||
bus->dis_current_max = -bat->charge_current_max; // TODO: discharge current
|
||||
bus->dis_current_limit = -bat->discharge_current_max;
|
||||
|
||||
// negative sign for compensation of actual resistance
|
||||
bus->dis_droop_res = -(bat->internal_resistance + -bat->wire_resistance) * n;
|
||||
|
||||
bus->chg_allowed = true;
|
||||
bus->chg_voltage_target = bat->topping_voltage * n;
|
||||
bus->chg_voltage_min = bat->voltage_absolute_min * n;
|
||||
bus->chg_current_max = bat->charge_current_max;
|
||||
bus->chg_current_limit = bat->charge_current_max;
|
||||
|
||||
// negative sign for compensation of actual resistance
|
||||
bus->chg_droop_res = -bat->wire_resistance * n;
|
||||
@@ -476,10 +475,15 @@ void battery_init_dc_bus(DcBus *bus, BatConf *bat, unsigned int num_batteries)
|
||||
void charger_update_junction_bus(DcBus *junction, DcBus *bat, DcBus *load)
|
||||
{
|
||||
// relevant for DC/DC
|
||||
junction->chg_current_max = bat->chg_current_max - bat->current + load->current;
|
||||
junction->chg_current_limit = bat->chg_current_limit - bat->current + load->current;
|
||||
junction->chg_voltage_target = bat->chg_voltage_target;
|
||||
|
||||
// relevant for load output
|
||||
junction->dis_voltage_start = bat->dis_voltage_start;
|
||||
junction->dis_voltage_stop = bat->dis_voltage_stop;
|
||||
|
||||
// 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).
|
||||
junction->dis_current_limit = bat->dis_current_limit - bat->current;
|
||||
}
|
||||
|
||||
+13
-4
@@ -22,11 +22,10 @@
|
||||
* @brief Battery and charger configuration and functions
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "dcdc.h"
|
||||
#include "dc_bus.h"
|
||||
|
||||
/** Battery cell types
|
||||
@@ -81,10 +80,16 @@ typedef struct
|
||||
|
||||
/** Maximum charge current in *CC/bulk* phase (A)
|
||||
*
|
||||
* Limits the current if the PCB allows more than the battery.
|
||||
* Limits the current if the PCB allows more than the battery. (positive value)
|
||||
*/
|
||||
float charge_current_max;
|
||||
|
||||
/** Maximum discharge current via load port (A)
|
||||
*
|
||||
* Limits the current if the PCB allows more than the battery. (positive value)
|
||||
*/
|
||||
float discharge_current_max;
|
||||
|
||||
/** Maximum voltage in CV/absorption phase (V)
|
||||
*
|
||||
* Charger target voltage, switching from CC to CV at this voltage threshold.
|
||||
@@ -348,9 +353,13 @@ void charger_init(Charger *charger);
|
||||
*/
|
||||
void charger_detect_num_batteries(Charger *charger, BatConf *bat, DcBus *bus);
|
||||
|
||||
/** Discharging control update (for load output), should be called once per second
|
||||
*/
|
||||
void battery_discharge_control(DcBus *bus, BatConf *bat_conf, Charger *charger);
|
||||
|
||||
/** Charger state machine update, should be called once per second
|
||||
*/
|
||||
void charger_state_machine(DcBus *port, BatConf *bat_conf, Charger *charger);
|
||||
void battery_charge_control(DcBus *bus, BatConf *bat_conf, Charger *charger);
|
||||
|
||||
/** Calculates targets for junction of load and battery bus at the DC/DC output
|
||||
*/
|
||||
|
||||
@@ -136,7 +136,7 @@ const data_object_t data_objects[] = {
|
||||
{0x79, TS_OUTPUT, TS_READ_ALL, TS_T_UINT16, 0, (void*) &(dcdc.state), "DCDCState"},
|
||||
{0x7A, TS_OUTPUT, TS_READ_ALL, TS_T_FLOAT32, 2, (void*) &(hv_terminal.current), "Solar_A"},
|
||||
{0x7B, TS_OUTPUT, TS_READ_ALL, TS_T_FLOAT32, 2, (void*) &(lv_terminal.chg_voltage_target), "BatTarget_V"},
|
||||
{0x7C, TS_OUTPUT, TS_READ_ALL, TS_T_FLOAT32, 2, (void*) &(lv_terminal.chg_current_max), "BatTarget_A"},
|
||||
{0x7C, TS_OUTPUT, TS_READ_ALL, TS_T_FLOAT32, 2, (void*) &(lv_terminal.chg_current_limit), "BatTarget_A"},
|
||||
{0x7D, TS_OUTPUT, TS_READ_ALL, TS_T_FLOAT32, 2, (void*) &(lv_terminal.power), "Bat_W"},
|
||||
{0x7E, TS_OUTPUT, TS_READ_ALL, TS_T_FLOAT32, 2, (void*) &(hv_terminal.power), "Solar_W"},
|
||||
{0x7F, TS_OUTPUT, TS_READ_ALL, TS_T_FLOAT32, 2, (void*) &(load_terminal.power), "Load_W"},
|
||||
|
||||
+4
-7
@@ -18,25 +18,22 @@
|
||||
|
||||
void dc_bus_init_solar(DcBus *bus, float max_abs_current)
|
||||
{
|
||||
bus->dis_allowed = true; // PV panel may provide power to solar input of DC/DC
|
||||
bus->dis_voltage_start = 16.0;
|
||||
bus->dis_voltage_stop = 14.0;
|
||||
bus->dis_current_max = -max_abs_current;
|
||||
bus->dis_current_limit = -max_abs_current;
|
||||
|
||||
bus->chg_allowed = false;
|
||||
bus->chg_current_limit = 0; // no current towards solar panel allowed
|
||||
}
|
||||
|
||||
void dc_bus_init_nanogrid(DcBus *bus)
|
||||
{
|
||||
bus->dis_allowed = true;
|
||||
bus->dis_voltage_start = 30.0; // starting buck mode above this point
|
||||
bus->dis_voltage_stop = 20.0; // stopping buck mode below this point
|
||||
bus->dis_current_max = -5.0;
|
||||
bus->dis_current_limit = -5.0;
|
||||
bus->dis_droop_res = 0.1; // 1 Ohm means 1V change of target voltage per amp
|
||||
|
||||
bus->chg_allowed = true;
|
||||
bus->chg_voltage_target = 28.0; // starting idle mode above this point
|
||||
bus->chg_current_max = 5.0;
|
||||
bus->chg_current_limit = 5.0;
|
||||
bus->chg_voltage_min = 10.0;
|
||||
bus->chg_droop_res = 0.1; // 1 Ohm means 1V change of target voltage per amp
|
||||
}
|
||||
|
||||
+4
-4
@@ -36,19 +36,19 @@ typedef struct {
|
||||
float current; ///< sum of currents (positive sign = increasing voltage/charge of the bus)
|
||||
float power; ///< multiplication of power & voltage
|
||||
|
||||
bool chg_allowed; ///< charging direction for battery port
|
||||
float chg_voltage_target; ///< target voltage if port is configured as output
|
||||
float chg_droop_res; ///< v_target = v_out_max - r_droop_output * current
|
||||
float chg_voltage_min; ///< minimum voltage to allow current output (necessary
|
||||
///< to prevent charging of deep-discharged Li-ion batteries)
|
||||
float chg_current_max; ///< charging direction for battery port
|
||||
float chg_current_limit; ///< current charging the bus, i.e. increasing its voltage
|
||||
///< (equals charging direction for battery terminal)
|
||||
|
||||
bool dis_allowed; ///< discharging direction for battery port
|
||||
float dis_voltage_start; ///< minimum voltage to allow current input (= discharging of batteries),
|
||||
///< starting point for discharging of batteries (load reconnect)
|
||||
float dis_voltage_stop; ///< absolute minimum = load disconnect for batteries
|
||||
float dis_droop_res; ///< v_stop = v_input_stop - r_droop_input * current
|
||||
float dis_current_max; ///< discharging direction for battery port: must be negative value !!!
|
||||
float dis_current_limit; ///< current which discharges the bus, i.e. decreases its
|
||||
///< voltage, value must be negative!!!
|
||||
|
||||
float chg_energy_Wh; ///< cumulated energy in charge direction since last counter reset (Wh)
|
||||
float dis_energy_Wh; ///< cumulated energy in discharge direction since last counter reset (Wh)
|
||||
|
||||
+7
-7
@@ -80,7 +80,7 @@ int duty_cycle_delta(Dcdc *dcdc)
|
||||
#if 0
|
||||
printf("P: %.2f, P_prev: %.2f, v_in: %.2f, v_out: %.2f, i_in: %.2f, i_out: %.2f, v_chg_target: %.2f, i_chg_max: %.2f, PWM: %.1f, chg_state: %d\n",
|
||||
out->power, dcdc->power_prev, in->voltage, out->voltage, in->current, out->current, out->chg_voltage_target,
|
||||
out->chg_current_max, half_bridge_get_duty_cycle() * 100.0, dcdc->state);
|
||||
out->chg_current_limit, half_bridge_get_duty_cycle() * 100.0, dcdc->state);
|
||||
#endif
|
||||
|
||||
if (time(NULL) - dcdc->power_good_timestamp > 10 || // more than 10s low power
|
||||
@@ -94,8 +94,8 @@ int duty_cycle_delta(Dcdc *dcdc)
|
||||
dcdc->state = DCDC_STATE_CV;
|
||||
pwr_inc_goal = -1; // decrease output power
|
||||
}
|
||||
else if (out->current > out->chg_current_max // output charge current limit exceeded
|
||||
|| in->current < in->dis_current_max) // input current (negative signs) limit exceeded
|
||||
else if (out->current > out->chg_current_limit // output charge current limit exceeded
|
||||
|| in->current < in->dis_current_limit) // input current (negative signs) limit exceeded
|
||||
{
|
||||
dcdc->state = DCDC_STATE_CC;
|
||||
pwr_inc_goal = -1; // decrease output power
|
||||
@@ -136,19 +136,19 @@ int dcdc_check_start_conditions(Dcdc *dcdc)
|
||||
return 0; // no energy transfer allowed
|
||||
}
|
||||
|
||||
if (dcdc->lv_bus->chg_current_max > 0 &&
|
||||
if (dcdc->lv_bus->chg_current_limit > 0 &&
|
||||
dcdc->lv_bus->voltage < dcdc->lv_bus->chg_voltage_target &&
|
||||
dcdc->lv_bus->voltage > dcdc->lv_bus->chg_voltage_min &&
|
||||
dcdc->hv_bus->dis_current_max < 0 &&
|
||||
dcdc->hv_bus->dis_current_limit < 0 &&
|
||||
dcdc->hv_bus->voltage > dcdc->hv_bus->dis_voltage_start)
|
||||
{
|
||||
return 1; // start in buck mode allowed
|
||||
}
|
||||
|
||||
if (dcdc->hv_bus->chg_current_max > 0 &&
|
||||
if (dcdc->hv_bus->chg_current_limit > 0 &&
|
||||
dcdc->hv_bus->voltage < dcdc->hv_bus->chg_voltage_target &&
|
||||
dcdc->hv_bus->voltage > dcdc->hv_bus->chg_voltage_min &&
|
||||
dcdc->lv_bus->dis_current_max < 0 &&
|
||||
dcdc->lv_bus->dis_current_limit < 0 &&
|
||||
dcdc->lv_bus->voltage > dcdc->lv_bus->dis_voltage_start)
|
||||
{
|
||||
return -1; // start in boost mode allowed
|
||||
|
||||
+2
-1
@@ -22,8 +22,9 @@
|
||||
* @brief DC/DC buck/boost control functions
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "bat_charger.h"
|
||||
|
||||
#include "dc_bus.h"
|
||||
|
||||
/** DC/DC basic operation mode
|
||||
|
||||
+15
-10
@@ -178,9 +178,10 @@ void load_usb_set(bool enabled)
|
||||
#endif
|
||||
}
|
||||
|
||||
void load_init(LoadOutput *load, DcBus *bus)
|
||||
void load_init(LoadOutput *load, DcBus *bus_int, DcBus *terminal)
|
||||
{
|
||||
load->bus = bus;
|
||||
load->bus_int = bus_int;
|
||||
load->terminal = terminal;
|
||||
load->current_max = LOAD_CURRENT_MAX;
|
||||
load->enabled_target = true;
|
||||
load->usb_enabled_target = true;
|
||||
@@ -240,12 +241,14 @@ void usb_state_machine(LoadOutput *load)
|
||||
|
||||
static time_t lvd_timestamp = 0; // stores when the load was disconnected last time
|
||||
|
||||
void load_state_machine(LoadOutput *load, bool source_enabled)
|
||||
void load_state_machine(LoadOutput *load)
|
||||
{
|
||||
//printf("Load State: %d\n", load->switch_state);
|
||||
switch (load->switch_state) {
|
||||
case LOAD_STATE_DISABLED:
|
||||
if (source_enabled == true && load->enabled_target == true) {
|
||||
if (load->bus_int->dis_current_limit < 0 // discharging enabled
|
||||
&& load->enabled_target == true)
|
||||
{
|
||||
load_switch_set(true);
|
||||
load->switch_state = LOAD_STATE_ON;
|
||||
}
|
||||
@@ -255,7 +258,7 @@ void load_state_machine(LoadOutput *load, bool source_enabled)
|
||||
load_switch_set(false);
|
||||
load->switch_state = LOAD_STATE_DISABLED;
|
||||
}
|
||||
else if (source_enabled == false) {
|
||||
else if (load->bus_int->dis_current_limit == 0) { // float == is allowed for 0.0
|
||||
lvd_timestamp = time(NULL);
|
||||
load_switch_set(false);
|
||||
load->switch_state = LOAD_STATE_OFF_LOW_SOC;
|
||||
@@ -263,7 +266,9 @@ void load_state_machine(LoadOutput *load, bool source_enabled)
|
||||
break;
|
||||
case LOAD_STATE_OFF_LOW_SOC:
|
||||
// wait at least one hour
|
||||
if (source_enabled == true && time(NULL) - lvd_timestamp > 60*60) {
|
||||
if (load->bus_int->dis_current_limit < 0 // discharging enabled again
|
||||
&& time(NULL) - lvd_timestamp > 60*60)
|
||||
{
|
||||
if (load->enabled_target == true) {
|
||||
load_switch_set(true);
|
||||
load->switch_state = LOAD_STATE_ON;
|
||||
@@ -280,7 +285,7 @@ void load_state_machine(LoadOutput *load, bool source_enabled)
|
||||
}
|
||||
break;
|
||||
case LOAD_STATE_OFF_OVERVOLTAGE:
|
||||
if (load->bus->voltage < LOW_SIDE_VOLTAGE_MAX) { // TODO: add hysteresis?
|
||||
if (load->bus_int->voltage < LOW_SIDE_VOLTAGE_MAX) { // TODO: add hysteresis?
|
||||
load->switch_state = LOAD_STATE_DISABLED; // switch to normal mode again
|
||||
}
|
||||
break;
|
||||
@@ -310,7 +315,7 @@ void load_control(LoadOutput *load, float load_max_voltage)
|
||||
// junction temperature calculation model for overcurrent detection
|
||||
load->junction_temperature = load->junction_temperature + (
|
||||
mcu_temp - load->junction_temperature +
|
||||
load->bus->current * load->bus->current /
|
||||
load->terminal->current * load->terminal->current /
|
||||
(LOAD_CURRENT_MAX * LOAD_CURRENT_MAX) * (MOSFET_MAX_JUNCTION_TEMP - 25)
|
||||
) / (MOSFET_THERMAL_TIME_CONSTANT * CONTROL_FREQUENCY);
|
||||
|
||||
@@ -322,8 +327,8 @@ void load_control(LoadOutput *load, float load_max_voltage)
|
||||
}
|
||||
|
||||
static int debounce_counter = 0;
|
||||
if (load->bus->voltage > load_max_voltage ||
|
||||
load->bus->voltage > LOW_SIDE_VOLTAGE_MAX)
|
||||
if (load->bus_int->voltage > load_max_voltage ||
|
||||
load->bus_int->voltage > LOW_SIDE_VOLTAGE_MAX)
|
||||
{
|
||||
debounce_counter++;
|
||||
if (debounce_counter > CONTROL_FREQUENCY) { // waited 1s before setting the flag
|
||||
|
||||
+18
-6
@@ -23,8 +23,9 @@
|
||||
* Load/USB output functions and data types
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "dc_bus.h"
|
||||
|
||||
/** Load/USB output states
|
||||
@@ -48,20 +49,29 @@ typedef struct {
|
||||
uint16_t switch_state; ///< Current state of load output switch
|
||||
uint16_t usb_state; ///< Current state of USB output
|
||||
|
||||
DcBus *bus; ///< Pointer to DC bus containting actual voltage and current measurement
|
||||
DcBus *bus_int; ///< Pointer to internal DC bus where the load output
|
||||
///< current is coming from
|
||||
DcBus *terminal; ///< Pointer to DC bus containting actual voltage and current
|
||||
///< measurement of (external) load output terminal
|
||||
|
||||
float current_max; ///< maximum allowed current
|
||||
int overcurrent_timestamp; ///< time at which an overcurrent event occured
|
||||
|
||||
float junction_temperature; ///< calculated using thermal model based on current and ambient temperature measurement (unit: °C)
|
||||
float junction_temperature; ///< calculated using thermal model based on current and ambient
|
||||
///< temperature measurement (unit: °C)
|
||||
|
||||
bool enabled_target; ///< target setting defined via communication port (overruled if battery is empty)
|
||||
bool enabled_target; ///< target setting defined via communication port (overruled if
|
||||
///< battery is empty)
|
||||
bool usb_enabled_target; ///< same for USB output
|
||||
} LoadOutput;
|
||||
|
||||
/** Initialize LoadOutput struct and overcurrent / short circuit protection comparator (if existing)
|
||||
*
|
||||
* @param load Load output struct
|
||||
* @param bus_int Internal DC bus the load switch is connected to (e.g. battery and DC/DC junction)
|
||||
* @param terminal Load terminal DC bus (external interface)
|
||||
*/
|
||||
void load_init(LoadOutput *load, DcBus *bus);
|
||||
void load_init(LoadOutput *load, DcBus *bus_int, DcBus *terminal);
|
||||
|
||||
/** Enable/disable load switch
|
||||
*/
|
||||
@@ -72,8 +82,10 @@ void load_switch_set(bool enabled);
|
||||
void load_usb_set(bool enabled);
|
||||
|
||||
/** State machine, called every second.
|
||||
*
|
||||
* @param load Load output struct
|
||||
*/
|
||||
void load_state_machine(LoadOutput *load, bool source_enabled);
|
||||
void load_state_machine(LoadOutput *load);
|
||||
|
||||
/** Main load control function, should be called by control timer
|
||||
*
|
||||
|
||||
+4
-4
@@ -81,8 +81,8 @@ void log_update_min_max_values(LogData *log_data, Dcdc *dcdc, Charger *charger,
|
||||
log_data->dcdc_current_max = dcdc->lv_bus->current;
|
||||
}
|
||||
|
||||
if (load->bus->current > log_data->load_current_max) {
|
||||
log_data->load_current_max = load->bus->current;
|
||||
if (load->terminal->current > log_data->load_current_max) {
|
||||
log_data->load_current_max = load->terminal->current;
|
||||
}
|
||||
|
||||
if (solar_bus->current < 0) {
|
||||
@@ -95,8 +95,8 @@ void log_update_min_max_values(LogData *log_data, Dcdc *dcdc, Charger *charger,
|
||||
}
|
||||
}
|
||||
|
||||
if (load->bus->current > 0) {
|
||||
uint16_t load_power = load->bus->voltage * load->bus->current;
|
||||
if (load->terminal->current > 0) {
|
||||
uint16_t load_power = load->terminal->voltage * load->terminal->current;
|
||||
if (load_power > log_data->load_power_max_day) {
|
||||
log_data->load_power_max_day = load_power;
|
||||
if (log_data->load_power_max_day > log_data->load_power_max_total) {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
* Structs needed for data logging (like max/min values, etc.)
|
||||
*/
|
||||
|
||||
#include "bat_charger.h"
|
||||
#include "dc_bus.h"
|
||||
#include "load.h"
|
||||
#include "dcdc.h"
|
||||
|
||||
+4
-3
@@ -110,7 +110,7 @@ int main()
|
||||
battery_conf_overwrite(&bat_conf, &bat_conf_user); // initialize conf_user with same values
|
||||
charger_init(&charger);
|
||||
|
||||
load_init(&load, &load_terminal);
|
||||
load_init(&load, &lv_bus_int, &load_terminal);
|
||||
|
||||
#ifdef CHARGER_TYPE_PWM
|
||||
pwm_switch_init(&pwm_switch);
|
||||
@@ -189,11 +189,12 @@ int main()
|
||||
|
||||
//printf("Still alive... time: %d, mode: %d\n", (int)time(NULL), dcdc.mode);
|
||||
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_discharge_control(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
|
||||
charger_update_junction_bus(&lv_bus_int, bat_terminal, &load_terminal);
|
||||
|
||||
load_state_machine(&load, lv_terminal.dis_allowed);
|
||||
load_state_machine(&load);
|
||||
|
||||
eeprom_update();
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "dc_bus.h"
|
||||
#include "log.h"
|
||||
#include "pwm_switch.h"
|
||||
#include "half_bridge.h"
|
||||
#include "load.h"
|
||||
|
||||
extern LogData log_data;
|
||||
extern Charger charger;
|
||||
|
||||
+5
-5
@@ -130,7 +130,7 @@ void pwm_switch_init(PwmSwitch *pwm_switch)
|
||||
void pwm_switch_control(PwmSwitch *pwm_switch, DcBus *solar_bus, DcBus *bat_bus)
|
||||
{
|
||||
if (_enabled) {
|
||||
if (bat_bus->chg_allowed == false || solar_bus->dis_allowed == false
|
||||
if (bat_bus->chg_current_limit == 0 || solar_bus->dis_current_limit == 0
|
||||
|| solar_bus->current > 0 // discharging battery into solar panel --> stop
|
||||
|| pwm_switch->enabled == false)
|
||||
{
|
||||
@@ -139,8 +139,8 @@ void pwm_switch_control(PwmSwitch *pwm_switch, DcBus *solar_bus, DcBus *bat_bus)
|
||||
printf("PWM charger stop.\n");
|
||||
}
|
||||
else if (bat_bus->voltage > (bat_bus->chg_voltage_target - bat_bus->chg_droop_res * bat_bus->current) // output voltage above target
|
||||
|| bat_bus->current > bat_bus->chg_current_max // output current limit exceeded
|
||||
|| solar_bus->current < solar_bus->dis_current_max) // input current (negative signs) above limit
|
||||
|| bat_bus->current > bat_bus->chg_current_limit // output current limit exceeded
|
||||
|| solar_bus->current < solar_bus->dis_current_limit) // input current (negative signs) above limit
|
||||
{
|
||||
// The gate driver switch-off time is quite high (fall time around 1ms), so very short
|
||||
// on or off periods (duty cycle close to 0 and 1) should be avoided
|
||||
@@ -169,10 +169,10 @@ void pwm_switch_control(PwmSwitch *pwm_switch, DcBus *solar_bus, DcBus *bat_bus)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (bat_bus->chg_allowed == true
|
||||
if (bat_bus->chg_current_limit > 0 // charging allowed
|
||||
&& bat_bus->voltage < bat_bus->chg_voltage_target
|
||||
&& bat_bus->voltage > bat_bus->chg_voltage_min
|
||||
&& solar_bus->dis_allowed == true
|
||||
&& solar_bus->dis_current_limit < 0 // dischraging allowed
|
||||
&& solar_bus->voltage > bat_bus->voltage + pwm_switch->offset_voltage_start
|
||||
&& time(NULL) > (pwm_switch->off_timestamp + pwm_switch->restart_interval)
|
||||
&& pwm_switch->enabled == true)
|
||||
|
||||
@@ -122,7 +122,7 @@ void uext_process_1s()
|
||||
oled.setTextCursor(90, 18);
|
||||
oled.printf("%5.1fW", (abs(load_terminal.power) < 0.1) ? 0 : load_terminal.power); // remove negative zeros
|
||||
oled.setTextCursor(90, 26);
|
||||
oled.printf("%5.1fA\n", (abs(load.bus->current) < 0.1) ? 0 : load.bus->current);
|
||||
oled.printf("%5.1fA\n", (abs(load_terminal.current) < 0.1) ? 0 : load_terminal.current);
|
||||
|
||||
oled.setTextCursor(0, 36);
|
||||
oled.printf("Day +%5.0fWh -%5.0fWh", solar_terminal->dis_energy_Wh, fabs(load_terminal.chg_energy_Wh));
|
||||
|
||||
+102
-19
@@ -17,13 +17,16 @@ static void init_structs()
|
||||
charger_init(&charger);
|
||||
battery_init_dc_bus(bat_terminal, &bat_conf, 1);
|
||||
charger.state = CHG_STATE_IDLE;
|
||||
charger.bat_temperature = 25;
|
||||
bat_terminal->voltage = 14.0;
|
||||
bat_terminal->current = 0;
|
||||
}
|
||||
|
||||
void no_start_at_high_voltage()
|
||||
{
|
||||
init_structs();
|
||||
bat_terminal->voltage = bat_conf.voltage_recharge + 0.1;
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_IDLE, charger.state);
|
||||
}
|
||||
|
||||
@@ -32,7 +35,7 @@ void no_start_after_short_rest()
|
||||
init_structs();
|
||||
charger.time_state_changed = time(NULL) - bat_conf.time_limit_recharge + 1;
|
||||
bat_terminal->voltage = bat_conf.voltage_recharge - 0.1;
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_IDLE, charger.state);
|
||||
}
|
||||
|
||||
@@ -41,11 +44,11 @@ void no_start_outside_temperature_limits()
|
||||
init_structs();
|
||||
charger.bat_temperature = bat_conf.charge_temp_max + 1;
|
||||
bat_terminal->voltage = bat_conf.voltage_recharge - 0.1;
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_IDLE, charger.state);
|
||||
|
||||
charger.bat_temperature = bat_conf.charge_temp_min - 1;
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_IDLE, charger.state);
|
||||
}
|
||||
|
||||
@@ -54,7 +57,7 @@ void start_if_everything_just_fine()
|
||||
init_structs();
|
||||
charger.time_state_changed = time(NULL) - bat_conf.time_limit_recharge - 1;
|
||||
bat_terminal->voltage = bat_conf.voltage_recharge - 0.1;
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_BULK, charger.state);
|
||||
}
|
||||
|
||||
@@ -63,10 +66,10 @@ void enter_topping_at_voltage_setpoint()
|
||||
init_structs();
|
||||
charger.time_state_changed = time(NULL) - bat_conf.time_limit_recharge - 1;
|
||||
bat_terminal->voltage = bat_conf.voltage_recharge - 0.1;
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_BULK, charger.state);
|
||||
bat_terminal->voltage = bat_conf.topping_voltage + 0.1;
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_TOPPING, charger.state);
|
||||
}
|
||||
|
||||
@@ -78,11 +81,11 @@ void stop_topping_after_time_limit()
|
||||
bat_terminal->voltage = bat_conf.topping_voltage + 0.1;
|
||||
bat_terminal->current = bat_conf.topping_current_cutoff + 0.1;
|
||||
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_TOPPING, charger.state);
|
||||
|
||||
charger.time_state_changed = time(NULL) - bat_conf.topping_duration - 1;
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_TRICKLE, charger.state);
|
||||
}
|
||||
|
||||
@@ -93,7 +96,7 @@ void stop_topping_at_cutoff_current()
|
||||
charger.time_state_changed = time(NULL) - 1;
|
||||
bat_terminal->voltage = bat_conf.topping_voltage + 0.1;
|
||||
bat_terminal->current = bat_conf.topping_current_cutoff - 0.1;
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_TRICKLE, charger.state);
|
||||
}
|
||||
|
||||
@@ -105,7 +108,7 @@ void trickle_to_idle_for_li_ion()
|
||||
charger.time_state_changed = time(NULL) - 1;
|
||||
bat_terminal->voltage = bat_conf.topping_voltage + 0.1;
|
||||
bat_terminal->current = bat_conf.topping_current_cutoff - 0.1;
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_IDLE, charger.state);
|
||||
}
|
||||
|
||||
@@ -118,11 +121,11 @@ void no_trickle_if_low_current_because_of_low_input()
|
||||
bat_terminal->voltage = bat_conf.topping_voltage - 0.1;
|
||||
bat_terminal->current = bat_conf.topping_current_cutoff - 0.1;
|
||||
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_TOPPING, charger.state);
|
||||
|
||||
charger.time_voltage_limit_reached = time(NULL) - 1;
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_TRICKLE, charger.state);
|
||||
}
|
||||
|
||||
@@ -140,7 +143,7 @@ void no_equalization_if_disabled()
|
||||
charger.time_state_changed = time(NULL) - 1;
|
||||
bat_terminal->voltage = bat_conf.topping_voltage + 0.1;
|
||||
bat_terminal->current = bat_conf.topping_current_cutoff - 0.1;
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_NOT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
||||
}
|
||||
|
||||
@@ -158,7 +161,7 @@ void no_equalization_if_limits_not_reached()
|
||||
charger.time_state_changed = time(NULL) - 1;
|
||||
bat_terminal->voltage = bat_conf.topping_voltage + 0.1;
|
||||
bat_terminal->current = bat_conf.topping_current_cutoff - 0.1;
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_NOT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
||||
}
|
||||
|
||||
@@ -172,7 +175,7 @@ void trickle_to_equalization_if_enabled_and_time_limit_reached()
|
||||
charger.time_state_changed = time(NULL) - 1;
|
||||
bat_terminal->voltage = bat_conf.topping_voltage + 0.1;
|
||||
bat_terminal->current = bat_conf.topping_current_cutoff - 0.1;
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
||||
}
|
||||
|
||||
@@ -187,7 +190,7 @@ void trickle_to_equalization_if_enabled_and_deep_dis_limit_reached()
|
||||
charger.time_state_changed = time(NULL) - 1;
|
||||
bat_terminal->voltage = bat_conf.topping_voltage + 0.1;
|
||||
bat_terminal->current = bat_conf.topping_current_cutoff - 0.1;
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
||||
}
|
||||
|
||||
@@ -199,11 +202,11 @@ void stop_equalization_after_time_limit()
|
||||
charger.time_state_changed = time(NULL) - bat_conf.equalization_duration + 1;
|
||||
bat_terminal->voltage = bat_conf.equalization_voltage + 0.1;
|
||||
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_EQUALIZATION, charger.state);
|
||||
|
||||
charger.time_state_changed = time(NULL) - bat_conf.topping_duration - 1;
|
||||
charger_state_machine(bat_terminal, &bat_conf, &charger);
|
||||
battery_charge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(CHG_STATE_TRICKLE, charger.state);
|
||||
}
|
||||
|
||||
@@ -212,10 +215,79 @@ void restart_bulk_from_trickle_if_voltage_drops()
|
||||
TEST_ASSERT(0);
|
||||
}
|
||||
|
||||
void stop_discharge_at_low_voltage()
|
||||
{
|
||||
init_structs();
|
||||
|
||||
bat_terminal->voltage = 14;
|
||||
battery_discharge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_LESS_THAN(0, bat_terminal->dis_current_limit);
|
||||
|
||||
bat_terminal->voltage = bat_conf.voltage_load_disconnect - 0.1;
|
||||
battery_discharge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(0, bat_terminal->dis_current_limit);
|
||||
}
|
||||
|
||||
void stop_discharge_at_overtemp()
|
||||
{
|
||||
init_structs();
|
||||
TEST_ASSERT_LESS_THAN(0, bat_terminal->dis_current_limit);
|
||||
|
||||
charger.bat_temperature = bat_conf.discharge_temp_max + 1;
|
||||
battery_discharge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(0, bat_terminal->dis_current_limit);
|
||||
}
|
||||
|
||||
void stop_discharge_at_undertemp()
|
||||
{
|
||||
init_structs();
|
||||
TEST_ASSERT_LESS_THAN(0, bat_terminal->dis_current_limit);
|
||||
|
||||
charger.bat_temperature = bat_conf.discharge_temp_min - 1;
|
||||
battery_discharge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(0, bat_terminal->dis_current_limit);
|
||||
}
|
||||
|
||||
void restart_discharge_if_allowed()
|
||||
{
|
||||
init_structs();
|
||||
|
||||
// stop because of undervoltage
|
||||
bat_terminal->voltage = bat_conf.voltage_load_disconnect - 0.1;
|
||||
battery_discharge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(0, bat_terminal->dis_current_limit);
|
||||
|
||||
// increase voltage slightly above DISconnect voltage
|
||||
bat_terminal->voltage = bat_conf.voltage_load_disconnect + 0.1;
|
||||
battery_discharge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_EQUAL(0, bat_terminal->dis_current_limit);
|
||||
|
||||
// increase voltage above REconnect voltage
|
||||
bat_terminal->voltage = bat_conf.voltage_load_reconnect + 0.1;
|
||||
battery_discharge_control(bat_terminal, &bat_conf, &charger);
|
||||
TEST_ASSERT_LESS_THAN(0, bat_terminal->dis_current_limit);
|
||||
}
|
||||
|
||||
void battery_values_propagated_to_lv_bus_int()
|
||||
{
|
||||
TEST_ASSERT(0);
|
||||
}
|
||||
|
||||
void no_soc_above_100()
|
||||
{
|
||||
TEST_ASSERT(0);
|
||||
}
|
||||
|
||||
void no_soc_below_0()
|
||||
{
|
||||
TEST_ASSERT(0);
|
||||
}
|
||||
|
||||
void bat_charger_tests()
|
||||
{
|
||||
UNITY_BEGIN();
|
||||
|
||||
// startup of charging
|
||||
RUN_TEST(no_start_at_high_voltage);
|
||||
RUN_TEST(no_start_after_short_rest);
|
||||
RUN_TEST(no_start_outside_temperature_limits);
|
||||
@@ -242,5 +314,16 @@ void bat_charger_tests()
|
||||
// TODO: temperature compensation
|
||||
// TODO: current compensation
|
||||
|
||||
RUN_TEST(stop_discharge_at_low_voltage);
|
||||
RUN_TEST(stop_discharge_at_overtemp);
|
||||
RUN_TEST(stop_discharge_at_undertemp);
|
||||
RUN_TEST(restart_discharge_if_allowed);
|
||||
|
||||
//RUN_TEST(battery_values_propagated_to_lv_bus_int);
|
||||
|
||||
// ToDo: SOC calculation
|
||||
//RUN_TEST(no_soc_above_100);
|
||||
//RUN_TEST(no_soc_below_0);
|
||||
|
||||
UNITY_END();
|
||||
}
|
||||
+6
-6
@@ -131,7 +131,7 @@ void no_buck_start_if_bat_voltage_high()
|
||||
void no_buck_start_if_bat_chg_not_allowed()
|
||||
{
|
||||
init_structs_buck();
|
||||
lv_bus_int.chg_current_max = 0;
|
||||
lv_bus_int.chg_current_limit = 0;
|
||||
TEST_ASSERT_EQUAL(0, dcdc_check_start_conditions(&dcdc));
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ void no_boost_start_if_bat_voltage_high()
|
||||
void no_boost_start_if_bat_chg_not_allowed()
|
||||
{
|
||||
init_structs_boost();
|
||||
hv_terminal.chg_current_max = 0;
|
||||
hv_terminal.chg_current_limit = 0;
|
||||
TEST_ASSERT_EQUAL(0, dcdc_check_start_conditions(&dcdc));
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ void buck_derating_output_current_too_high()
|
||||
{
|
||||
start_buck();
|
||||
float pwm_before = half_bridge_get_duty_cycle();
|
||||
lv_bus_int.current = lv_bus_int.chg_current_max + 0.1;
|
||||
lv_bus_int.current = lv_bus_int.chg_current_limit + 0.1;
|
||||
dcdc_control(&dcdc);
|
||||
float pwm_after = half_bridge_get_duty_cycle();
|
||||
TEST_ASSERT(pwm_after < pwm_before);
|
||||
@@ -235,7 +235,7 @@ void buck_derating_input_current_too_high()
|
||||
{
|
||||
start_buck();
|
||||
float pwm_before = half_bridge_get_duty_cycle();
|
||||
hv_terminal.current = hv_terminal.dis_current_max - 0.1;
|
||||
hv_terminal.current = hv_terminal.dis_current_limit - 0.1;
|
||||
dcdc_control(&dcdc);
|
||||
float pwm_after = half_bridge_get_duty_cycle();
|
||||
TEST_ASSERT(pwm_after < pwm_before);
|
||||
@@ -314,7 +314,7 @@ void boost_derating_output_current_too_high()
|
||||
{
|
||||
start_boost();
|
||||
float pwm_before = half_bridge_get_duty_cycle();
|
||||
hv_terminal.current = hv_terminal.chg_current_max + 0.1;
|
||||
hv_terminal.current = hv_terminal.chg_current_limit + 0.1;
|
||||
dcdc_control(&dcdc);
|
||||
float pwm_after = half_bridge_get_duty_cycle();
|
||||
TEST_ASSERT(pwm_after > pwm_before);
|
||||
@@ -335,7 +335,7 @@ void boost_derating_input_current_too_high()
|
||||
{
|
||||
start_boost();
|
||||
float pwm_before = half_bridge_get_duty_cycle();
|
||||
lv_bus_int.current = lv_bus_int.dis_current_max - 0.1;
|
||||
lv_bus_int.current = lv_bus_int.dis_current_limit - 0.1;
|
||||
dcdc_control(&dcdc);
|
||||
float pwm_after = half_bridge_get_duty_cycle();
|
||||
TEST_ASSERT(pwm_after > pwm_before);
|
||||
|
||||
Reference in New Issue
Block a user