Added precharge mode

This commit is contained in:
Matthias Heisig
2025-06-04 19:37:25 +02:00
parent f12063e294
commit 38f44128d1
9 changed files with 451 additions and 277 deletions

View File

@@ -28,10 +28,14 @@ VAR
_iState : INT;
_iStateSafetyCheck : INT;
_iStateBalancing : INT;
_iStatePrecharge : INT;
// Start safety check mode
_xStartSafetyCheck : BOOL;
// Start precharge mode
_xStartPrecharge : BOOL;
// Auto remote and auto local power request
_rAutoPowerRequest : REAL;
@@ -144,6 +148,8 @@ VAR
_xStringsBalancingDone : BOOL;
_xStringsInAutoMode : BOOL;
_eStringOpMode : E_STRING_OPERATING_MODE;
_rMaxCurrentInverterDCVoltage : REAL;
_rMinCurrentInverterDCVoltage : REAL;
@@ -314,6 +320,7 @@ _tonStartupDelay(IN := TRUE);
_afbStrings[0](
xEnable := _xEnableString AND GVL_CONFIG.axStringEnabled[0],
uiStringNumber := 0,
eOperationMode := _eStringOpMode,
xErrorShutdown := _xErrorShutdown,
xStartBalancing := _xStartBalancing,
sInverterIP := GVL_CONFIG.sInverterIpString1,
@@ -343,6 +350,7 @@ GVL_MODBUS.stBMSErrorReg.wBMSWarningActive.stBitmap.bSafetyIntlkString1 := (NOT
_afbStrings[1](
xEnable := _xEnableString AND GVL_CONFIG.axStringEnabled[1],
uiStringNumber := 1,
eOperationMode := _eStringOpMode,
xErrorShutdown := _xErrorShutdown,
xStartBalancing := _xStartBalancing,
sInverterIP := GVL_CONFIG.sInverterIpString2,
@@ -549,6 +557,7 @@ GVL_MODBUS.stModbusEMSComm.stModbusReg11.rSetpointCosPhiMirror := GVL_MODBUS.stM
// ===============================
CASE _eBMSControlMode OF
E_BMS_CONTROL_MODE.AUTO_REMOTE:
_eStringOpMode := E_STRING_OPERATING_MODE.AUTOMATIC;
_xAllComponentsToManualMode := FALSE;
_xInSafetyCheckMode := FALSE;
_xReleaseManualMode := FALSE;
@@ -559,6 +568,7 @@ CASE _eBMSControlMode OF
SM_AUTO();
E_BMS_CONTROL_MODE.AUTO_LOCAL:
_eStringOpMode := E_STRING_OPERATING_MODE.AUTOMATIC;
_xAllComponentsToManualMode := FALSE;
_xInSafetyCheckMode := FALSE;
_xReleaseManualMode := FALSE;
@@ -570,6 +580,7 @@ CASE _eBMSControlMode OF
SM_AUTO();
E_BMS_CONTROL_MODE.MANUAL:
_eStringOpMode := E_STRING_OPERATING_MODE.AUTOMATIC;
_xAllComponentsToManualMode := TRUE;
_xInSafetyCheckMode := FALSE;
_xReleaseManualMode := TRUE;
@@ -580,6 +591,7 @@ CASE _eBMSControlMode OF
SM_MANUAL();
E_BMS_CONTROL_MODE.SAFETY_CHECK:
_eStringOpMode := E_STRING_OPERATING_MODE.SAFETY_CHECK;
_xAllComponentsToManualMode := FALSE;
_xInSafetyCheckMode := TRUE;
_xReleaseManualMode := FALSE;
@@ -590,6 +602,7 @@ CASE _eBMSControlMode OF
SM_SAFETY_CHECK();
E_BMS_CONTROL_MODE.CAPACITY_TEST:
_eStringOpMode := E_STRING_OPERATING_MODE.AUTOMATIC;
_xAllComponentsToManualMode := FALSE;
_xInSafetyCheckMode := FALSE;
_xReleaseManualMode := FALSE;
@@ -600,6 +613,7 @@ CASE _eBMSControlMode OF
SM_CAPACITY_TEST();
E_BMS_CONTROL_MODE.BALANCING:
_eStringOpMode := E_STRING_OPERATING_MODE.BALANCING;
_xAllComponentsToManualMode := FALSE;
_xInSafetyCheckMode := FALSE;
_xReleaseManualMode := FALSE;
@@ -610,6 +624,7 @@ CASE _eBMSControlMode OF
SM_BALANCING();
E_BMS_CONTROL_MODE.CYCLING:
_eStringOpMode := E_STRING_OPERATING_MODE.AUTOMATIC;
_xAllComponentsToManualMode := FALSE;
_xInSafetyCheckMode := FALSE;
_xReleaseManualMode := FALSE;
@@ -621,6 +636,17 @@ CASE _eBMSControlMode OF
END_IF
SM_AUTO();
GVL_SCADA.stAutomaticModeHMI.diSetpointAutomatic := REAL_TO_DINT(_rAutoPowerRequest);
E_BMS_CONTROL_MODE.PRECHARGE:
_eStringOpMode := E_STRING_OPERATING_MODE.PRECHARGE;
_xAllComponentsToManualMode := FALSE;
_xInSafetyCheckMode := FALSE;
_xReleaseManualMode := FALSE;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eBatteryStatus := E_BATTERY_STATUS.MAINTENANCE;
IF (GVL_SCADA.eRequestedControlMode <> _eBMSControlMode) AND (GVL_SCADA.xCanChangeControlMode) THEN
_eBMSControlMode := GVL_SCADA.eRequestedControlMode;
END_IF
SM_PRECHARGE();
END_CASE
GVL_SCADA.xCanChangeControlMode := _xCanChangeMode;
@@ -1045,7 +1071,95 @@ END_CASE]]></ST>
</Action>
<Action Name="SM_PRECHARGE" Id="{b84aedc8-0039-40a2-8abe-a166eca7bebc}">
<Implementation>
<ST><![CDATA[]]></ST>
<ST><![CDATA[// Start on start button pressed
IF GVL_SCADA.stAutomaticModeHMI.stStartAutoButton.xRequest THEN
// Only start if everything is ok
IF _xStringsAllInAutomaticMode AND (NOT _xStringsErrorActive) THEN
_xStartPrecharge := TRUE;
END_IF
END_IF
// Sto pif stop button pressed
IF GVL_SCADA.stAutomaticModeHMI.stStopAutoButton.xRequest THEN
_xStartPrecharge := FALSE;
END_IF
// State machine
CASE _iStatePrecharge OF
0: // Idle
// Wait for start command
IF _xStartPrecharge AND _xStringsAllInAutomaticMode THEN
_xEnableString := TRUE;
_iStatePrecharge := 10;
_rPowerInverter := 0.0;
_xCanChangeMode := FALSE;
END_IF
10: // Wait for string to be ready
IF _xStringsReady AND (NOT _xStringsErrorActive) THEN
_iStatePrecharge := 30;
END_IF
// Shutdown
IF NOT _xStartPrecharge THEN
_xEnableString := FALSE;
_iStatePrecharge := 0;
_xCanChangeMode := TRUE;
END_IF
// Check for errors
IF _xStringsErrorActive THEN
_iStatePrecharge := 1000;
END_IF
30: // String enabled and dc circuit breaker closed
// Check if the battery should still be active
IF (NOT _xStartPrecharge) THEN
// Start string shutdown
_xEnableString := FALSE;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus := E_CHARGE_STATUS.UNDEFINED;
GVL_MODBUS.stModbusEMSComm.stModbusReg10.uiActiveParallelMembers := 0;
_iStatePrecharge := 45;
_xCanChangeMode := TRUE;
END_IF
// Check for errors
IF _xStringsErrorActive THEN
_xEnableString := FALSE;
_iStatePrecharge := 1000;
END_IF
45: // Wait for shutdown of string to be done
IF _xStringsOff THEN
_iStatePrecharge := 0;
END_IF
IF _xStartPrecharge THEN
_iStatePrecharge := 0;
END_IF
// Check for errors
IF _xStringsErrorActive THEN
_xEnableString := FALSE;
_iStatePrecharge := 1000;
END_IF
1000: // Error state
_xEnableString := FALSE;
_rPowerInverter := 0.0;
_xCanChangeMode := TRUE;
_xStartPrecharge := FALSE;
_iStatePrecharge := 1010;
1010: // Wait for reset from error state
IF (NOT _xStringsErrorActive) AND (NOT _xStartPrecharge) THEN
// Goto init state
_iStatePrecharge := 0;
_xCanChangeMode := TRUE;
END_IF
END_CASE]]></ST>
</Implementation>
</Action>
<Action Name="SM_SAFETY_CHECK" Id="{6d8e5993-cf32-4980-9ea3-c1fbfa4b8601}">