lincomatic / open_evse

Firmware for Open EVSE
GNU General Public License v3.0
114 stars 163 forks source link

Session Wh Counter Code Not Accurate #77

Closed lincomatic closed 6 years ago

lincomatic commented 6 years ago

I was just looking at the session Wh counter code, and it appears to make the erroneous assumption that it's called once per second. The code is in g_OnboardDisplay::Update() and is as follows:


      if (g_EvseController.GetCurSvcLevel() == 2) {                        //  first verify L2 or L1
    g_WattSeconds =  g_WattSeconds + (VOLTS_FOR_L2 * current / 1000);  // accumulate Watt Seconds for Level2 charging
      }
      else {
    g_WattSeconds =  g_WattSeconds + (VOLTS_FOR_L1 * current / 1000);  // accumulate Watt Seconds for Level1 charging
      }

The code doesn't take into time how much time has elapsed. It's just assuming that it's being called once per second. Though the code is usually called once per second, it can actually be called at random intervals, whenever the display needs to be updated

lincomatic commented 6 years ago

Rewrote KWH_RECORDING code.. probably needs more testing https://github.com/lincomatic/open_evse/commit/9ee6f1c1579dda2e98664debbbe8e34d2b678b68