Added inverter implementation

This commit is contained in:
Matthias Heisig
2024-01-05 16:27:39 +01:00
parent bd0bbd9c8b
commit 4586e72a0e
18 changed files with 1318 additions and 293 deletions

View File

@@ -3,6 +3,9 @@
<POU Name="FB_String" Id="{46501225-f446-4674-bfed-3be64273e576}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FB_String
VAR_INPUT
// Enable
xEnable : BOOL;
// Module 1 HMI interface
stHMIInterface : ST_STRING_HMI_INTERFACE;
@@ -19,6 +22,21 @@ VAR_INPUT
xConfirmAlarms : BOOL;
END_VAR
VAR_OUTPUT
// Current string voltage
rCurrentVoltage : REAL;
// Module in shutdown segment discharge mode
xInShutdownDischargeMode : BOOL;
// Module can be discharged during shutdown sequence
xShutdownDischargeAllowed : BOOL;
// String ready
xReady : BOOL;
// String completely off
xOff : BOOL;
xError : BOOL;
xWarning : BOOL;
END_VAR
@@ -27,15 +45,28 @@ VAR
_fbModule2 : FB_Module(CONCAT(_sName, 'Module 2'));
_fbModule3 : FB_Module(CONCAT(_sName, 'Module 3'));
// All modules are ready
_xAllModulesReady : BOOL;
// All modules in shutdown discharge mode
_xAllModulesInShutdownDischargeMode : BOOL;
// Flag for module balance checking
_xBalanceOk : BOOL;
// String name
_sName : STRING;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[// ===============================
<ST><![CDATA[// Reset error flag
xError := FALSE;
// ===============================
// Module 1
// ===============================
_fbModule1(
xEnable := xEnable,
xEmergencyStopOk:= xEmergencyStopOk,
stHMIInterface:= stHMIInterface.stHMIInterfaceModule1,
xReleaseErrors:= xReleaseErrors,
@@ -55,6 +86,7 @@ END_IF
// Module 2
// ===============================
_fbModule2(
xEnable := xEnable,
xEmergencyStopOk:= xEmergencyStopOk,
stHMIInterface:= stHMIInterface.stHMIInterfaceModule2,
xReleaseErrors:= xReleaseErrors,
@@ -74,6 +106,7 @@ END_IF
// Module 3
// ===============================
_fbModule3(
xEnable := xEnable,
xEmergencyStopOk:= xEmergencyStopOk,
stHMIInterface:= stHMIInterface.stHMIInterfaceModule3,
xReleaseErrors:= xReleaseErrors,
@@ -86,6 +119,73 @@ END_IF
IF _fbModule3.xError THEN
xError := TRUE;
END_IF
// ===============================
// Modules ready check
// ===============================
_xAllModulesReady := _fbModule1.xReady AND _fbModule2.xReady AND _fbModule3.xReady;
// ===============================
// Modules in shutdown discharge mode
// ===============================
xInShutdownDischargeMode := _fbModule1.xInShutdownDischargeMode AND _fbModule2.xInShutdownDischargeMode AND _fbModule3.xInShutdownDischargeMode;
// ===============================
// Units shutdown discharge allowed
// ===============================
xShutdownDischargeAllowed := _fbModule1.xShutdownDischargeAllowed AND _fbModule2.xShutdownDischargeAllowed AND _fbModule3.xShutdownDischargeAllowed;
// ===============================
// All modules off
// ===============================
xOff := _fbModule1.xOff AND _fbModule2.xOff AND _fbModule3.xOff;
// ===============================
// Calculate module voltage
// ===============================
rCurrentVoltage := _fbModule1.rCurrentVoltage + _fbModule2.rCurrentVoltage + _fbModule3.rCurrentVoltage;
// ===============================
// String balance check
// ===============================
// Reset balance ok flag
_xBalanceOk := TRUE;
// Test module 1 with module 2
IF ABS(_fbModule1.rCurrentVoltage - _fbModule2.rCurrentVoltage) > GVL_CONFIG.rMaxAbsDiffVoltageModulesInString THEN
_xBalanceOk := FALSE;
END_IF
// Test module 1 with module 3
IF ABS(_fbModule1.rCurrentVoltage - _fbModule3.rCurrentVoltage) > GVL_CONFIG.rMaxAbsDiffVoltageModulesInString THEN
_xBalanceOk := FALSE;
END_IF
// Test module 2 with module 3
IF ABS(_fbModule2.rCurrentVoltage - _fbModule3.rCurrentVoltage) > GVL_CONFIG.rMaxAbsDiffVoltageModulesInString THEN
_xBalanceOk := FALSE;
END_IF
// Signal an error if all units are ready and module is out of balance
IF _xAllModulesReady AND (NOT _xBalanceOk) THEN
xError := TRUE;
END_IF
// ===============================
// String ready validation check
// ===============================
IF _xAllModulesReady AND _xBalanceOk THEN
xReady := TRUE;
ELSE
xReady := FALSE;
END_IF]]></ST>
</Implementation>
<Method Name="FB_init" Id="{9e8494eb-1b40-4be9-91c8-810ecbdf7f0c}">
@@ -102,9 +202,14 @@ END_VAR
</Implementation>
</Method>
<LineIds Name="FB_String">
<LineId Id="266" Count="0" />
<LineId Id="268" Count="0" />
<LineId Id="267" Count="0" />
<LineId Id="69" Count="0" />
<LineId Id="67" Count="1" />
<LineId Id="47" Count="1" />
<LineId Id="47" Count="0" />
<LineId Id="140" Count="0" />
<LineId Id="48" Count="0" />
<LineId Id="50" Count="3" />
<LineId Id="58" Count="0" />
<LineId Id="62" Count="0" />
@@ -112,10 +217,41 @@ END_VAR
<LineId Id="66" Count="0" />
<LineId Id="63" Count="0" />
<LineId Id="59" Count="2" />
<LineId Id="71" Count="17" />
<LineId Id="71" Count="5" />
<LineId Id="141" Count="0" />
<LineId Id="77" Count="11" />
<LineId Id="70" Count="0" />
<LineId Id="90" Count="17" />
<LineId Id="90" Count="5" />
<LineId Id="142" Count="0" />
<LineId Id="96" Count="11" />
<LineId Id="89" Count="0" />
<LineId Id="183" Count="5" />
<LineId Id="245" Count="4" />
<LineId Id="244" Count="0" />
<LineId Id="261" Count="4" />
<LineId Id="260" Count="0" />
<LineId Id="270" Count="4" />
<LineId Id="269" Count="0" />
<LineId Id="197" Count="0" />
<LineId Id="190" Count="3" />
<LineId Id="182" Count="0" />
<LineId Id="199" Count="5" />
<LineId Id="198" Count="0" />
<LineId Id="209" Count="0" />
<LineId Id="208" Count="0" />
<LineId Id="230" Count="1" />
<LineId Id="211" Count="0" />
<LineId Id="232" Count="0" />
<LineId Id="210" Count="0" />
<LineId Id="234" Count="1" />
<LineId Id="233" Count="0" />
<LineId Id="213" Count="0" />
<LineId Id="212" Count="0" />
<LineId Id="237" Count="1" />
<LineId Id="236" Count="0" />
<LineId Id="215" Count="11" />
<LineId Id="239" Count="1" />
<LineId Id="214" Count="0" />
</LineIds>
<LineIds Name="FB_String.FB_init">
<LineId Id="7" Count="0" />