Fix oversights in modeling functions

This commit is contained in:
Phillip Kühne 2025-02-15 22:07:33 +01:00
parent ff80ebe4db
commit 62d4c6bdb0
Signed by: phillip
GPG Key ID: E4C1C4D2F90902AA
4 changed files with 21 additions and 8 deletions

View File

@ -136,3 +136,15 @@ uint16_t LightDetection::readDLPT(photoTransistors sensor){
digitalWrite(DL_PT_ENABLE,LOW); digitalWrite(DL_PT_ENABLE,LOW);
return result; return result;
}; };
float LightDetection::modelCurrentConsumption(photoTransistors sensor){
if(sensor == DL_FRONT || sensor == DL_BOTTOM){
return PowerParameters::CurrentConsumptions::CURRENT_PT * 2;
} else {
return PowerParameters::CurrentConsumptions::CURRENT_PT * 4;
}
};
float LightDetection::modelChargeConsumptionOn(photoTransistors sensor, uint16_t durationMs) {
return LightDetection::modelCurrentConsumption(sensor) * durationMs * 10e6;
}

View File

@ -84,15 +84,16 @@ public:
* *
* @return float the current consumption of the PTs * @return float the current consumption of the PTs
*/ */
static float modelCurrentConsumption(void); static float modelCurrentConsumption(photoTransistors sensor);
/** /**
* @brief Estimate the energy consumption of setting the specified led to * @brief Estimate the energy consumption of enabling the selected PT for
* the passed color * the given duration
* @param durationMs time the led will be on * @param durationMs time the led will be on
* @return consumed energy in coloumbs * @return consumed energy in coloumbs
*/ */
float modelChargeConsumptionOn(uint16_t durationMs); static float modelChargeConsumptionOn(photoTransistors sensor,
uint16_t durationMs);
protected: protected:
static const uint8_t IR_PT_FRONT_ADC = 3; static const uint8_t IR_PT_FRONT_ADC = 3;

View File

@ -71,7 +71,7 @@ class Motor{
* @param durationMs time the display will be on * @param durationMs time the display will be on
* @return consumed energy in coloumbs * @return consumed energy in coloumbs
*/ */
float modelChargeConsumptionOn(uint16_t duty, uint16_t durationMs); float modelChargeConsumption(uint16_t duty, uint16_t durationMs);
protected: protected:

View File

@ -68,11 +68,11 @@ bool Motor::setSpeed(uint16_t duty) {
uint16_t Motor::getSpeed(void) { return this->duty; }; uint16_t Motor::getSpeed(void) { return this->duty; };
float modelCurrentConsumption(uint16_t duty) { float Motor::modelCurrentConsumption(uint16_t duty) {
const float dutyFactor = duty / static_cast<float>(1 << DUTY_RES); const float dutyFactor = duty / static_cast<float>(1 << DUTY_RES);
return PowerParameters::CurrentConsumptions::CURRENT_MOTOR_T_ON * dutyFactor; return PowerParameters::CurrentConsumptions::CURRENT_MOTOR_T_ON * dutyFactor;
} }
float modelChargeConsumptionOn(uint16_t duty, uint16_t durationMs) { float Motor::modelChargeConsumption(uint16_t duty, uint16_t durationMs) {
return modelCurrentConsumption(duty) * durationMs * 10e6; return modelCurrentConsumption(duty) * durationMs * 10e6;
} }