mr-manuel / venus-os_dbus-serialbattery

Battery Monitor driver for serial battery in VenusOS GX systems
https://mr-manuel.github.io/venus-os_dbus-serialbattery_docs/
MIT License
47 stars 17 forks source link

Remove round function for soc_calc_capacity_remain #100

Closed jojo18222 closed 1 week ago

jojo18222 commented 2 weeks ago

Describe the bug

In File battery.py Line 470 the calculatated soc_calc_capacity_remain is rounded to 3 decimal places. This should removed because small current values have no affect and so the soc_calc_capacity_remain and Soc value doesn't change.

How to reproduce

SOC_CALCULATION = True SOC_CALC_CURRENT_REPORTED_BY_BMS = -300, 0, 300 SOC_CALC_CURRENT_MEASURED_BY_USER = -300, -0.1, 300 Low Soc is reached, BMS current is 0A, calculatated Soc stays forever at the low Soc value.

Expected behavior

Soc should slowly reduced.

Driver version of the currently installed driver

1.4.20240902dev

Driver version of the last known working driver

No response

Venus OS device type

Raspberry Pi 4

Venus OS version

3.50

BMS type

Daly BMS

Cell count

16

Battery count

1

Connection type

Serial USB adapter to RS485

Config file

SOC_CALCULATION   = True
SOC_CALC_CURRENT_REPORTED_BY_BMS  = -300, 0, 300
SOC_CALC_CURRENT_MEASURED_BY_USER = -300, -0.1, 300

Relevant log output

-

Any other information that may be helpful

No response

mr-manuel commented 2 weeks ago

Currents smaller than three decimals are so low that your measurement reading is probably not accurate enough to measure it. Even a SmartShunt has a maximum accuracy of 0.1 A. I don't think that a Daly BMS is that accurate. Probably your correction table should be updated.

jojo18222 commented 2 weeks ago

Correct, the Daly BMS current starts at 0.4A I think. I have connected Venus os raspi with a DC/DC converter directly to the battery. The clamp meter shows round about 0.1A. So in the correction table I set if BMS shows 0A, the real value is -0.1A. With an older version of serial driver, the Soc was reduced slowly if the multiplus was in idle, for example at low Soc situation. Now, with the rounded value, Soc stays forever at a Soc value and I think this is not how it should work.

mr-manuel commented 1 week ago

Which older version? I don‘t think that this is the issue. You should calibrate the current measurement on your Daly BMS, if this is possible with Daly. I tested with a simulated current of 0.01 A and it worked correctly. The current measurement for that current is simply too small.

jojo18222 commented 1 week ago

Here is the round function not implemented: https://github.com/Louisvdw/dbus-serialbattery/blob/fd0fc1a193427df6ca0fadd141aa57826f761819/etc/dbus-serialbattery/battery.py#L280 Ok, I don't have further arguments. I can't calibrate the daly bms, because the current of the raspi is to low (5 Watts). And if soc_calc_capacity_remain is rounded and the Multiplus 2 is in idle or off, the soc never get lower although the raspi consumes 5 Watts. After some days or longer, the real soc is way lower then the calculated soc. I don't understand the advantages of the soc_calc_capacity_remain is rounded, because a line before, the soc_calc_capacity_remain is calculated without rounding and later, the soc value is rounded with 2 digits anyway.

mr-manuel commented 1 week ago

Could you try to change the rounding to 6 decimals? Some values are rounded, to filter out stupid values like 45.0000000000001 or 29.99999999999998 that happen sometimes.

jojo18222 commented 1 week ago

Sure, I can test 6 decimal places. But as I can see, this value (soc_calc_capacity_remain) is never published to dbus, so it is only a internal value for soc calculaction, and the soc value is rounded to 2 decimal places, which makes sense. https://github.com/mr-manuel/venus-os_dbus-serialbattery/blob/7113c1fe0feb436c53d62195cae8fa5bf3e16879/etc/dbus-serialbattery/battery.py#L527 So there is no advantages to round soc_calc_capacity_remain, only that the soc value is more inexact in my opinion.

mr-manuel commented 1 week ago

Now I had more time to check the code. Indeed it does not make any sense. It was rounded since the first PR. Currently I have a bigger change in the pipeline, therefore it will take some time, but the rounding will be removed in the next version. Until then I leave the issue open.

jojo18222 commented 1 week ago

Hey, thanks for the change. Sorry to bother you again. You also changed the digital places for soc_calc from 2 to 3. But this has no effect because in dbushelper.py soc_calc is rounded back to 2 decimal places. https://github.com/mr-manuel/venus-os_dbus-serialbattery/blob/81d743ba207bd4fdfc696707412f11bdab33d3b8/etc/dbus-serialbattery/dbushelper.py#L816

mr-manuel commented 1 week ago

Yes I changed that also. This is only relevant for a more pricise saving of the calculated SOC to the dbus. Useful for batteries with >1.000 Ah.