-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added option to limit AC charger power based on battery SoC #449
Changes from 3 commits
f2162fe
3a877f4
015ed1e
71e4753
50acb25
73d166f
4a24c34
e883926
f3e39fb
4eb918c
8e423a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
#include "PowerMeter.h" | ||
#include "PowerLimiter.h" | ||
#include "Configuration.h" | ||
#include "Battery.h" | ||
#include <SPI.h> | ||
#include <mcp_can.h> | ||
|
||
|
@@ -230,7 +231,7 @@ void HuaweiCanClass::loop() | |
// Calculate new power limit | ||
float newPowerLimit = -1 * round(PowerMeter.getPowerTotal()); | ||
newPowerLimit += _rp.output_power; | ||
MessageOutput.printf("[HuaweiCanClass::loop] PL: %f, OP: %f \r\n", newPowerLimit, _rp.output_power); | ||
MessageOutput.printf("[HuaweiCanClass::loop] newPowerLimit: %f, output_power: %f \r\n", newPowerLimit, _rp.output_power); | ||
|
||
if (newPowerLimit > config.Huawei_Auto_Power_Lower_Power_Limit) { | ||
|
||
|
@@ -249,7 +250,14 @@ void HuaweiCanClass::loop() | |
_autoPowerEnabled = 10; | ||
} | ||
|
||
// Limit power to maximum | ||
if (config.Battery_Enabled && config.Huawei_Auto_Power_Reduce_On_BatterySoC_Enabled){ | ||
uint8_t _batterySoC = Battery.getStats()->getSoC(); | ||
if (_batterySoC >= config.Huawei_Auto_Power_BatterySoC_Threshold && newPowerLimit > config.Huawei_Auto_Power_Reduced_Upper_Power_Limit){ | ||
MessageOutput.printf("[HuaweiCanClass::loop] Current battery SoC %i reached threshold %i, reducing output power to %f \r\n", _batterySoC, config.Huawei_Auto_Power_BatterySoC_Threshold, config.Huawei_Auto_Power_Reduced_Upper_Power_Limit); | ||
newPowerLimit = config.Huawei_Auto_Power_Reduced_Upper_Power_Limit; | ||
} | ||
} | ||
// Limit power to maximum | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing an empty line before this comment, and comment was indented by accident. It should actually not change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
if (newPowerLimit > config.Huawei_Auto_Power_Upper_Power_Limit) { | ||
newPowerLimit = config.Huawei_Auto_Power_Upper_Power_Limit; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ dist-ssr | |
coverage | ||
*.local | ||
vite.user.ts | ||
.yarn | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change has nothing to do with the feature described in this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, but I didn't know any other way to avoid pushing the 400+ cached yarn packages into the repo. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my comment below regarding the git staging area and selecting parts of your workdir to be included in the next commit. |
||
.yarnrc.yml | ||
|
||
/cypress/videos/ | ||
/cypress/screenshots/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -777,12 +777,17 @@ | |
"Configuration": "AC Ladegerät Konfiguration", | ||
"EnableHuawei": "Huawei R4850G2 an CAN Bus Interface aktiv", | ||
"EnableAutoPower": "Automatische Leistungssteuerung", | ||
"EnableReducePowerOnBatterySoC": "Leistung abhängig vom Batterie-Ladezustand reduzieren", | ||
"EnableReducePowerOnBatterySoCHint": "Wenn eine Batterie per CAN-Bus verbunden ist, kann die maximale Ausgangsleistung ab einem bestimmten SoC reduziert werden", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will work for all kind of battery interfaces (Pylontech via CAN, JK BMS via serial, or Victron SmartShunt via Serial, or in the future also via MQTT). Please change the wording accordingly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do 👍 |
||
"Limits": "Limits", | ||
"BatterySoCLimits": "Batterie SoC-Limits", | ||
"VoltageLimit": "Ladespannungslimit", | ||
"enableVoltageLimit": "Start Spannungslimit", | ||
"enableVoltageLimitHint": "Die automatische Leistungssteuerung wird deaktiviert wenn die Ausgangsspannung über diesem Wert liegt und wenn gleichzeitig die Ausgangsleistung unter die minimale Leistung fällt.\nDie automatische Leistungssteuerung wird re-aktiveiert wenn die Batteriespannung unter diesen Wert fällt.", | ||
"lowerPowerLimit": "Minimale Leistung", | ||
"upperPowerLimit": "Maximale Leistung", | ||
"BatterySoCThreshold": "Batterie SoC-Schwellenwert", | ||
"ReducedUpperPowerLimit": "Maximale Leistung, wenn SoC-Schwellenwert erreicht ist", | ||
"Seconds": "@:dtuadmin.Seconds", | ||
"Save": "@:dtuadmin.Save" | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
export interface AcChargerConfig { | ||
enabled: boolean; | ||
auto_power_enabled: boolean; | ||
auto_power_reduce_on_batterysoc_enabled: boolean; | ||
voltage_limit: number; | ||
enable_voltage_limit: number; | ||
lower_power_limit: number; | ||
upper_power_limit: number; | ||
batterysoc_threshold: number; | ||
reduced_upper_power_limit: number; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,12 @@ | |
:label="$t('acchargeradmin.EnableAutoPower')" | ||
v-model="acChargerConfigList.auto_power_enabled" | ||
type="checkbox" wide/> | ||
<InputElement v-show="acChargerConfigList.auto_power_enabled" | ||
:label="$t('acchargeradmin.EnableReducePowerOnBatterySoC')" | ||
v-model="acChargerConfigList.auto_power_reduce_on_batterysoc_enabled" | ||
type="checkbox" wide> | ||
<BIconInfoCircle v-tooltip :title="$t('acchargeradmin.EnableReducePowerOnBatterySoCHint')" /> | ||
</InputElement> | ||
|
||
<CardElement :text="$t('acchargeradmin.Limits')" textVariant="text-bg-primary" add-space | ||
v-show="acChargerConfigList.auto_power_enabled"> | ||
|
@@ -51,12 +57,36 @@ | |
<div class="input-group"> | ||
<input type="number" class="form-control" id="upperPowerLimit" | ||
placeholder="2000" v-model="acChargerConfigList.upper_power_limit" | ||
aria-describedby="lowerPowerLimitDescription" min="100" max="3000" required/> | ||
aria-describedby="upperPowerLimitDescription" min="100" max="3000" required/> | ||
<span class="input-group-text" id="upperPowerLimitDescription">W</span> | ||
</div> | ||
</div> | ||
</div> | ||
</CardElement> | ||
<CardElement :text="$t('acchargeradmin.BatterySoCLimits')" textVariant="text-bg-primary" add-space | ||
v-show="acChargerConfigList.auto_power_reduce_on_batterysoc_enabled"> | ||
<div class="row mb-3"> | ||
<label for="batterySoCThreshold" class="col-sm-2 col-form-label">{{ $t('acchargeradmin.BatterySoCThreshold') }}:</label> | ||
<div class="col-sm-10"> | ||
<div class="input-group"> | ||
<input type="number" class="form-control" id="batterySoCThreshold" | ||
placeholder="90" v-model="acChargerConfigList.batterysoc_threshold" | ||
aria-describedby="batterySoCThresholdDescription" min="1" max="99" required/> | ||
<span class="input-group-text" id="batterySoCThresholdDescription">%</span> | ||
</div> | ||
</div> | ||
<label for="reducedUpperPowerLimit" class="col-sm-2 col-form-label">{{ $t('acchargeradmin.ReducedUpperPowerLimit') }}:</label> | ||
<div class="col-sm-10"> | ||
<div class="input-group"> | ||
<input type="number" class="form-control" id="reducedUpperPowerLimit" | ||
placeholder="500" v-model="acChargerConfigList.reduced_upper_power_limit" | ||
aria-describedby="reducedUpperPowerLimitDescription" min="100" max="3000" required/> | ||
<span class="input-group-text" id="reducedUpperPowerLimitDescription">W</span> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
</CardElement> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The div in this CardElement is not properly indented. Why is it indented two or three levels to many? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I honestly don't know, but I will change it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm? Now the diff looks way to big... There are now changes to pats that are not concerned with this feature. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Purely cosmetic, I added another |
||
</CardElement> | ||
|
||
<button type="submit" class="btn btn-primary mb-3">{{ $t('acchargeradmin.Save') }}</button> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How often will this appear once the threshold is reached? In every call to loop()? Or is this section of the function only reached with a fixed interval? I am asking to make sure that this does not flood the serial line or the web console.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does get called regularly when the battery SoC threshold is reached, but since all other outputs in this function are like this, it doesn't really make a huge difference.
Personally, I would like to add a verbose logging switch to this settings page and link most console outputs to it, but I didn't get around to it yet.