Add power modeling and scheduling based on thesis

This commit is contained in:
2025-02-12 16:09:40 +01:00
parent b44538b473
commit c63935a413
5 changed files with 195 additions and 54 deletions

View File

@@ -11,8 +11,6 @@
#ifndef Power_h
#define Power_h
#define TOTAL_POWER_MILLIWATTS POWER_BUDGET
enum TaskResumptionReason { POWER_AVAILABLE, TIMEOUT };
class Power {
@@ -55,6 +53,11 @@ public:
/// @return Battery charge state in percent
static int getBatteryChargePercent();
/// @brief Get estimated battery charge state as percentage based on
// voltage directly
/// @return Battery charge state in percent
static int getBatteryVoltageChargePercent();
/// @brief Get estimated battery charge state as coulombs
/// @return Battery charge state in coulombs
static float getBatteryChargeCoulombs();
@@ -62,26 +65,35 @@ public:
/// @brief get available current (after voltage conversion and efficiency
/// losses, referencing 1C discharge)
/// @return available current in milliamps
static float getAvailableCurrent();
static float getMax3V3Current();
protected:
/// @brief PowerScheduler instance to manage power consumption
static PowerScheduler *powerScheduler;
/// @brief update Power State
static void updatePowerState();
static void updatePowerStateHandler();
/*
* Power State
*/
/// @brief last time of power state update
static TickType_t lastPowerStateUpdate;
/// @brief remaining Charge in coulombs
static int coloumbsRemaining;
static float coloumbsRemaining;
/// @brief remaining Charge in percent
static int percentRemaining;
friend class PowerScheduler;
/// @brief Circular array of last calculated values for current state of
/// charge
static float lastSOC[PowerParameters::Battery::AVERAGING_SAMPLES];
static int latestSoCIndex;
/// @brief Add calculated value to circular array, pushing out oldest value
static void addSoCSample(float soc);
};
extern Power power;