Minor bugfixes and future addons

This commit is contained in:
Matthias Heisig
2025-04-06 10:21:01 +02:00
parent 84e0e174a1
commit 2221f6bab3
22 changed files with 795 additions and 509 deletions

View File

@@ -12,9 +12,6 @@ VAR_INPUT
// Start balancing
xStartBalancing : BOOL;
// Component shortage workaround
stModuleVoltageConfig : ST_MODULE_VOLT_CONFIG;
// Module in safety check mode
xInSafetyCheckMode : BOOL;
@@ -57,6 +54,10 @@ VAR_INPUT
// Leakage tank
xLeakageTank AT %I* : BOOL;
// Current current value from string to copy to HMI interface
rCurrent : REAL;
// Current EtherCAT state
uiECState AT %I* : UINT;
END_VAR
VAR_OUTPUT
@@ -117,16 +118,9 @@ VAR
// Connection lost alarm
_fbConnLostAlarm : FB_TcAlarm;
// Enable balance check
_xEnableBalanceCheck : BOOL;
// Module name
_sName : STRING;
// Moving average filter for module voltage
//_fbMAFVoltage : FB_MovingAverageFilter;
//_arMAFVoltage : ARRAY[0..9] OF REAL;
_fbBalanceNotOkSignal : FB_ReleaseSignal;
_xECModuleInOP : BOOL;
@@ -220,7 +214,6 @@ _fbUnit1(
xEnable := xEnable,
xStartBalancing := xStartBalancing,
xInverterEnabled := xInverterEnabled,
xVoltageSensorIs1500V := stModuleVoltageConfig.xUnit1Is1500V,
xInSafetyCheckMode := xInSafetyCheckMode,
stUnitConfig:= GVL_CONFIG.stUnitConfig,
stHMIInterface:= refstHMIInterface.stHMIInterfaceUnit1,
@@ -230,8 +223,9 @@ _fbUnit1(
xConfirmAlarms:= xConfirmAlarms,
xReleaseManualMode := xReleaseManualMode,
rBalancingTargetVoltage := rBalancingTargetVoltage,
xAllToManualMode := xAllToManualMode,
_xWarningConfirmPending=> );
xAllToManualMode := xAllToManualMode);
refstHMIInterface.stHMIInterfaceUnit1.rCurrent := rCurrent;
IF _fbUnit1.xWarning THEN
xWarning := TRUE;
@@ -258,7 +252,6 @@ _fbUnit2(
xEnable := xEnable,
xStartBalancing := xStartBalancing,
xInverterEnabled := xInverterEnabled,
xVoltageSensorIs1500V := stModuleVoltageConfig.xUnit2Is1500V,
xInSafetyCheckMode := xInSafetyCheckMode,
stUnitConfig:= GVL_CONFIG.stUnitConfig,
stHMIInterface:= refstHMIInterface.stHMIInterfaceUnit2,
@@ -268,8 +261,9 @@ _fbUnit2(
xConfirmAlarms:= xConfirmAlarms,
xReleaseManualMode := xReleaseManualMode,
rBalancingTargetVoltage := rBalancingTargetVoltage,
xAllToManualMode := xAllToManualMode,
_xWarningConfirmPending=> );
xAllToManualMode := xAllToManualMode);
refstHMIInterface.stHMIInterfaceUnit2.rCurrent := rCurrent;
IF _fbUnit2.xWarning THEN
xWarning := TRUE;
@@ -296,7 +290,6 @@ _fbUnit3(
xEnable := xEnable,
xStartBalancing := xStartBalancing,
xInverterEnabled := xInverterEnabled,
xVoltageSensorIs1500V := stModuleVoltageConfig.xUnit3Is1500V,
xInSafetyCheckMode := xInSafetyCheckMode,
stUnitConfig:= GVL_CONFIG.stUnitConfig,
stHMIInterface:= refstHMIInterface.stHMIInterfaceUnit3,
@@ -306,8 +299,9 @@ _fbUnit3(
xConfirmAlarms:= xConfirmAlarms,
xReleaseManualMode := xReleaseManualMode,
rBalancingTargetVoltage := rBalancingTargetVoltage,
xAllToManualMode := xAllToManualMode,
_xWarningConfirmPending=> );
xAllToManualMode := xAllToManualMode);
refstHMIInterface.stHMIInterfaceUnit3.rCurrent := rCurrent;
IF _fbUnit3.xWarning THEN
xWarning := TRUE;
@@ -334,7 +328,6 @@ _fbUnit4(
xEnable := xEnable,
xStartBalancing := xStartBalancing,
xInverterEnabled := xInverterEnabled,
xVoltageSensorIs1500V := stModuleVoltageConfig.xUnit4Is1500V,
xInSafetyCheckMode := xInSafetyCheckMode,
stUnitConfig:= GVL_CONFIG.stUnitConfig,
stHMIInterface:= refstHMIInterface.stHMIInterfaceUnit4,
@@ -344,8 +337,9 @@ _fbUnit4(
xConfirmAlarms:= xConfirmAlarms,
xReleaseManualMode := xReleaseManualMode,
rBalancingTargetVoltage := rBalancingTargetVoltage,
xAllToManualMode := xAllToManualMode,
_xWarningConfirmPending=> );
xAllToManualMode := xAllToManualMode);
refstHMIInterface.stHMIInterfaceUnit4.rCurrent := rCurrent;
IF _fbUnit4.xWarning THEN
xWarning := TRUE;
@@ -394,12 +388,11 @@ xShutdownDischargeAllowed := _fbUnit1.xShutdownDischargeAllowed AND _fbUnit2.xSh
// ===============================
xOff := _fbUnit1.xOff AND _fbUnit2.xOff AND _fbUnit3.xOff AND _fbUnit4.xOff;
// ===============================
// Calculate module voltage
// ===============================
rCurrentVoltage := _fbUnit1.rCurrentVoltage + _fbUnit2.rCurrentVoltage + _fbUnit3.rCurrentVoltage + _fbUnit4.rCurrentVoltage;
//_fbMAFVoltage(pValues := ADR(_arMAFVoltage), iArraySize := 10, rCurrentValue := rCurrentVoltage, rAverage => stHMIInterface.rVoltage);
//stHMIInterface.rVoltage := rCurrentVoltage;
refstHMIInterface.rVoltage := refstHMIInterface.rVoltage * 0.9 + rCurrentVoltage * 0.1;
@@ -484,25 +477,35 @@ END_IF
rSmallestSegmentVoltage := MIN(_fbUnit1.rCurrentVoltage, _fbUnit2.rCurrentVoltage, _fbUnit3.rCurrentVoltage, _fbUnit4.rCurrentVoltage);
rHighestSegmentVoltage := MAX(_fbUnit1.rCurrentVoltage, _fbUnit2.rCurrentVoltage, _fbUnit3.rCurrentVoltage, _fbUnit4.rCurrentVoltage);
// ===============================
// Copy string current to module current
// ===============================
refstHMIInterface.rCurrent := rCurrent;
// ===============================
// Module status sum
// ===============================
// Module ready
IF xReady AND (NOT xError) THEN
refstHMIInterface.eStatus := E_COMPONENT_STATUS.ON;
END_IF
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
// Module starting
IF (NOT xOff) AND (NOT xReady) AND xEnable AND (NOT xError) THEN
refstHMIInterface.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
// Module shutdown
IF (NOT xOff) AND (NOT xReady) AND (NOT xEnable) AND (NOT xError) THEN
refstHMIInterface.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
// Module off
IF xOff AND (NOT xError) THEN
refstHMIInterface.eStatus := E_COMPONENT_STATUS.OFF;
END_IF
// Module error
IF xError THEN
refstHMIInterface.eStatus := E_COMPONENT_STATUS.ERROR;
END_IF
@@ -584,5 +587,37 @@ _fbLeackageSegment34Alarm.ipArguments.Clear().AddString(_sName);]]></ST>
</Implementation>
</Set>
</Property>
<LineIds Name="FB_Module">
<LineId Id="3" Count="81" />
<LineId Id="86" Count="9" />
<LineId Id="371" Count="1" />
<LineId Id="96" Count="25" />
<LineId Id="123" Count="9" />
<LineId Id="373" Count="1" />
<LineId Id="133" Count="25" />
<LineId Id="160" Count="9" />
<LineId Id="375" Count="1" />
<LineId Id="170" Count="25" />
<LineId Id="197" Count="9" />
<LineId Id="377" Count="1" />
<LineId Id="207" Count="135" />
<LineId Id="380" Count="1" />
<LineId Id="383" Count="0" />
<LineId Id="379" Count="0" />
<LineId Id="384" Count="0" />
<LineId Id="343" Count="27" />
<LineId Id="2" Count="0" />
</LineIds>
<LineIds Name="FB_Module.FB_init">
<LineId Id="3" Count="26" />
<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="16" />
<LineId Id="2" Count="0" />
</LineIds>
</POU>
</TcPlcObject>