From e747b9d10b64074cb307272955b9ec3469406b50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phillip=20K=C3=BChne?= Date: Tue, 11 Feb 2025 20:10:43 +0100 Subject: [PATCH] Add data gathered from measurement results --- src/power/Consumptions.h | 34 ----------- src/power/PowerParameters.h | 109 ++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 34 deletions(-) delete mode 100644 src/power/Consumptions.h create mode 100644 src/power/PowerParameters.h diff --git a/src/power/Consumptions.h b/src/power/Consumptions.h deleted file mode 100644 index 0344110..0000000 --- a/src/power/Consumptions.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file Consumptions.h - * @author Phillip Kühne - * @brief - * @version 0.1 - * @date 2024-11-28 - * - * @copyright (c) 2024 - * - */ - -#ifndef Consumptions_h -#define Consumptions_h - -// The power budget afforded by the LIR2450 button cell, 700mW -#define POWER_BUDGET 700 - -// The power consumptions of the different components are defined here. -// These are "typical worst case" values for now. -#define CONSUMPTION_ESP_BASE 96 -#define CONSUMPTION_ESP_LOAD 100 -#define CONSUMPTION_RGB_LED 56 -#define CONSUMPTION_IR_BOTTOM 327 -#define CONSUMPTION_IR_FRONT 492 -#define CONSUMPTION_OLED 92 // Assumes lots of lit pixels -#define CONSUMPTION_MOTOR 323 -// These are placeholders for completeness for now -#define CONSUMPTION_RGBW_SENSOR 1 -#define CONSUMPTION_IR_PT 1 -#define CONSUMPTION_UV_LED 200 -#define CONSUMPTION_IMU 1 - - -#endif //Consumptions_h \ No newline at end of file diff --git a/src/power/PowerParameters.h b/src/power/PowerParameters.h new file mode 100644 index 0000000..a3f6066 --- /dev/null +++ b/src/power/PowerParameters.h @@ -0,0 +1,109 @@ +/** + * @file PowerParameters.h + * @author Phillip Kühne + * @brief + * @version 0.1 + * @date 2024-11-28 + * + * @copyright (c) 2024 + * + */ + +#ifndef PowerParameters_h +#define PowerParameters_h + +namespace PowerParameters { + + struct Battery { + // Datasheet values + static constexpr float CELL_CAPACITY_MAH = 120; + static constexpr float CELL_VOLTAGE_NOMINAL = 3.7; + struct DISCHARGE_CURVE { + static constexpr float REFERENCE_CURRENT_A = 0.05; + static constexpr int NUM_POINTS = 22; + static constexpr float VOLTAGES[NUM_POINTS] = { + 4.15, 4.05, 3.97, 3.9, 3.84, 3.795, 3.765, 3.74, 3.72, 3.7, 3.69, + 3.68, 3.675, 3.67, 3.665, 3.66, 3.64, 3.61, 3.55, 3.45, 3.25, 3.0}; + static constexpr int CHARGE_STATES[NUM_POINTS] = { + 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, + 45, 40, 35, 30, 25, 20, 15, 10, 5, 0, -5}; + }; + + // Derived values + static constexpr float CELL_CHARGE_FULL_COLOUMB = CELL_CAPACITY_MAH * 3.6; + static constexpr float CELL_ENERGY_FULL_JOULES = + CELL_CAPACITY_MAH * CELL_VOLTAGE_NOMINAL * 3.6; + static constexpr float CELL_CURRENT_1C = CELL_CAPACITY_MAH; + static constexpr float CELL_CURRENT_2C = CELL_CAPACITY_MAH * 2; + struct BAT_ADC { + static constexpr float VOLTAGE_DIVIDER_R12 = 27e3; + static constexpr float VOLTAGE_DIVIDER_R13 = 10e3; + static constexpr float VOLTAGE_DIVIDER_FACTOR = + (VOLTAGE_DIVIDER_R12 + VOLTAGE_DIVIDER_R13) / VOLTAGE_DIVIDER_R13; + }; + }; + + // Factors concerning Buck-Boost-Converter + static constexpr float BUCK_BOOST_EFFICIENCY = 0.9; + + /* + * The current consumptions in milliamperes of the different components are + * defined here. These values are measured on 3,3 Volts, and need to be + * converted to currents actually occuring at the battery. + */ + struct CurrentConsumptions { + static constexpr float CURRENT_ESP_BASE = 37.42; + static constexpr float CURRENT_ESP_LOAD = 88.43; + static constexpr float CURRENT_ESP_AVG = + (CURRENT_ESP_BASE + CURRENT_ESP_LOAD) / 2; + // RGB LED quiescent current + static constexpr float CURRENT_LED_RGB_BASE = 0.7; + // RGB LED per channel current during PWM on-time. + static constexpr float CURRENT_LED_RGB_CHAN_T_ON = 16; + static constexpr float CURRENT_SENSOR_RGBW = 0.2; + static constexpr float CURRENT_LED_IR_BOTTOM = 100; + static constexpr float CURRENT_LED_IR_FRONT = 180.7; + // Phototransistor current when active and illuminated. + static constexpr float CURRENT_PT = 0.33005; + // Average value, as internal behaviour can not non-expensively and + // accurately be observed from code. + static constexpr float CURRENT_DISPLAY = 9; + // Per motor current during PWM on-time. + static constexpr float CURRENT_MOTOR_T_ON = 130; + // Current of IMU when activated. + static constexpr float CURRENT_IMU = 0.55; + // LED Current. Placeholder. + static constexpr float CURRENT_UV_LED = 200; + }; + + struct PinConfig { + static constexpr int BAT_ADC = 10; + static constexpr int BAT_ADC_EN = 9; + static constexpr int VUSB_SENS = 38; + static constexpr int BAT_CHG_STAT = 39; + }; + + enum PowerConsumers { + ESP, + WIFI, + LED_RGB_TOP_LEFT, + LED_RGB_TOP_RIGHT, + LED_RGB_BOTTOM, + RGBW_SENSOR, + LED_IR_BOTTOM, + LED_IR_FRONT, + PT_IR_LEFT, + PT_IR_RIGHT, + PT_IR_FRONT, + PT_IR_BACK, + PT_DL_FRONT, + PT_DL_BOTTOM, + LED_UV, + DISPLAY, + MOTOR_LEFT, + MOTOR_RIGHT, + IMU + }; +}; + +#endif // Consumptions_h \ No newline at end of file