DCDC enable data object (input type) added

This commit is contained in:
Martin Jaeger
2019-03-25 18:16:31 +01:00
parent bb2ab2a9d5
commit e80e33606b
3 changed files with 13 additions and 4 deletions
+1
View File
@@ -101,6 +101,7 @@ const data_object_t data_objects[] = {
{0x60, TS_CAT_INPUT, TS_ACCESS_READ | TS_ACCESS_WRITE, TS_T_BOOL, 0, (void*) &(load.enabled_target), "LoadEn"}, // change w/o store setting in NVM
{0x61, TS_CAT_INPUT, TS_ACCESS_READ | TS_ACCESS_WRITE, TS_T_BOOL, 0, (void*) &(load.usb_enabled_target), "USBEn"},
{0x62, TS_CAT_INPUT, TS_ACCESS_READ | TS_ACCESS_WRITE, TS_T_BOOL, 0, (void*) &(dcdc.enabled), "DCDCEn"},
// OUTPUT DATA ////////////////////////////////////////////////////////////
// using IDs >= 0x70 except for high priority data objects
+11 -4
View File
@@ -26,6 +26,7 @@
void dcdc_init(dcdc_t *dcdc)
{
dcdc->mode = DCDC_MODE_INIT;
dcdc->enabled = true;
dcdc->ls_current_max = DCDC_CURRENT_MAX;
dcdc->ls_current_min = 0.05; // A if lower, charger is switched off
dcdc->hs_voltage_max = HIGH_SIDE_VOLTAGE_MAX; // V
@@ -40,11 +41,10 @@ void dcdc_init(dcdc_t *dcdc)
// returns if output power should be increased (1), decreased (-1) or switched off (0)
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;
static int pwm_delta = 1;
//printf("P: %.2f, P_prev: %.2f, v_in: %.2f, v_out: %.2f, i_in: %.2f, i_out: %.2f, i_max: %.2f, PWM: %.1f, chg_en: %d",
//printf("P: %.2f, P_prev: %.2f, v_in: %.2f, v_out: %.2f, i_in: %.2f, i_out: %.2f, i_max: %.2f, PWM: %.1f, chg_en: %d\n",
// dcdc_power_new, dcdc->power, in->voltage, out->voltage, in->current, out->current,
// out->current_output_max, half_bridge_get_duty_cycle() * 100.0, out->output_allowed);
@@ -104,19 +104,26 @@ void dcdc_control(dcdc_t *dcdc, power_port_t *hs, power_port_t *ls)
step = _dcdc_output_control(dcdc, hs, ls);
half_bridge_duty_cycle_step(-step);
}
if (step == 0) {
half_bridge_stop();
dcdc->off_timestamp = time(NULL);
printf("DC/DC stop.\n");
}
if (ls->voltage > dcdc->ls_voltage_max || hs->voltage > dcdc->hs_voltage_max) {
else if (ls->voltage > dcdc->ls_voltage_max || hs->voltage > dcdc->hs_voltage_max) {
half_bridge_stop();
dcdc->off_timestamp = time(NULL);
printf("DC/DC emergency stop (voltage limits exceeded).\n");
}
else if (dcdc->enabled == false) {
half_bridge_stop();
printf("DC/DC stop (disabled).\n");
}
}
else {
if (ls->voltage > dcdc->ls_voltage_max || hs->voltage > dcdc->hs_voltage_max) {
if (dcdc->enabled == false ||
ls->voltage > dcdc->ls_voltage_max ||
hs->voltage > dcdc->hs_voltage_max) {
return;
}
if (_dcdc_check_start_conditions(dcdc, ls, hs)) {
+1
View File
@@ -47,6 +47,7 @@ enum dcdc_control_mode
*/
typedef struct {
dcdc_control_mode mode; ///< DC/DC mode (buck, boost or nanogrid)
bool enabled; ///< Can be used to disable the DC/DC power stage
// actual measurements
float ls_current; ///< Low-side (inductor) current