|
@@ -21,6 +21,8 @@
|
|
|
#define PRE_CHARG_RANGE 50
|
|
|
#define EQUAL 0
|
|
|
#define CMD_DELAY_TIME 25000
|
|
|
+#define LOG_VOL_GAP 50
|
|
|
+#define LOG_CUR_GAP 5
|
|
|
|
|
|
struct SysConfigAndInfo *ShmSysConfigAndInfo;
|
|
|
struct StatusCodeData *ShmStatusCodeData;
|
|
@@ -31,8 +33,7 @@ byte getAvailableCapOffset = 5;
|
|
|
byte deratingKeepCount = 0;
|
|
|
byte psuCmdSeq = _PSU_CMD_CAP;
|
|
|
|
|
|
-float evseOutVol = 0;
|
|
|
-float evseOutCur = 0;
|
|
|
+float chargingOutputLogInfo[2][4];
|
|
|
|
|
|
void PRINTF_FUNC(char *string, ...);
|
|
|
|
|
@@ -338,10 +339,10 @@ void GetStatusCallback(byte group, byte SN, byte temp, int alarm)
|
|
|
}
|
|
|
|
|
|
for(byte psuIndex = 0; psuIndex < conn_1_count; psuIndex++)
|
|
|
- PRINTF_FUNC("Connector 1 - Number = %d \n", connector_1[psuIndex]);
|
|
|
+ PRINTF_FUNC("Connector 1 - PSU Number = %d \n", connector_1[psuIndex]);
|
|
|
|
|
|
for(byte psuIndex = 0; psuIndex < conn_2_count; psuIndex++)
|
|
|
- PRINTF_FUNC("Connector 2 - Number = %d \n", connector_2[psuIndex]);
|
|
|
+ PRINTF_FUNC("Connector 2 - PSU Number = %d \n", connector_2[psuIndex]);
|
|
|
}
|
|
|
}
|
|
|
// no using -- GetOutputAndTempCallback End
|
|
@@ -361,8 +362,18 @@ void GetMaxPowerAndCur(unsigned char mode, int ratingCur, int *pow, int *cur)
|
|
|
if (ShmPsuData->Work_Step < GET_SYS_CAP)
|
|
|
return;
|
|
|
|
|
|
- unsigned short maxCurrent = ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent * 10;
|
|
|
- unsigned short maxPower = ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10;
|
|
|
+ //unsigned short maxCurrent = ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent * 10;
|
|
|
+ unsigned short maxCurrent = ShmPsuData->SystemAvailableCurrent;
|
|
|
+ //unsigned short maxPower = ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10;
|
|
|
+ unsigned short maxPower = ShmPsuData->SystemAvailablePower;
|
|
|
+
|
|
|
+ if (ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent * 10 != 0 &&
|
|
|
+ ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent * 10 < maxCurrent)
|
|
|
+ maxCurrent = ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent * 10;
|
|
|
+
|
|
|
+ if (ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10 != 0 &&
|
|
|
+ ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10 < maxPower)
|
|
|
+ maxPower = ShmSysConfigAndInfo->SysConfig.MaxChargingPower * 10;
|
|
|
|
|
|
if (mode == _MAIN_CHARGING_MODE_AVER)
|
|
|
{
|
|
@@ -477,8 +488,11 @@ void GetAvailableCapCallback(byte address, short maxVol, short minVol, short max
|
|
|
|
|
|
//printf("=============== _current ==================== %d \n", _current);
|
|
|
//printf("=============== _ratingcurrent ==================== %d \n", _ratingcurrent);
|
|
|
- ShmPsuData->SystemAvailableCurrent = _current;
|
|
|
- ShmPsuData->SystemAvailablePower = _power;
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.BootingStatus == BOOTTING)
|
|
|
+ {
|
|
|
+ ShmPsuData->SystemAvailableCurrent = _current;
|
|
|
+ ShmPsuData->SystemAvailablePower = _power;
|
|
|
+ }
|
|
|
|
|
|
if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_AVER ||
|
|
|
(ShmSysConfigAndInfo->SysInfo.ReAssignedFlag >= _REASSIGNED_GET_NEW_CAP &&
|
|
@@ -882,7 +896,8 @@ void GetPresentOutputFCallback(byte group, float outVol, float outCur)
|
|
|
}
|
|
|
|
|
|
if ((chargingInfo[group]->SystemStatus >= S_PREPARING_FOR_EVSE && chargingInfo[group]->SystemStatus <= S_COMPLETE) ||
|
|
|
- (chargingInfo[group]->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingInfo[group]->SystemStatus <= S_CCS_PRECHARGE_ST1))
|
|
|
+ (chargingInfo[group]->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingInfo[group]->SystemStatus <= S_CCS_PRECHARGE_ST1) ||
|
|
|
+ chargingInfo[group]->SystemStatus == S_ALARM)
|
|
|
{
|
|
|
float _vol_buf = outputVol;
|
|
|
float _cur_buf = outputCur;
|
|
@@ -1135,6 +1150,37 @@ int InitShareMemory()
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+//================================================
|
|
|
+// Log function
|
|
|
+//================================================
|
|
|
+void OutputChargingLogFuncion(byte groupIndex)
|
|
|
+{
|
|
|
+ // 列印時機 : 需求改變或輸出電壓與紀錄落差超過 5V 或者輸出電流與紀錄落差超過 0.5A
|
|
|
+ if (chargingOutputLogInfo[groupIndex][_CHARGING_LOG_NEED_VOL] != chargingInfo[groupIndex]->EvBatterytargetVoltage * 10 ||
|
|
|
+ (chargingInfo[groupIndex]->FireChargingVoltage <= chargingOutputLogInfo[groupIndex][_CHARGING_LOG_OUTPUT_VOL] - LOG_VOL_GAP ||
|
|
|
+ chargingInfo[groupIndex]->FireChargingVoltage >= chargingOutputLogInfo[groupIndex][_CHARGING_LOG_OUTPUT_VOL] + LOG_VOL_GAP))
|
|
|
+ {
|
|
|
+ chargingOutputLogInfo[groupIndex][_CHARGING_LOG_NEED_VOL] = chargingInfo[groupIndex]->EvBatterytargetVoltage * 10;
|
|
|
+ chargingOutputLogInfo[groupIndex][_CHARGING_LOG_OUTPUT_VOL] = chargingInfo[groupIndex]->FireChargingVoltage;
|
|
|
+
|
|
|
+ PRINTF_FUNC("Conn %d, EV Req Voltage : %.1f, EVSE Output Voltage = %.1f \n", groupIndex,
|
|
|
+ chargingOutputLogInfo[groupIndex][_CHARGING_LOG_NEED_VOL] / 10,
|
|
|
+ chargingOutputLogInfo[groupIndex][_CHARGING_LOG_OUTPUT_VOL] / 10);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (chargingOutputLogInfo[groupIndex][_CHARGING_LOG_NEED_CUR] != chargingInfo[groupIndex]->EvBatterytargetCurrent * 10 ||
|
|
|
+ (chargingInfo[groupIndex]->PresentChargingCurrent <= chargingOutputLogInfo[groupIndex][_CHARGING_LOG_OUTPUT_CUR] - LOG_CUR_GAP ||
|
|
|
+ chargingInfo[groupIndex]->PresentChargingCurrent >= chargingOutputLogInfo[groupIndex][_CHARGING_LOG_OUTPUT_CUR] + LOG_CUR_GAP))
|
|
|
+ {
|
|
|
+ chargingOutputLogInfo[groupIndex][_CHARGING_LOG_NEED_CUR] = chargingInfo[groupIndex]->EvBatterytargetCurrent * 10;
|
|
|
+ chargingOutputLogInfo[groupIndex][_CHARGING_LOG_OUTPUT_CUR] = chargingInfo[groupIndex]->PresentChargingCurrent;
|
|
|
+
|
|
|
+ PRINTF_FUNC("Conn %d, EV Req Current : %.1f, EVSE Output Current = %.1f \n", groupIndex,
|
|
|
+ chargingOutputLogInfo[groupIndex][_CHARGING_LOG_NEED_CUR] / 10,
|
|
|
+ chargingOutputLogInfo[groupIndex][_CHARGING_LOG_OUTPUT_CUR]);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
//================================================
|
|
|
// Main process
|
|
|
//================================================
|
|
@@ -1143,12 +1189,15 @@ void InitialPsuData()
|
|
|
ShmPsuData->SystemPresentPsuQuantity = 0;
|
|
|
ShmPsuData->SystemAvailablePower = 0;
|
|
|
|
|
|
- PRINTF_FUNC("************ psu Group = %d \n", ShmPsuData->GroupCount);
|
|
|
+ PRINTF_FUNC("InitialPsuData : PSU Group = %d \n", ShmPsuData->GroupCount);
|
|
|
for (byte _groupCount = 0; _groupCount < ShmPsuData->GroupCount; _groupCount++)
|
|
|
{
|
|
|
ShmPsuData->PsuGroup[_groupCount].GroupPresentPsuQuantity = 0;
|
|
|
ShmPsuData->PsuGroup[_groupCount].GroupAvailablePower = 0;
|
|
|
ShmPsuData->PsuGroup[_groupCount].GroupAvailableCurrent = 0;
|
|
|
+
|
|
|
+ chargingInfo[_groupCount]->PresentChargingVoltage = 0;
|
|
|
+ chargingInfo[_groupCount]->PresentChargingCurrent = 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1174,6 +1223,9 @@ void Initialization()
|
|
|
ShmPsuData->GroupCount = 1;
|
|
|
else
|
|
|
ShmPsuData->GroupCount = _gunCount;
|
|
|
+
|
|
|
+ ShmPsuData->SystemAvailableCurrent = 0;
|
|
|
+ ShmPsuData->SystemAvailablePower = 0;
|
|
|
}
|
|
|
|
|
|
void CheckSmartChargingStep(bool isWaitingAver, bool isCharging, bool canAverageCharging)
|
|
@@ -1188,7 +1240,7 @@ void CheckSmartChargingStep(bool isWaitingAver, bool isCharging, bool canAverage
|
|
|
|
|
|
if (canAverageCharging)
|
|
|
{
|
|
|
- PRINTF_FUNC("=============Smart Charging : _REASSIGNED_GET_NEW_CAP============= Step 2 \n");
|
|
|
+ PRINTF_FUNC("======= Only to get the charging side capacity (Step 2) ======= \n");
|
|
|
ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_GET_NEW_CAP;
|
|
|
}
|
|
|
else
|
|
@@ -1210,20 +1262,20 @@ void CheckSmartChargingStep(bool isWaitingAver, bool isCharging, bool canAverage
|
|
|
{
|
|
|
if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_AVER)
|
|
|
{
|
|
|
- PRINTF_FUNC("=============Smart Charging : _REASSIGNED_ADJUST_A_TO_M============= Step 12 \n");
|
|
|
+ PRINTF_FUNC("======= To raise voltage of idle module to charing voltage (Step 12) ======= \n");
|
|
|
preChargingCur = preChargingTarget = 0;
|
|
|
gettimeofday(&_max_time, NULL);
|
|
|
ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_ADJUST_A_TO_M;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- PRINTF_FUNC("=============Smart Charging_1 : _REASSIGNED_COMP============= Step 15 \n");
|
|
|
+ PRINTF_FUNC("======= The Change to maximum charge mode is complete. (Step 15) ======= \n");
|
|
|
ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_COMP;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- PRINTF_FUNC("=============Smart Charging_2 : _REASSIGNED_COMP============= Step 15 \n");
|
|
|
+ PRINTF_FUNC("======= The Change to maximum charge mode is complete. (Step 15) ======= \n");
|
|
|
ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_COMP;
|
|
|
}
|
|
|
}
|
|
@@ -1336,9 +1388,12 @@ int main(void)
|
|
|
Initialization();
|
|
|
libInitialize = InitialCommunication();
|
|
|
byte isInitialComp = NO;
|
|
|
- PRINTF_FUNC("ALTERNATIVE_CONG = %d \n", ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf);
|
|
|
- //main loop
|
|
|
+ if (ShmSysConfigAndInfo->SysInfo.IsAlternatvieConf == YES)
|
|
|
+ {
|
|
|
+ PRINTF_FUNC("Alter native mode. \n");
|
|
|
+ }
|
|
|
|
|
|
+ //main loop
|
|
|
while (libInitialize)
|
|
|
{
|
|
|
// 斷電狀態
|
|
@@ -1401,13 +1456,12 @@ int main(void)
|
|
|
// 取各群模組數量
|
|
|
GetModuleCount(index);
|
|
|
}
|
|
|
- PRINTF_FUNC("== PSU == indexCount = %d, moduleCount = %d, sysCount = %d\n",
|
|
|
+ PRINTF_FUNC("== PSU == Connector Count = %d, moduleCount = %d, sysCount = %d\n",
|
|
|
ShmPsuData->GroupCount, moduleCount, ShmPsuData->SystemPresentPsuQuantity);
|
|
|
|
|
|
// 判斷系統數量與各群數量一致
|
|
|
if(moduleCount == ShmPsuData->SystemPresentPsuQuantity && moduleCount > 0)
|
|
|
{
|
|
|
- PRINTF_FUNC("Psu Count = %d \n", moduleCount);
|
|
|
if (ShmSysConfigAndInfo->SysInfo.BootingStatus == BOOTTING)
|
|
|
{
|
|
|
// 電樁在 Booting 的狀態 - 自檢
|
|
@@ -1418,8 +1472,6 @@ int main(void)
|
|
|
{
|
|
|
PRINTF_FUNC("== PSU == _WORK_CHARGING \n");
|
|
|
ShmPsuData->Work_Step = _WORK_CHARGING;
|
|
|
-
|
|
|
- gettimeofday(&_test_time, NULL);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1483,6 +1535,7 @@ int main(void)
|
|
|
}
|
|
|
|
|
|
gettimeofday(&_cmdSubPriority_time, NULL);
|
|
|
+ gettimeofday(&_log_time, NULL);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -1555,22 +1608,10 @@ int main(void)
|
|
|
(chargingInfo[groupIndex]->SystemStatus >= S_PREPARING_FOR_EVSE && chargingInfo[groupIndex]->SystemStatus <= S_CHARGING && chargingInfo[groupIndex]->Type == _Type_GB) ||
|
|
|
(chargingInfo[groupIndex]->SystemStatus >= S_CCS_PRECHARGE_ST0 && chargingInfo[groupIndex]->SystemStatus <= S_CCS_PRECHARGE_ST1))
|
|
|
{
|
|
|
- if (chargingInfo[groupIndex]->FireChargingVoltage > 0 &&
|
|
|
- evseOutVol != (chargingInfo[groupIndex]->FireChargingVoltage / 10))
|
|
|
- {
|
|
|
- evseOutVol = (chargingInfo[groupIndex]->FireChargingVoltage / 10);
|
|
|
- PRINTF_FUNC("groupIndex = %d, ev need vol = %f, evse output vol = %f \n", groupIndex,
|
|
|
- (chargingInfo[groupIndex]->EvBatterytargetVoltage * 10),
|
|
|
- chargingInfo[groupIndex]->FireChargingVoltage);
|
|
|
- }
|
|
|
-
|
|
|
- if ((chargingInfo[groupIndex]->PresentChargingCurrent * 10) > 0 &&
|
|
|
- evseOutCur != (chargingInfo[groupIndex]->PresentChargingCurrent * 10))
|
|
|
+ if (GetTimeoutValue(_log_time) / 1000 > 1000)
|
|
|
{
|
|
|
- evseOutCur = (chargingInfo[groupIndex]->PresentChargingCurrent * 10);
|
|
|
- PRINTF_FUNC("groupIndex = %d, ev need cur = %f, evse output cur = %f \n", groupIndex,
|
|
|
- (chargingInfo[groupIndex]->EvBatterytargetCurrent * 10),
|
|
|
- (chargingInfo[groupIndex]->PresentChargingCurrent * 10));
|
|
|
+ OutputChargingLogFuncion(groupIndex);
|
|
|
+ gettimeofday(&_log_time, NULL);
|
|
|
}
|
|
|
|
|
|
if (ShmSysConfigAndInfo->SysInfo.MainChargingMode == _MAIN_CHARGING_MODE_MAX)
|
|
@@ -1608,7 +1649,7 @@ int main(void)
|
|
|
{
|
|
|
// 車端降載完成
|
|
|
PRINTF_FUNC("Index = %d, newEvCurrent = %f \n", groupIndex, (chargingInfo[groupIndex]->EvBatterytargetCurrent * 10));
|
|
|
- PRINTF_FUNC("=============Smart Charging : _REASSIGNED_ADJUST_M_TO_A============= Step 3 \n");
|
|
|
+ PRINTF_FUNC("======= Get the charging current req of EV and shutdown the module of stop side (Step 3) ======= \n");
|
|
|
ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_ADJUST_M_TO_A;
|
|
|
gettimeofday(&_derating_time, NULL);
|
|
|
deratingKeepCount = 0;
|
|
@@ -1616,7 +1657,7 @@ int main(void)
|
|
|
else
|
|
|
{
|
|
|
deratingKeepCount++;
|
|
|
- PRINTF_FUNC("** Step 2 ** : Index = %d, EvBatterytargetCurrent = %f, TargetCurrent = %d, Count = %d \n",
|
|
|
+ PRINTF_FUNC("Max To Ava mode (2) : Index = %d, EvBatterytargetCurrent = %f, TargetCurrent = %d, Count = %d \n",
|
|
|
groupIndex,
|
|
|
(chargingInfo[groupIndex]->EvBatterytargetCurrent * 10),
|
|
|
(ShmPsuData->PsuGroup[groupIndex].GroupPresentOutputCurrent + DERATING_GAP),
|
|
@@ -1630,7 +1671,7 @@ int main(void)
|
|
|
|
|
|
if (chargingInfo[groupIndex]->AvailableChargingCurrent <= (chargingInfo[groupIndex]->EvBatterytargetCurrent * 10))
|
|
|
{
|
|
|
- PRINTF_FUNC("** _REASSIGNED_ADJUST_M_TO_A ** Gun_%d, PresentChargingCurrent = %f, AvailableChargingCurrent = %f, EvBatterytargetCurrent = %f \n", groupIndex,
|
|
|
+ PRINTF_FUNC("Max To Ava mode (3-1) : Gun_%d, PresentChargingCurrent = %f, AvailableChargingCurrent = %f, EvBatterytargetCurrent = %f \n", groupIndex,
|
|
|
(chargingInfo[groupIndex]->PresentChargingCurrent * 10),
|
|
|
chargingInfo[groupIndex]->AvailableChargingCurrent,
|
|
|
(chargingInfo[groupIndex]->EvBatterytargetCurrent * 10));
|
|
@@ -1662,13 +1703,13 @@ int main(void)
|
|
|
|
|
|
if (isChanged)
|
|
|
{
|
|
|
- PRINTF_FUNC("** _REASSIGNED_ADJUST_M_TO_A To 4** Gun_%d, PresentChargingCurrent = %f, GroupPresentOutputCurrent = %d \n", groupIndex,
|
|
|
+ PRINTF_FUNC("Max To Ava mode (3-2) : Gun_%d, PresentChargingCurrent = %f, GroupPresentOutputCurrent = %d \n", groupIndex,
|
|
|
(chargingInfo[groupIndex]->PresentChargingCurrent * 10),
|
|
|
ShmPsuData->PsuGroup[groupIndex].GroupPresentOutputCurrent);
|
|
|
|
|
|
// 輸出端與車端要求電流接近
|
|
|
- PRINTF_FUNC("=============Smart Charging : _REASSIGNED_RELAY_M_TO_A============= Step 4 \n");
|
|
|
- ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_RELAY_M_TO_A;
|
|
|
+ PRINTF_FUNC("======= disable the Parallel relay (Step 4) ======= \n");
|
|
|
+ ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_RELAY_M_TO_A;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -1820,7 +1861,7 @@ int main(void)
|
|
|
if (((chargingInfo[subIndex]->PresentChargingVoltage * 10) < (chargingInfo[groupIndex]->PresentChargingVoltage * 10) - ZERO_VOLTAGE) ||
|
|
|
((chargingInfo[subIndex]->PresentChargingVoltage * 10) < (chargingInfo[groupIndex]->EvBatterytargetVoltage * 10) - CHK_VOL_RANGE))
|
|
|
{
|
|
|
- PRINTF_FUNC("** _REASSIGNED_ADJUST_A_TO_M ** Gun_%d, PresentChargingVoltage = %f, PresentChargingVoltage_V = %f, EvBatterytargetVoltage = %f \n", subIndex,
|
|
|
+ PRINTF_FUNC("Ava To Max mode (12) : Gun_%d, PresentChargingVoltage = %f, PresentChargingVoltage_V = %f, EvBatterytargetVoltage = %f \n", subIndex,
|
|
|
(chargingInfo[subIndex]->PresentChargingVoltage * 10),
|
|
|
((chargingInfo[groupIndex]->PresentChargingVoltage * 10) - ZERO_VOLTAGE),
|
|
|
((chargingInfo[groupIndex]->EvBatterytargetVoltage * 10) - CHK_VOL_RANGE));
|
|
@@ -1833,7 +1874,7 @@ int main(void)
|
|
|
if (balanceVol)
|
|
|
{
|
|
|
// 閒置端與車端要求電壓接近
|
|
|
- PRINTF_FUNC("=============Smart Charging : _REASSIGNED_RELAY_A_TO_M============= Step 13 \n");
|
|
|
+ PRINTF_FUNC("======= Enable the Parallel relay (Step 13) ======= \n");
|
|
|
ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_RELAY_A_TO_M;
|
|
|
}
|
|
|
else
|
|
@@ -1861,7 +1902,7 @@ int main(void)
|
|
|
|
|
|
if (idleCurrent >= chargingCurrent - PRE_CHARG_RANGE)
|
|
|
{
|
|
|
- PRINTF_FUNC("=============Smart Charging_0 : _REASSIGNED_COMP============= Step 15 \n");
|
|
|
+ PRINTF_FUNC("======= The Change to maximum charge mode is complete. (Step 15) ======= \n");
|
|
|
ShmSysConfigAndInfo->SysInfo.ReAssignedFlag = _REASSIGNED_COMP;
|
|
|
}
|
|
|
else
|