Energy calculation for PWM CC fixed

- Correct negative sign for incoming solar current
- Current multiplied with PWM duty cycle to get average current
- Min/max calculation moved to log.cpp
This commit is contained in:
Martin Jaeger
2019-05-15 11:06:49 +02:00
parent 05ccfb4c65
commit b742fe6671
7 changed files with 99 additions and 79 deletions
+9 -3
View File
@@ -1,5 +1,5 @@
/* LibreSolar MPPT charge controller firmware
* Copyright (c) 2016-2018 Martin Jäger (www.libre.solar)
/* LibreSolar charge controller firmware
* Copyright (c) 2016-2019 Martin Jäger (www.libre.solar)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,11 @@
#ifndef UNIT_TEST
/** @file
*
* @brief Entry point of charge controller firmware
*/
#include "mbed.h"
#include "thingset.h" // handles access to internal data via communication interfaces
@@ -86,7 +91,8 @@ void system_control()
dc_bus_energy_balance(&hs_bus);
dc_bus_energy_balance(&ls_bus);
dc_bus_energy_balance(&load_bus);
log_update_energy(&log_data, &ls_bus, &hs_bus, &load_bus);
log_update_energy(&log_data, &hs_bus, &ls_bus, &load_bus);
log_update_min_max_values(&log_data, &dcdc, &bat_state, &load, &hs_bus, &ls_bus, &load_bus);
battery_update_soc(&bat_conf, &bat_state, bat_bus->voltage, bat_bus->current);
}
counter++;