Restructuring of data types (structs) and files
- dcdc_port_t renamed to power_port_t for future use in PWM charge controllers - structs.h split into battery.h, log.h and charger.h - bat_charger.cpp/h split into battery.cpp/h and charger.cpp/h
This commit is contained in:
+3
-44
@@ -20,7 +20,6 @@
|
||||
|
||||
#include "half_bridge.h"
|
||||
|
||||
//#include "data_objects.h"
|
||||
#include <time.h> // for time(NULL) function
|
||||
#include <math.h> // for fabs function
|
||||
|
||||
@@ -38,48 +37,8 @@ void dcdc_init(dcdc_t *dcdc)
|
||||
dcdc->pwm_delta = 1;
|
||||
}
|
||||
|
||||
void dcdc_port_init_bat(dcdc_port_t *port, battery_t *bat)
|
||||
{
|
||||
port->input_allowed = true; // discharging allowed
|
||||
port->output_allowed = true; // charging allowed
|
||||
|
||||
port->voltage_input_start = bat->cell_voltage_load_reconnect * bat->num_cells;
|
||||
port->voltage_input_stop = bat->cell_voltage_load_disconnect * bat->num_cells;
|
||||
port->current_input_max = -bat->charge_current_max; // TODO: discharge current
|
||||
|
||||
port->voltage_output_target = bat->cell_voltage_max * bat->num_cells;
|
||||
port->voltage_output_min = bat->cell_voltage_absolute_min * bat->num_cells;
|
||||
port->current_output_max = bat->charge_current_max;
|
||||
}
|
||||
|
||||
void dcdc_port_init_solar(dcdc_port_t *port)
|
||||
{
|
||||
port->input_allowed = true; // PV panel may provide power to solar input of DC/DC
|
||||
port->output_allowed = false;
|
||||
|
||||
port->voltage_input_start = 16.0;
|
||||
port->voltage_input_stop = 14.0;
|
||||
port->current_input_max = -18.0;
|
||||
}
|
||||
|
||||
void dcdc_port_init_nanogrid(dcdc_port_t *port)
|
||||
{
|
||||
port->input_allowed = true;
|
||||
port->output_allowed = true;
|
||||
|
||||
port->voltage_input_start = 30.0; // starting buck mode above this point
|
||||
port->voltage_input_stop = 20.0; // stopping buck mode below this point
|
||||
port->current_input_max = -5.0;
|
||||
|
||||
port->voltage_output_target = 28.0; // starting idle mode above this point
|
||||
port->current_output_max = 5.0;
|
||||
port->voltage_output_min = 10.0;
|
||||
port->droop_resistance = 1.0; // 1 Ohm means 1V change of target voltage per amp
|
||||
}
|
||||
|
||||
|
||||
// returns if output power should be increased (1), decreased (-1) or switched off (0)
|
||||
int _dcdc_output_control(dcdc_t *dcdc, dcdc_port_t *out, dcdc_port_t *in)
|
||||
int _dcdc_output_control(dcdc_t *dcdc, power_port_t *out, power_port_t *in)
|
||||
{
|
||||
//static float dcdc_power;
|
||||
float dcdc_power_new = out->voltage * out->current;
|
||||
@@ -120,7 +79,7 @@ int _dcdc_output_control(dcdc_t *dcdc, dcdc_port_t *out, dcdc_port_t *in)
|
||||
}
|
||||
}
|
||||
|
||||
bool _dcdc_check_start_conditions(dcdc_t *dcdc, dcdc_port_t *out, dcdc_port_t *in)
|
||||
bool _dcdc_check_start_conditions(dcdc_t *dcdc, power_port_t *out, power_port_t *in)
|
||||
{
|
||||
return out->output_allowed == true
|
||||
&& out->voltage < out->voltage_output_target
|
||||
@@ -131,7 +90,7 @@ bool _dcdc_check_start_conditions(dcdc_t *dcdc, dcdc_port_t *out, dcdc_port_t *i
|
||||
&& time(NULL) > (dcdc->off_timestamp + dcdc->restart_interval);
|
||||
}
|
||||
|
||||
void dcdc_control(dcdc_t *dcdc, dcdc_port_t *hs, dcdc_port_t *ls)
|
||||
void dcdc_control(dcdc_t *dcdc, power_port_t *hs, power_port_t *ls)
|
||||
{
|
||||
if (half_bridge_enabled()) {
|
||||
int step;
|
||||
|
||||
Reference in New Issue
Block a user