Skip to content

Commit

Permalink
don't let $SC V increase ampacity above PP ampacity
Browse files Browse the repository at this point in the history
  • Loading branch information
lincomatic committed May 16, 2018
1 parent 17188f5 commit 739ac3f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
10 changes: 9 additions & 1 deletion firmware/open_evse/AutoCurrentCapacityController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ AutoCurrentCapacityController::AutoCurrentCapacityController() :
maxAmps = 0;
}

void AutoCurrentCapacityController::AutoSetCurrentCapacity()
uint8_t AutoCurrentCapacityController::ReadPPMaxAmps()
{
// n.b. should probably sample a few times and average it
uint16_t adcval = adcPP.read();
Expand All @@ -47,6 +47,14 @@ void AutoCurrentCapacityController::AutoSetCurrentCapacity()
}
}

return amps;
}


void AutoCurrentCapacityController::AutoSetCurrentCapacity()
{
uint8_t amps = ReadPPMaxAmps();

if (amps > maxAmps) {
amps = maxAmps;
}
Expand Down
3 changes: 2 additions & 1 deletion firmware/open_evse/AutoCurrentCapacityController.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ typedef struct pp_amps {

class AutoCurrentCapacityController {
AdcPin adcPP;
uint8_t maxAmps;
uint8_t maxAmps; // PP can't override this current
uint8_t curAmps;

public:
AutoCurrentCapacityController();
uint8_t GetCurAmps() { return curAmps; }
void SetMaxAmps(int8_t amps) { maxAmps = amps; }
uint8_t ReadPPMaxAmps();

void AutoSetCurrentCapacity();
};
Expand Down
9 changes: 9 additions & 0 deletions firmware/open_evse/J1772EvseController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1741,6 +1741,15 @@ int J1772EVSEController::SetCurrentCapacity(uint8_t amps,uint8_t updatelcd,uint8
int rc = 0;
uint8_t maxcurrentcap = (GetCurSvcLevel() == 1) ? MAX_CURRENT_CAPACITY_L1 : MAX_CURRENT_CAPACITY_L2;

#ifdef PP_AUTO_AMPACITY
if ((GetState() >= EVSE_STATE_B) && (GetState() <= EVSE_STATE_C)) {
uint8_t mcc = g_ACCController.ReadPPMaxAmps();
if (mcc && (mcc < maxcurrentcap)) {
maxcurrentcap = mcc;
}
}
#endif // PP_AUTO_AMPACITY

if ((amps >= MIN_CURRENT_CAPACITY_J1772) && (amps <= maxcurrentcap)) {
m_CurrentCapacity = amps;
}
Expand Down
2 changes: 2 additions & 0 deletions firmware/open_evse/open_evse.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@
#define PP_TABLE_IEC

#include "AutoCurrentCapacityController.h"

extern AutoCurrentCapacityController g_ACCController;
#endif

// charge for a specified amount of time and then stop
Expand Down
1 change: 1 addition & 0 deletions firmware/open_evse/rapi_proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ SC amps [V]- set current capacity
response:
if amps < minimum current capacity, will set to minimum and return $NK amps
if amps > maximum current capacity, will set to maximum and return $NK amps
if amps > maximum PP current capacity, will set to maximum PP current capacity and return $NK amps
if V specified, andcurrently in over temperature status, current capacity
will be unchanged, and return $NK amps if current capacity will be
increased by amps
Expand Down

0 comments on commit 739ac3f

Please sign in to comment.