Skip to content

Commit

Permalink
fix SLEEP delay opening contactor too early bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lincomatic committed Dec 16, 2019
1 parent abc571d commit 21cfccd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
3 changes: 3 additions & 0 deletions firmware/open_evse/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Change Log

D6.1.2 20191216 SCL
- fix bug in relay opening delay code for SLEEP state - wasn't reading/comparing charging current correctly.. was always reading too low, so would instantly open the contactor
- change SLEEP delay threshold current from 3A -> 1A

20191215 SCL
- added #ifndef VERSION around #define VERSION
Expand Down
29 changes: 20 additions & 9 deletions firmware/open_evse/J1772EvseController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,14 +526,16 @@ void J1772EVSEController::Sleep()
pinSleepStatus.write(1);
#endif // SLEEP_STATUS_REG

g_OBD.Update(OBD_UPD_FORCE);
#ifdef RAPI
RapiSendEvseState();
#endif // RAPI
// try to prevent arcing of our relay by waiting for EV to open its contacts first
// use the charge end time variable temporarily to count down
// when to open the contacts in Update()
m_ChargeOffTimeMS = millis();

g_OBD.Update(OBD_UPD_FORCE);

#ifdef RAPI
RapiSendEvseState();
#endif // RAPI
}
}

Expand Down Expand Up @@ -1119,17 +1121,26 @@ void J1772EVSEController::Update(uint8_t forcetransition)
// if it doesn't happen within 3 sec, we'll just open our relay anyway
// c) no current draw means EV opened its contacts even if it stays in STATE C
// allow 3A slop for ammeter inaccuracy
#ifdef AMMETER
readAmmeter();
long instantma = m_AmmeterReading*m_CurrentScaleFactor - m_AmmeterCurrentOffset;
if (instantma < 0) instantma = 0;
#endif // AMMETER
if ((phigh >= m_ThreshData.m_ThreshBC)
#ifdef AMMETER
|| (m_AmmeterReading <= 3000)
|| (instantma <= 1000L)
#endif // AMMETER
|| ((curms - m_ChargeOffTimeMS) >= 3000)) {
chargingOff();
|| ((curms - m_ChargeOffTimeMS) >= 3000UL)) {
#ifdef FT_SLEEP_DELAY
sprintf(g_sTmp,"SLEEP OPEN %d",(int)phigh);
// sprintf(g_sTmp,"SLEEP OPEN %d",(int)phigh);
// g_OBD.LcdMsg(g_sTmp,(phigh >= m_ThreshData.m_ThreshBC) ? "THRESH" : "TIMEOUT");
sprintf(g_sTmp,"%d %lu %lu",phigh,instantma,(curms-m_ChargeOffTimeMS));
g_OBD.LcdMsg(g_sTmp,(phigh >= m_ThreshData.m_ThreshBC) ? "THRESH" : "TIMEOUT");
chargingOff();
for(;;)
wdt_delay(2000);
#endif
#endif // FT_SLEEP_DELAY
chargingOff();
}
}
else { // not charging
Expand Down

0 comments on commit 21cfccd

Please sign in to comment.