- Added new module status

- Added error messages for EtherCAT connection lost
This commit is contained in:
Matthias Heisig
2024-09-05 18:32:49 +02:00
parent 5e94ba4868
commit 3d041c50c4
8 changed files with 607 additions and 318 deletions

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4026.7">
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4026.8">
<POU Name="FB_Module" Id="{87be924f-018d-4c09-997b-f0c0054414cc}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FB_Module
VAR_INPUT
@@ -56,6 +56,8 @@ VAR_INPUT
// Leakage tank
xLeakageTank AT %I* : BOOL;
xECState AT %I* : UINT;
END_VAR
VAR_OUTPUT
// Module voltage
@@ -103,6 +105,9 @@ VAR
// Units out of balance alarm
_fbUnitsOutOfBalanceAlarm : FB_TcAlarm;
// Connection lost alarm
_fbConnLostAlarm : FB_TcAlarm;
// Enable balance check
_xEnableBalanceCheck : BOOL;
@@ -115,6 +120,8 @@ VAR
_fbBalanceNotOkSignal : FB_ReleaseSignal;
_xECModuleInOP : BOOL;
xDebug1 : BOOL;
xDebug2 : BOOL;
xDebug3 : BOOL;
@@ -132,6 +139,22 @@ xAllUnitsInAutomatic := TRUE;
// Reset safety interlocks flag
xSafetyIntlksOk := TRUE;
// ===============================
// Handle module connection lost error
// ===============================
_xECModuleInOP := (xECState AND 16#000F) = 8;
IF (NOT _xECModuleInOP) AND (NOT _fbConnLostAlarm.bRaised) AND xReleaseErrors THEN
_fbConnLostAlarm.Raise(0);
END_IF
IF (_xECModuleInOP) AND _fbConnLostAlarm.bRaised THEN
_fbConnLostAlarm.Clear(0, FALSE);
END_IF
IF _fbConnLostAlarm.eConfirmationState = TcEventConfirmationState.WaitForConfirmation AND xConfirmAlarms THEN
_fbConnLostAlarm.Confirm(0);
END_IF
// ===============================
// Unit 1
@@ -407,17 +430,26 @@ rHighestSegmentVoltage := MAX(_fbUnit1.rCurrentVoltage, _fbUnit2.rCurrentVoltage
// ===============================
// Module status sum
// ===============================
IF xOff THEN
stHMIInterface.eStatus := E_COMPONENT_STATUS.OFF;
IF xReady AND (NOT xError) THEN
stHMIInterface.eStatus := E_COMPONENT_STATUS.ON;
END_IF
IF xReady THEN
stHMIInterface.eStatus := E_COMPONENT_STATUS.ON;
IF (_fbUnit1.eUnitState = E_COMPONENT_STATUS.STARTING OR _fbUnit1.eUnitState = E_COMPONENT_STATUS.STARTING OR _fbUnit1.eUnitState = E_COMPONENT_STATUS.STARTING OR _fbUnit1.eUnitState = E_COMPONENT_STATUS.STARTING) AND (NOT xError) THEN
stHMIInterface.eStatus := E_COMPONENT_STATUS.STARTING;
END_IF
IF (_fbUnit1.eUnitState = E_COMPONENT_STATUS.SHUTDOWN OR _fbUnit1.eUnitState = E_COMPONENT_STATUS.SHUTDOWN OR _fbUnit1.eUnitState = E_COMPONENT_STATUS.SHUTDOWN OR _fbUnit1.eUnitState = E_COMPONENT_STATUS.SHUTDOWN) AND (NOT xError) THEN
stHMIInterface.eStatus := E_COMPONENT_STATUS.SHUTDOWN;
END_IF
IF (_fbUnit1.eUnitState = E_COMPONENT_STATUS.OFF AND _fbUnit1.eUnitState = E_COMPONENT_STATUS.OFF AND _fbUnit1.eUnitState = E_COMPONENT_STATUS.OFF AND _fbUnit1.eUnitState = E_COMPONENT_STATUS.OFF) AND (NOT xError) THEN
stHMIInterface.eStatus := E_COMPONENT_STATUS.OFF;
END_IF
IF xError THEN
stHMIInterface.eStatus := E_COMPONENT_STATUS.ERROR;
END_IF]]></ST>
END_IF
]]></ST>
</Implementation>
<Method Name="FB_init" Id="{369c1d27-76e4-45f8-9dbe-03524d3389df}">
<Declaration><![CDATA[METHOD FB_init : BOOL
@@ -443,6 +475,11 @@ _fbUnitsOutOfBalanceAlarm.CreateEx(stEventEntry := TC_EVENTS.BMSEvents.ModuleImb
// Create alarm message
_fbUnitsOutOfBalanceAlarm.ipArguments.Clear().AddString(_sName);
// Create connection lost alarm
_fbConnLostAlarm.CreateEx(stEventEntry := TC_EVENTS.General.CommError, bWithConfirmation := TRUE, 0);
_fbConnLostAlarm.ipArguments.Clear().AddString(_sName);
// Create leakage alarm messages
]]></ST>
</Implementation>
@@ -471,9 +508,59 @@ _fbUnit3.Name := CONCAT(_sName, ' - Unit 3');
_fbUnit4.Name := CONCAT(_sName, ' - Unit 4');
// Create alarm message
_fbUnitsOutOfBalanceAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
_fbUnitsOutOfBalanceAlarm.ipArguments.Clear().AddString(_sName);
// Create connection lost alarm
_fbConnLostAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
</Implementation>
</Set>
</Property>
<LineIds Name="FB_Module">
<LineId Id="3" Count="8" />
<LineId Id="338" Count="0" />
<LineId Id="340" Count="1" />
<LineId Id="339" Count="0" />
<LineId Id="352" Count="0" />
<LineId Id="337" Count="0" />
<LineId Id="342" Count="1" />
<LineId Id="345" Count="2" />
<LineId Id="344" Count="0" />
<LineId Id="349" Count="0" />
<LineId Id="348" Count="0" />
<LineId Id="350" Count="1" />
<LineId Id="12" Count="275" />
<LineId Id="317" Count="2" />
<LineId Id="326" Count="0" />
<LineId Id="325" Count="0" />
<LineId Id="327" Count="1" />
<LineId Id="330" Count="0" />
<LineId Id="329" Count="0" />
<LineId Id="331" Count="1" />
<LineId Id="334" Count="0" />
<LineId Id="333" Count="0" />
<LineId Id="335" Count="1" />
<LineId Id="322" Count="0" />
<LineId Id="321" Count="0" />
<LineId Id="323" Count="1" />
<LineId Id="2" Count="0" />
</LineIds>
<LineIds Name="FB_Module.FB_init">
<LineId Id="3" Count="13" />
<LineId Id="18" Count="0" />
<LineId Id="21" Count="1" />
<LineId Id="19" Count="1" />
<LineId Id="17" Count="0" />
<LineId Id="2" Count="0" />
</LineIds>
<LineIds Name="FB_Module.Name.Get">
<LineId Id="2" Count="0" />
</LineIds>
<LineIds Name="FB_Module.Name.Set">
<LineId Id="3" Count="8" />
<LineId Id="2" Count="0" />
<LineId Id="14" Count="0" />
<LineId Id="13" Count="0" />
<LineId Id="12" Count="0" />
</LineIds>
</POU>
</TcPlcObject>