WIP: Aktueller stand für fehlersuche Sensorrauschen

This commit is contained in:
Matthias Heisig
2024-05-22 17:43:26 +02:00
parent cf0d144987
commit 0d9a4d9c72
27 changed files with 1667 additions and 824 deletions

View File

@@ -51,6 +51,16 @@ VAR
// Emergency stop not ok alarm
_fbEStopNotOk : FB_TcAlarm;
// String 1 Error Mssage
_fbEtherCATErrorString1 : FB_TcAlarm;
_stECString1ErrSI : FB_TcSourceInfo;
// String 2 Error Mssage
_fbEtherCATErrorString2 : FB_TcAlarm;
_stECString2ErrSI : FB_TcSourceInfo;
// First cycle tag
_xFirstCycle : BOOL := TRUE;
@@ -104,12 +114,18 @@ VAR
// Safety
_fbSafety : FB_Safety;
// String EtherCAT state
_uiEtherCATState AT%I* : UINT;
_wEtherCATState : WORD;
_xEtherCatString1Ok : BOOL;
_xEtherCatString2Ok : BOOL;
// DEBUG
_xRestart : BOOL;
_xDebug : BOOL;
_uiDebugCurrentString : UINT := 1;
_uiDebugCurrentString : UINT := 0;
_ModbusDebugTest : ST_MODBUS_REG_11;
@@ -140,9 +156,21 @@ IF _xFirstCycle THEN
_fbBatteryEmptyMessage.CreateEx(stEventEntry := TC_EVENTS.BMSEvents.BatteryEmpty, 0);
_fbEStopNotOk.CreateEx(stEventEntry := TC_EVENTS.BMSEvents.EmergencyStopNotOk, TRUE, 0);
_stECString1ErrSI.Clear();
_stECString1ErrSI.nId := 1;
_stECString1ErrSI.sName := 'MAIN';
_fbEtherCATErrorString1.CreateEx(stEventEntry := TC_EVENTS.BMSEvents.EthercatStringError, TRUE, _stECString1ErrSI);
_fbEtherCATErrorString1.ipArguments.Clear().AddString('1');
_stECString2ErrSI.Clear();
_stECString2ErrSI.nId := 2;
_stECString2ErrSI.sName := 'MAIN';
_fbEtherCATErrorString2.CreateEx(stEventEntry := TC_EVENTS.BMSEvents.EthercatStringError, TRUE, _stECString2ErrSI);
_fbEtherCATErrorString2.ipArguments.Clear().AddString('2');
END_IF
// Reset error flag
_xErrorActive := FALSE;
// Ack alarms from HMI
@@ -151,6 +179,40 @@ IF GVL_SCADA.stAckAlarmsButton.xRequest THEN
GVL_SCADA.stAckAlarmsButton.xRequest := FALSE;
END_IF
// ===============================
// EtherCAT communication error
// ===============================
_wEtherCATState := UINT_TO_WORD(_uiEtherCATState);
_xEtherCatString1Ok := (_wEtherCATState AND 16#8000) = 0;
_xEtherCatString2Ok := (_wEtherCATState AND 16#2000) = 0;
// String 1 on X1 = Port D = 0x8000
IF (NOT _xEtherCatString1Ok) AND (NOT _fbEtherCATErrorString1.bRaised) THEN
_fbEtherCATErrorString1.Raise(0);
END_IF
IF _fbEtherCATErrorString1.bRaised AND (_xEtherCatString1Ok) THEN
_fbEtherCATErrorString1.Clear(0, FALSE);
END_IF
IF _fbEtherCATErrorString1.eConfirmationState = TcEventConfirmationState.WaitForConfirmation AND _xConfirmAlarms THEN
_fbEtherCATErrorString1.Confirm(0);
END_IF
// String 2 on X2 = Port B = 0x2000
IF (NOT _xEtherCatString2Ok) AND (NOT _fbEtherCATErrorString2.bRaised) THEN
_fbEtherCATErrorString2.Raise(0);
END_IF
IF _fbEtherCATErrorString2.bRaised AND _xEtherCatString2Ok THEN
_fbEtherCATErrorString2.Clear(0, FALSE);
END_IF
IF _fbEtherCATErrorString2.eConfirmationState = TcEventConfirmationState.WaitForConfirmation AND _xConfirmAlarms THEN
_fbEtherCATErrorString2.Confirm(0);
END_IF
// ===============================
// Safety
// ===============================
@@ -212,14 +274,14 @@ _tonStartupDelay(IN := TRUE);
// Call string 1
_afbStrings[0](
stStringModuleVoltageConfig := GVL_CONFIG.stString1VoltageConfig,
xEnable := _xEnableString AND GVL_CONFIG.xDummy,
xStartBalancing := _xStartBalancing AND GVL_CONFIG.xDummy,
xEnable := _xEnableString, //AND GVL_CONFIG.xDummy,
xStartBalancing := _xStartBalancing, // AND GVL_CONFIG.xDummy,
sInverterIP := GVL_CONFIG.sInverterIpString1,
rPowerInverter := _rPowerInverter,
xInSafetyCheckMode := _xInSafetyCheckMode,
stHMIInterface:= GVL_SCADA.stHMIInterface[0],
xEmergencyStopOk:= _xEmergencyStopOk,
xReleaseErrors:= _xReleaseErrors AND _tonStartupDelay.Q AND GVL_CONFIG.xDummy,
xReleaseErrors:= _xReleaseErrors AND _tonStartupDelay.Q AND _xEtherCatString1Ok,
xReleaseLimitErrors:= _xReleaseLimitsErrors AND _tonStartupDelay.Q,
xReleaseManualMode := _xReleaseManualMode,
xConfirmAlarms:= _xConfirmAlarms,
@@ -239,7 +301,7 @@ _afbStrings[1](
xInSafetyCheckMode := _xInSafetyCheckMode,
stHMIInterface:= GVL_SCADA.stHMIInterface[1],
xEmergencyStopOk:= _xEmergencyStopOk,
xReleaseErrors:= _xReleaseErrors AND _tonStartupDelay.Q,
xReleaseErrors:= _xReleaseErrors AND _tonStartupDelay.Q AND _xEtherCatString2Ok,
xReleaseLimitErrors:= _xReleaseLimitsErrors AND _tonStartupDelay.Q,
xReleaseManualMode := _xReleaseManualMode,
xConfirmAlarms:= _xConfirmAlarms,
@@ -443,6 +505,7 @@ END_IF]]></ST>
IF (ABS(_rAutoPowerRequest) < DINT_TO_REAL(GVL_CONFIG.diMinimumAbsPowerForEnable)) THEN
_xEnableString := FALSE;
_xCanChangeMode := TRUE;
_iState := 45;
END_IF
@@ -479,7 +542,7 @@ END_IF]]></ST>
// Start string shutdown
_xEnableString := FALSE;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus := E_CHARGE_STATUS.UNDEFINED;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus := E_CHARGE_STATUS.DISCHARGING;
GVL_MODBUS.stModbusEMSComm.stModbusReg10.uiActiveParallelMembers := 0;
_iState := 35;
END_IF
@@ -533,6 +596,7 @@ END_IF]]></ST>
_xEnableString := FALSE;
_tonBeginShutdown(In := FALSE);
GVL_SCADA.stAutomaticModeHMI.diSetpointAutomatic := 0;
_xCanChangeMode := TRUE;
_iState := 45;
END_IF
@@ -579,6 +643,7 @@ END_IF]]></ST>
45: // Wait for shutdown of string to be done
IF (NOT _afbStrings[_uiDebugCurrentString].xInShutdownDischargeMode) AND _afbStrings[_uiDebugCurrentString].xOff THEN
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eBatteryStatus := E_BATTERY_STATUS.OFF;
GVL_MODBUS.stModbusEMSComm.stModbusReg11.eChargeStatus := E_CHARGE_STATUS.UNDEFINED;
_iState := 0;
END_IF
@@ -679,10 +744,13 @@ IF GVL_SCADA.stAutomaticModeHMI.stStartAutoButton.xRequest THEN
END_IF
END_IF
// Sto pif stop button pressed
IF GVL_SCADA.stAutomaticModeHMI.stStopAutoButton.xRequest THEN
_xStartSafetyCheck := FALSE;
END_IF
// State machine
CASE _iStateSafetyCheck OF
0: // Idle
// Wait for start command
@@ -698,6 +766,7 @@ CASE _iStateSafetyCheck OF
_iStateSafetyCheck := 30;
END_IF
// Shutdown
IF NOT _xStartSafetyCheck THEN
_xEnableString := FALSE;
_iStateSafetyCheck := 0;
@@ -739,6 +808,7 @@ CASE _iStateSafetyCheck OF
1000: // Error state
_xEnableString := FALSE;
_rPowerInverter := 0.0;
_xCanChangeMode := TRUE;
_iStateSafetyCheck := 1010;
1010: // Wait for reset from error state
@@ -758,11 +828,31 @@ END_CASE]]></ST>
<LineId Id="2808" Count="0" />
<LineId Id="2813" Count="1" />
<LineId Id="2917" Count="1" />
<LineId Id="3257" Count="0" />
<LineId Id="3442" Count="0" />
<LineId Id="3306" Count="1" />
<LineId Id="3258" Count="0" />
<LineId Id="3260" Count="1" />
<LineId Id="3443" Count="0" />
<LineId Id="3308" Count="1" />
<LineId Id="3259" Count="0" />
<LineId Id="3262" Count="0" />
<LineId Id="2807" Count="0" />
<LineId Id="2805" Count="0" />
<LineId Id="2802" Count="0" />
<LineId Id="2045" Count="0" />
<LineId Id="2932" Count="4" />
<LineId Id="3445" Count="7" />
<LineId Id="3444" Count="0" />
<LineId Id="3264" Count="3" />
<LineId Id="3272" Count="0" />
<LineId Id="3298" Count="1" />
<LineId Id="3282" Count="0" />
<LineId Id="3277" Count="0" />
<LineId Id="3268" Count="2" />
<LineId Id="3274" Count="0" />
<LineId Id="3273" Count="0" />
<LineId Id="3275" Count="1" />
<LineId Id="3279" Count="2" />
<LineId Id="3278" Count="0" />
<LineId Id="3284" Count="11" />
<LineId Id="3283" Count="0" />
<LineId Id="2931" Count="0" />
<LineId Id="2046" Count="5" />
<LineId Id="2920" Count="0" />
@@ -875,7 +965,9 @@ END_CASE]]></ST>
<LineId Id="214" Count="0" />
<LineId Id="187" Count="1" />
<LineId Id="200" Count="1" />
<LineId Id="203" Count="1" />
<LineId Id="203" Count="0" />
<LineId Id="246" Count="0" />
<LineId Id="204" Count="0" />
<LineId Id="202" Count="0" />
<LineId Id="220" Count="0" />
<LineId Id="44" Count="16" />
@@ -890,6 +982,7 @@ END_CASE]]></ST>
<LineId Id="206" Count="0" />
<LineId Id="117" Count="0" />
<LineId Id="217" Count="0" />
<LineId Id="245" Count="0" />
<LineId Id="118" Count="9" />
<LineId Id="207" Count="0" />
<LineId Id="218" Count="0" />
@@ -902,7 +995,9 @@ END_CASE]]></ST>
<LineId Id="225" Count="0" />
<LineId Id="227" Count="2" />
<LineId Id="226" Count="0" />
<LineId Id="151" Count="5" />
<LineId Id="151" Count="3" />
<LineId Id="244" Count="0" />
<LineId Id="155" Count="1" />
<LineId Id="209" Count="0" />
<LineId Id="213" Count="0" />
<LineId Id="210" Count="2" />
@@ -952,7 +1047,11 @@ END_CASE]]></ST>
<LineId Id="242" Count="0" />
<LineId Id="236" Count="0" />
<LineId Id="243" Count="0" />
<LineId Id="237" Count="4" />
<LineId Id="237" Count="0" />
<LineId Id="252" Count="0" />
<LineId Id="249" Count="0" />
<LineId Id="239" Count="2" />
<LineId Id="253" Count="1" />
<LineId Id="17" Count="0" />
<LineId Id="20" Count="3" />
<LineId Id="198" Count="0" />
@@ -961,7 +1060,9 @@ END_CASE]]></ST>
<LineId Id="216" Count="0" />
<LineId Id="25" Count="0" />
<LineId Id="39" Count="4" />
<LineId Id="206" Count="2" />
<LineId Id="206" Count="0" />
<LineId Id="246" Count="0" />
<LineId Id="207" Count="1" />
<LineId Id="210" Count="0" />
<LineId Id="209" Count="0" />
<LineId Id="211" Count="0" />
@@ -981,6 +1082,7 @@ END_CASE]]></ST>
<LineId Id="222" Count="0" />
<LineId Id="177" Count="4" />
<LineId Id="183" Count="0" />
<LineId Id="247" Count="0" />
<LineId Id="185" Count="3" />
<LineId Id="195" Count="1" />
<LineId Id="218" Count="1" />