From 9e53d0727d508145252c3b82330ae97d244f4bad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Bo=CC=88hm?= Date: Wed, 23 Oct 2024 21:47:50 +0200 Subject: [PATCH] Fix: SBS Unipower battery discharge current handling SBS CAN receiver implementation was not using the correct way to provide discharge current limit. --- include/BatteryStats.h | 1 - src/BatteryStats.cpp | 2 -- src/SBSCanReceiver.cpp | 6 +++--- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/include/BatteryStats.h b/include/BatteryStats.h index bcf7cedc5..9f5e533d3 100644 --- a/include/BatteryStats.h +++ b/include/BatteryStats.h @@ -159,7 +159,6 @@ class SBSBatteryStats : public BatteryStats { float _chargeVoltage; float _chargeCurrentLimitation; - float _dischargeCurrentLimitation; uint16_t _stateOfHealth; float _current; float _temperature; diff --git a/src/BatteryStats.cpp b/src/BatteryStats.cpp index 796158d2c..8f207ae2c 100644 --- a/src/BatteryStats.cpp +++ b/src/BatteryStats.cpp @@ -163,7 +163,6 @@ void SBSBatteryStats::getLiveViewData(JsonVariant& root) const // values go into the "Status" card of the web application addLiveViewValue(root, "chargeVoltage", _chargeVoltage, "V", 1); addLiveViewValue(root, "chargeCurrentLimitation", _chargeCurrentLimitation, "A", 1); - addLiveViewValue(root, "dischargeCurrentLimitation", _dischargeCurrentLimitation, "A", 1); addLiveViewValue(root, "stateOfHealth", _stateOfHealth, "%", 0); addLiveViewValue(root, "current", _current, "A", 1); addLiveViewValue(root, "temperature", _temperature, "°C", 1); @@ -419,7 +418,6 @@ void SBSBatteryStats::mqttPublish() const MqttSettings.publish("battery/settings/chargeVoltage", String(_chargeVoltage)); MqttSettings.publish("battery/settings/chargeCurrentLimitation", String(_chargeCurrentLimitation)); - MqttSettings.publish("battery/settings/dischargeCurrentLimitation", String(_dischargeCurrentLimitation)); MqttSettings.publish("battery/stateOfHealth", String(_stateOfHealth)); MqttSettings.publish("battery/current", String(_current)); MqttSettings.publish("battery/temperature", String(_temperature)); diff --git a/src/SBSCanReceiver.cpp b/src/SBSCanReceiver.cpp index 9150075c1..9d225d21c 100644 --- a/src/SBSCanReceiver.cpp +++ b/src/SBSCanReceiver.cpp @@ -74,10 +74,10 @@ void SBSCanReceiver::onMessage(twai_message_t rx_message) case 0x640: { _stats->_chargeCurrentLimitation = (this->readSignedInt24(rx_message.data + 3) * 0.001); - _stats->_dischargeCurrentLimitation = (this->readSignedInt24(rx_message.data)) * 0.001; + _stats->setDischargeCurrentLimit(this->readSignedInt24(rx_message.data) * 0.001, millis()); if (_verboseLogging) { - MessageOutput.printf("[SBS Unipower] 1600 Currents %f, %f \r\n", _stats->_chargeCurrentLimitation, _stats->_dischargeCurrentLimitation); + MessageOutput.printf("[SBS Unipower] 1600 Currents %f, %f \r\n", _stats->_chargeCurrentLimitation, _stats->getDischargeCurrentLimit()); } break; } @@ -144,7 +144,7 @@ void SBSCanReceiver::dummyData() _stats->setSoC(42, 0/*precision*/, millis()); _stats->_chargeVoltage = dummyFloat(50); _stats->_chargeCurrentLimitation = dummyFloat(33); - _stats->_dischargeCurrentLimitation = dummyFloat(12); + _stats->setDischargeCurrentLimit(dummyFloat(12), millis()); _stats->_stateOfHealth = 99; _stats->setVoltage(48.67, millis()); _stats->_current = dummyFloat(-1);