Added shutdown when inverter error

This commit is contained in:
Matthias Heisig
2024-09-06 18:47:03 +02:00
parent 3d041c50c4
commit d9f39953a0
6 changed files with 144 additions and 73 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4026.8">
<POU Name="FB_Safety" Id="{f74eb8e4-e878-485f-9706-8dd039061a6b}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FB_Safety
VAR_INPUT

View File

@@ -473,6 +473,7 @@ CASE _iState OF
// Start in normal mode
IF xEnable AND (NOT xStartBalancing) AND xAllModulesInAutoMode AND xRepairSwitchOk THEN
_xEnable := TRUE;
eStatus := E_COMPONENT_STATUS.STARTING;
_iState := 5;
END_IF
@@ -480,6 +481,7 @@ CASE _iState OF
IF (NOT xEnable) AND xStartBalancing AND xAllModulesInAutoMode THEN
_xStartBalancing := TRUE;
_xReleaseLimitErrorsInternal := FALSE;
eStatus := E_COMPONENT_STATUS.STARTING;
_iState := 7;
END_IF
@@ -495,6 +497,7 @@ CASE _iState OF
IF (NOT xEnable) THEN
_xEnable := FALSE;
eStatus := E_COMPONENT_STATUS.OFF;
_iState := 0;
END_IF
@@ -510,6 +513,7 @@ CASE _iState OF
IF (NOT xStartBalancing) THEN
_xStartBalancing := FALSE;
eStatus := E_COMPONENT_STATUS.OFF;
_iState := 0;
END_IF
@@ -538,6 +542,7 @@ CASE _iState OF
IF NOT xEnable THEN
_tonSafetyOkTimeout.IN := FALSE;
_xEnable := FALSE;
eStatus := E_COMPONENT_STATUS.SHUTDOWN;
_iState := 40;
END_IF
@@ -569,6 +574,7 @@ CASE _iState OF
IF NOT xEnable THEN
_tonSafetyOkTimeout.IN := FALSE;
_xEnable := FALSE;
eStatus := E_COMPONENT_STATUS.SHUTDOWN;
_iState := 40;
END_IF
@@ -576,6 +582,7 @@ CASE _iState OF
_tonInverterStartupTimeout(IN := TRUE);
IF _fbInverter.xActive AND (NOT _fbInverter.xError) THEN
_iState := 30;
eStatus := E_COMPONENT_STATUS.ON;
xReady := TRUE;
_tonInverterStartupTimeout(IN := FALSE);
END_IF
@@ -584,6 +591,7 @@ CASE _iState OF
_xEnableInverter := FALSE;
_rPowerInverterInternal := 0.0;
_xEnable := FALSE;
eStatus := E_COMPONENT_STATUS.SHUTDOWN;
_iState := 31;
_tonInverterStartupTimeout(IN := FALSE);
END_IF
@@ -627,14 +635,16 @@ CASE _iState OF
_xReleaseLimitErrorsInternal := FALSE;
IF GVL_CONFIG.xShutdownDischargeWithInverter THEN
_rPowerInverterInternal := GVL_CONFIG.rAbsShutdownDischargePower;
eStatus := E_COMPONENT_STATUS.SHUTDOWN;
_iState := 31;
ELSE
_rPowerInverterInternal := 0.0;
_xEnableInverter := FALSE;
eStatus := E_COMPONENT_STATUS.SHUTDOWN;
_iState := 40;
END_IF
ELSIF (NOT _xAllModulesReady) OR (NOT _xBalanceOk) OR (NOT xSafetyIntlksOk) OR (NOT xRepairSwitchOk) THEN
ELSIF (NOT _xAllModulesReady) OR (NOT _xBalanceOk) OR (NOT xSafetyIntlksOk) OR (NOT xRepairSwitchOk) OR (_fbInverter.xError) THEN
xError := TRUE;
_xReleaseLimitErrorsInternal := FALSE;
_xEnable := FALSE;
@@ -690,6 +700,7 @@ CASE _iState OF
IF _tonInverterShutdownDelay.Q THEN
_tonInverterShutdownDelay(IN := FALSE);
xCloseDCCB := FALSE;
eStatus := E_COMPONENT_STATUS.OFF;
_iState := 0;
END_IF
@@ -701,6 +712,7 @@ CASE _iState OF
51: // Check if start balancing has been releases to avoid a restart
IF (NOT xStartBalancing) THEN
eStatus := E_COMPONENT_STATUS.OFF;
_iState := 0;
END_IF
@@ -716,6 +728,8 @@ CASE _iState OF
_tonResetPulseLength(IN := FALSE);
_tonErrorDCCBNotClosed(IN := FALSE);
eStatus := E_COMPONENT_STATUS.ERROR;
_iState := 1005;
1005: // Wait for inverter to be off
@@ -734,6 +748,7 @@ CASE _iState OF
// Leave error state only if modules are deactivated
IF (NOT xEnable) AND (NOT _xModuleError) THEN
xError := FALSE;
eStatus := E_COMPONENT_STATUS.OFF;
_iState := 0;
END_IF
END_CASE
@@ -750,21 +765,6 @@ END_IF
// Reset inverter startup timeout alarm
IF _fbInverterStartupTimeoutAlarm.bRaised AND xConfirmAlarms THEN
_fbInverterStartupTimeoutAlarm.Clear(0, TRUE);
END_IF
// ===============================
// String status sum
// ===============================
IF xOff THEN
eStatus := E_COMPONENT_STATUS.OFF;
END_IF
IF xReady THEN
eStatus := E_COMPONENT_STATUS.ON;
END_IF
IF xError THEN
eStatus := E_COMPONENT_STATUS.ERROR;
END_IF]]></ST>
</Implementation>
<Method Name="FB_init" Id="{9e8494eb-1b40-4be9-91c8-810ecbdf7f0c}">
@@ -858,9 +858,25 @@ _fbSafetyInterlocksNotOkAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
<LineId Id="611" Count="0" />
<LineId Id="610" Count="0" />
<LineId Id="612" Count="1" />
<LineId Id="11" Count="326" />
<LineId Id="11" Count="248" />
<LineId Id="623" Count="0" />
<LineId Id="260" Count="6" />
<LineId Id="624" Count="0" />
<LineId Id="267" Count="14" />
<LineId Id="630" Count="0" />
<LineId Id="282" Count="14" />
<LineId Id="629" Count="0" />
<LineId Id="297" Count="27" />
<LineId Id="628" Count="0" />
<LineId Id="325" Count="12" />
<LineId Id="597" Count="0" />
<LineId Id="338" Count="32" />
<LineId Id="338" Count="16" />
<LineId Id="627" Count="0" />
<LineId Id="355" Count="6" />
<LineId Id="625" Count="0" />
<LineId Id="362" Count="7" />
<LineId Id="626" Count="0" />
<LineId Id="370" Count="0" />
<LineId Id="578" Count="0" />
<LineId Id="371" Count="0" />
<LineId Id="582" Count="0" />
@@ -869,8 +885,19 @@ _fbSafetyInterlocksNotOkAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
<LineId Id="587" Count="2" />
<LineId Id="377" Count="0" />
<LineId Id="596" Count="0" />
<LineId Id="378" Count="167" />
<LineId Id="2" Count="0" />
<LineId Id="378" Count="29" />
<LineId Id="631" Count="0" />
<LineId Id="408" Count="3" />
<LineId Id="632" Count="0" />
<LineId Id="412" Count="58" />
<LineId Id="633" Count="0" />
<LineId Id="471" Count="10" />
<LineId Id="634" Count="0" />
<LineId Id="482" Count="13" />
<LineId Id="635" Count="1" />
<LineId Id="496" Count="18" />
<LineId Id="637" Count="0" />
<LineId Id="515" Count="16" />
</LineIds>
<LineIds Name="FB_String.FB_init">
<LineId Id="3" Count="21" />

View File

@@ -775,6 +775,7 @@ _fbNotAllAutomaticAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
// ===============================
CASE _iState OF
0: // Off
// Start in enable
IF xEnable AND (NOT xStartBalancing) AND _xAllComponentsInAutomatic AND (NOT _xErrorActive) THEN
_xReleaseManualMode := FALSE;
_timUnitStartupWaitTime := GVL_CONFIG.timUnitStartupTime;
@@ -782,6 +783,7 @@ CASE _iState OF
eUnitState := E_COMPONENT_STATUS.STARTING;
END_IF
// Start in balancing mode
IF (NOT xEnable) AND xStartBalancing AND _xAllComponentsInAutomatic AND (NOT _xErrorActive) THEN
_xReleaseManualMode := FALSE;
xBalancingDone := FALSE;
@@ -802,8 +804,14 @@ CASE _iState OF
END_IF
END_IF
// If enable signal is lost
IF ((NOT xEnable) AND (NOT xStartBalancing)) THEN
eUnitState := E_COMPONENT_STATUS.SHUTDOWN;
_iState := 40;
END_IF
// If enable signal is lost, or there is an error, goto shutdown
IF ((NOT xEnable) AND (NOT xStartBalancing)) OR _xErrorActive THEN
IF _xErrorActive THEN
_xReleaseManualMode := TRUE;
_iState := 1000;
END_IF
@@ -824,6 +832,7 @@ CASE _iState OF
// If enable signal is lost, goto shutdown
IF ((NOT xEnable) AND (NOT xStartBalancing)) THEN
eUnitState := E_COMPONENT_STATUS.SHUTDOWN;
_iState := 40; // 40
END_IF
@@ -847,6 +856,7 @@ CASE _iState OF
// If enable signal is lost, goto shutdown
IF (NOT xEnable) AND (NOT xStartBalancing) THEN
eUnitState := E_COMPONENT_STATUS.SHUTDOWN;
_iState := 40;
END_IF
@@ -1110,9 +1120,23 @@ END_CASE]]></ST>
<LineId Id="2" Count="0" />
</LineIds>
<LineIds Name="FB_Unit.StateMachine">
<LineId Id="2" Count="8" />
<LineId Id="2" Count="4" />
<LineId Id="332" Count="0" />
<LineId Id="7" Count="3" />
<LineId Id="317" Count="0" />
<LineId Id="11" Count="88" />
<LineId Id="11" Count="1" />
<LineId Id="333" Count="0" />
<LineId Id="13" Count="19" />
<LineId Id="326" Count="0" />
<LineId Id="328" Count="1" />
<LineId Id="331" Count="0" />
<LineId Id="330" Count="0" />
<LineId Id="327" Count="0" />
<LineId Id="33" Count="21" />
<LineId Id="325" Count="0" />
<LineId Id="55" Count="22" />
<LineId Id="324" Count="0" />
<LineId Id="78" Count="21" />
<LineId Id="318" Count="0" />
<LineId Id="100" Count="20" />
<LineId Id="319" Count="0" />

View File

@@ -175,6 +175,9 @@ IF _xFirstCycle THEN
_stECString2ErrSI.sName := 'MAIN';
_fbEtherCATErrorString2.CreateEx(stEventEntry := TC_EVENTS.BMSEvents.EthercatStringError, TRUE, _stECString2ErrSI);
_fbEtherCATErrorString2.ipArguments.Clear().AddString('2');
_afbStrings[0].Name := 'String 1';
_afbStrings[1].Name := 'String 2';
END_IF
// Reset error flag
@@ -845,7 +848,9 @@ END_CASE]]></ST>
</Implementation>
</Action>
<LineIds Name="MAIN">
<LineId Id="3" Count="117" />
<LineId Id="3" Count="32" />
<LineId Id="345" Count="2" />
<LineId Id="36" Count="84" />
<LineId Id="122" Count="8" />
<LineId Id="132" Count="212" />
<LineId Id="2" Count="0" />