Bläddra i källkod

2022-01-26 / Eason Yang
Action
1. Improve : PresentChargingPower smaller and equal than 1.0, present power = 0.
2. Improve : checkChargingProfileLimit() function for ccs . block 1A~5A.

File
1. main.c

FIRMWARE VERSION: B0.61.XX.XXXX.PX

8009 3 år sedan
förälder
incheckning
95cf87bed8
1 ändrade filer med 49 tillägg och 6 borttagningar
  1. 49 6
      EVSE/Projects/AW-CCS/Apps/main.c

+ 49 - 6
EVSE/Projects/AW-CCS/Apps/main.c

@@ -4248,6 +4248,12 @@ void checkAvailability(uint8_t gun_index)
 
 void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
 {
+	static struct PreviousData
+	{
+		uint16_t targetCurrent;
+		uint16_t current_limit;
+	}previousData[3];
+
 	if(ShmSysConfigAndInfo->SysInfo.OcppRunningVer == OCPP_RUNNING_VERSION_16)
 	{
 		if((ocpp_get_smartcharging_profileId(gun_index) > 0) &&
@@ -4417,7 +4423,11 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
 					}
 					else if(ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC)
 					{
-						ShmCharger->gun_info[gun_index].acCcsInfo.EVSEMaxCurrent = (float)((ShmCharger->gun_info[gun_index].targetCurrent > ShmCharger->gun_info[gun_index].primaryMcuState.rating_current)?ShmCharger->gun_info[gun_index].primaryMcuState.rating_current:ShmCharger->gun_info[gun_index].targetCurrent);
+						ShmCharger->gun_info[gun_index].targetCurrent = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmCharger->gun_info[gun_index].primaryMcuState.rating_current)?ShmCharger->gun_info[gun_index].primaryMcuState.rating_current:ShmCharger->gun_info[gun_index].targetCurrent);
+						ShmCharger->gun_info[gun_index].targetCurrent = ((1 <= ShmCharger->gun_info[gun_index].targetCurrent) && (ShmCharger->gun_info[gun_index].targetCurrent <= 5)?6:ShmCharger->gun_info[gun_index].targetCurrent);
+						ShmCharger->gun_info[gun_index].acCcsInfo.EVSEMaxCurrent = (float)ShmCharger->gun_info[gun_index].targetCurrent;
+
+						//ShmCharger->gun_info[gun_index].acCcsInfo.EVSEMaxCurrent = (float)((ShmCharger->gun_info[gun_index].targetCurrent > ShmCharger->gun_info[gun_index].primaryMcuState.rating_current)?ShmCharger->gun_info[gun_index].primaryMcuState.rating_current:ShmCharger->gun_info[gun_index].targetCurrent);
 					}
 				}
 			}
@@ -4439,11 +4449,28 @@ void checkChargingProfileLimit(uint8_t gun_index, uint8_t system_mode)
 					}
 					else if(ShmCharger->gun_info[gun_index].chargingMode == CHARGING_MODE_HLC)
 					{
-						ShmCharger->gun_info[gun_index].acCcsInfo.EVSEMaxCurrent = (float)((ShmCharger->gun_info[gun_index].targetCurrent > ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent)?ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent:ShmCharger->gun_info[gun_index].targetCurrent);
+						ShmCharger->gun_info[gun_index].targetCurrent = ((ShmCharger->gun_info[gun_index].targetCurrent > ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent)?ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent:ShmCharger->gun_info[gun_index].targetCurrent);
+						ShmCharger->gun_info[gun_index].targetCurrent = ((1 <= ShmCharger->gun_info[gun_index].targetCurrent) && (ShmCharger->gun_info[gun_index].targetCurrent <= 5)?6:ShmCharger->gun_info[gun_index].targetCurrent);
+						ShmCharger->gun_info[gun_index].acCcsInfo.EVSEMaxCurrent = (float)ShmCharger->gun_info[gun_index].targetCurrent;
+
+						//ShmCharger->gun_info[gun_index].acCcsInfo.EVSEMaxCurrent = (float)((ShmCharger->gun_info[gun_index].targetCurrent > ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent)?ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent:ShmCharger->gun_info[gun_index].targetCurrent);
 					}
 				}
 			}
 
+			if(ShmCharger->gun_info[gun_index].targetCurrent != previousData[gun_index].targetCurrent)
+			{
+				DEBUG_INFO("SysConfig.MaxChargingCurrent: %d\n", ShmSysConfigAndInfo->SysConfig.MaxChargingCurrent);
+				DEBUG_INFO("gun-%02d target current: %d\n", gun_index, ShmCharger->gun_info[gun_index].targetCurrent);
+				previousData[gun_index].targetCurrent = ShmCharger->gun_info[gun_index].targetCurrent;
+			}
+
+			if(ShmCharger->gun_info[gun_index].primaryMcuState.current_limit != previousData[gun_index].current_limit)
+			{
+				DEBUG_INFO("gun-%02d mcu current_limit: %d\n", gun_index, ShmCharger->gun_info[gun_index].primaryMcuState.current_limit);
+				previousData[gun_index].current_limit = ShmCharger->gun_info[gun_index].primaryMcuState.current_limit;
+			}
+
 			break;
 	}
 }
@@ -5183,7 +5210,16 @@ int main(void)
 			if(ShmSysConfigAndInfo->SysConfig.AcPhaseCount == 1)
 			{
 				if(ShmCharger->gun_info[gun_index].primaryMcuState.relay_state == ON)
-					ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingPower = (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingVoltage*ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingCurrent)/1000;
+				{
+					if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingPower > 1.0)
+					{
+						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingPower = (ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingVoltage*ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingCurrent)/1000;
+					}
+					else
+					{
+						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingPower = 0;
+					}
+				}
 				else
 					ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingPower = 0;
 			}
@@ -5191,9 +5227,16 @@ int main(void)
 			{
 				if(ShmCharger->gun_info[gun_index].primaryMcuState.relay_state == ON)
 				{
-					ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingPower = (((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingVoltage*ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingCurrent)/1000) +
-																								   ((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingVoltageL2*ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingCurrentL2)/1000) +
-																								   ((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingVoltageL3*ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingCurrentL3)/1000));
+					if(ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingPower > 1.0)
+					{
+						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingPower = (((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingVoltage*ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingCurrent)/1000) +
+																									   ((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingVoltageL2*ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingCurrentL2)/1000) +
+																									   ((ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingVoltageL3*ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingCurrentL3)/1000));
+					}
+					else
+					{
+						ShmSysConfigAndInfo->SysInfo.AcChargingData[gun_index].PresentChargingPower = 0;
+					}
 				}
 				else
 				{