Skip to content

Commit

Permalink
Merge branch 'ppauto' of https://github.com/lincomatic/open_evse
Browse files Browse the repository at this point in the history
  • Loading branch information
lincomatic committed Apr 4, 2023
2 parents 8395523 + 1da09d5 commit caac7f2
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 3 deletions.
5 changes: 4 additions & 1 deletion firmware/open_evse/AutoCurrentCapacityController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ uint8_t AutoCurrentCapacityController::ReadPPMaxAmps()

// Serial.print("pp: ");Serial.print(adcval);Serial.print(" amps: ");Serial.println(amps);

ppMaxAmps = amps;
return amps;
}

Expand All @@ -54,7 +55,9 @@ uint8_t AutoCurrentCapacityController::AutoSetCurrentCapacity()
uint8_t amps = ReadPPMaxAmps();

if (amps) {
g_EvseController.SetCurrentCapacity(amps,0,1);
if (g_EvseController.GetCurrentCapacity() > ppMaxAmps) {
g_EvseController.SetCurrentCapacity(ppMaxAmps,1,1);
}
return 0;
}
else {
Expand Down
2 changes: 2 additions & 0 deletions firmware/open_evse/AutoCurrentCapacityController.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ typedef struct pp_amps {

class AutoCurrentCapacityController {
AdcPin adcPP;
uint8_t ppMaxAmps;

public:
AutoCurrentCapacityController();
uint8_t GetPPMaxAmps() { return ppMaxAmps; }
uint8_t ReadPPMaxAmps();
uint8_t AutoSetCurrentCapacity();
};
Expand Down
6 changes: 6 additions & 0 deletions firmware/open_evse/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Change Log

20230207 SCL
- PP_AUTO_AMPACITY changes
-> used to change current capacity to PP ampacity. now, only change it
if currently higher than PP ampacity
-> GetMaxCurrentCapacity() is limited to PP ampacity in STATE B/C

20230206 SCL
- added BOOTLOCK - when defined, EVSE locked until receives $SB

Expand Down
10 changes: 10 additions & 0 deletions firmware/open_evse/J1772EvseController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,16 @@ uint8_t J1772EVSEController::GetMaxCurrentCapacity()
if ((ampacity == 0xff) || (ampacity == 0)) {
ampacity = (svclvl == 1) ? DEFAULT_CURRENT_CAPACITY_L1 : DEFAULT_CURRENT_CAPACITY_L2;
}

#ifdef PP_AUTO_AMPACITY
if ((m_EvseState >= EVSE_STATE_B) && (m_EvseState <= EVSE_STATE_C)) {
uint8_t ppamps = g_ACCController.GetPPMaxAmps();
if (ppamps < ampacity) {
ampacity = ppamps;
}
}
#endif // PP_AUTO_AMPACITY


if (ampacity < MIN_CURRENT_CAPACITY_J1772) {
ampacity = MIN_CURRENT_CAPACITY_J1772;
Expand Down
3 changes: 2 additions & 1 deletion firmware/open_evse/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2457,11 +2457,12 @@ uint8_t StateTransitionReqFunc(uint8_t curPilotState,uint8_t newPilotState,uint8
retEvseState = EVSE_STATE_A;
}
}
else { // EVSE_STATE_A
/* else { // EVSE_STATE_A
// reset back to default max current
uint8_t amps = g_EvseController.GetMaxCurrentCapacity();
g_EvseController.SetCurrentCapacity(amps,0,1);
}
*/
// Serial.print(" r: ");Serial.print(retEvseState);Serial.print(" a: ");Serial.print(g_ACCController.GetCurAmps());
// Serial.print(" c: ");Serial.print(curEvseState);Serial.print(" n: ");Serial.print(newEvseState);Serial.print(" r: ");Serial.print(retEvseState);

Expand Down
2 changes: 2 additions & 0 deletions firmware/open_evse/rapi_proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ GC - get current capacity info
hmaxamps - max hardware allowed current capacity MAX_CURRENT_CAPACITY_Ln
pilotamps - current capacity advertised by pilot
cmaxamps - max configured allowed current capacity (saved to EEPROM)
if PP_AUTO_AMPACITY is enabled, then in STATE B/C returns max capacity
read from PP if lower than max configured capacity
n.b. maxamps,emaxamps values are dependent on the active service level (L1/L2)
$GC^20
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ build_src_flags =
-DRAPI_SERIAL
-DRAPI_WF
-DRAPI_BTN
#-DPP_AUTO_AMPACITY
-DPP_AUTO_AMPACITY
-DTIME_LIMIT
-DCHARGE_LIMIT
-DMENNEKES_LOCK
Expand Down

0 comments on commit caac7f2

Please sign in to comment.