Improve soc estimator accuracy (#554)

This commit is contained in:
premultiply 2020-12-29 13:25:01 +01:00 • committed by GitHub
parent 5ec59a65ba
commit 87fe402a4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View file

@ -111,7 +111,8 @@ func (s *SocEstimator) SoC(chargedEnergy float64) (float64, error) {
if socDelta != 0 || energyDelta < 0 { // soc value change or unexpected energy reset
// calculate gradient, wh per soc %
if socDelta > 1 && energyDelta > 0 && s.prevSoC > 0 {
// TODO: drop samples with unmatching state of evse and vehicle
if socDelta > 2 && energyDelta > 0 && s.prevSoC > 0 {
s.energyPerSocStep = energyDelta / socDelta
s.virtualCapacity = s.energyPerSocStep * 100
s.log.TRACE.Printf("soc gradient updated: energyPerSocStep: %0.0fWh, virtualCapacity: %0.0fWh", s.energyPerSocStep, s.virtualCapacity)

View file

@ -58,7 +58,7 @@ func TestSoCEstimation(t *testing.T) {
{7100, 71.0, 71.0, 10000},
{7300, 72.0, 72.0, 10000},
{7400, 73.0, 73.0, 10000},
{7700, 75.0, 75.0, 15000}, // 0.3kWh add 2% -> 15kWh battery
{7700, 75.0, 75.0, 10000},
{8200, 80.0, 80.0, 10000},
{0, 25.0, 25.0, 10000},
{2500, 25.0, 50.0, 10000},