Files
Uniper_PLC/PLC/POUs/FB_Module.TcPOU
2024-01-05 16:27:39 +01:00

332 lines
9.6 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
<POU Name="FB_Module" Id="{87be924f-018d-4c09-997b-f0c0054414cc}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FB_Module
VAR_INPUT
// Emergency stop ok
xEmergencyStopOk : BOOL;
// Enable
xEnable : BOOL;
// Module completely off
xOff : BOOL := TRUE;
// HMI Interface
stHMIInterface : REFERENCE TO ST_MODULE_HMI_INTERFACE;
// Release alarms
xReleaseErrors : BOOL;
// Release analog io limit errors
xReleaseLimitErrors : BOOL;
// Input to confirm all errors
xConfirmAlarms : BOOL;
END_VAR
VAR_OUTPUT
// Module voltage
rCurrentVoltage : REAL;
// Module ready
xReady : BOOL;
// Module in shutdown segment discharge mode
xInShutdownDischargeMode : BOOL;
// Module can be discharged during shutdown sequence
xShutdownDischargeAllowed : BOOL;
// One unit has an error
xError : BOOL;
// One unit has a warning
xWarning : BOOL;
END_VAR
VAR
_fbUnit1 : FB_Unit(CONCAT(_sName, ' Unit 1'));
_fbUnit2 : FB_Unit(CONCAT(_sName, ' Unit 2'));
_fbUnit3 : FB_Unit(CONCAT(_sName, ' Unit 3'));
_fbUnit4 : FB_Unit(CONCAT(_sName, ' Unit 4'));
// Flag for unit balance checking
_xBalanceOk : BOOL;
// All units are ready
_xAllUnitsReady : BOOL;
// Module name
_sName : STRING;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[// Reset error and warning flag
xError := FALSE;
xWarning := FALSE;
// ===============================
// Unit 1
// ===============================
_fbUnit1(
xEnable := xEnable,
stUnitConfig:= GVL_CONFIG.stUnitConfig,
stHMIInterface:= stHMIInterface.stHMIInterfaceUnit1,
xEmergencyStopOk:= xEmergencyStopOk,
rSetpointPosolytPumpInlet:= GVL_CONFIG.rPumpPosolytOnPower,
rSetpointNegolytPumpInlet:= GVL_CONFIG.rPumpNegolytOnPower,
xReleaseErrors:= xReleaseErrors,
xReleaseLimitErrors:= xReleaseLimitErrors,
xConfirmAlarms:= xConfirmAlarms,
_xWarningConfirmPending=> );
IF _fbUnit1.xWarning THEN
xWarning := TRUE;
END_IF
IF _fbUnit1.xError THEN
xError := TRUE;
END_IF
// ===============================
// Unit 2
// ===============================
_fbUnit2(
xEnable := xEnable,
stUnitConfig:= GVL_CONFIG.stUnitConfig,
stHMIInterface:= stHMIInterface.stHMIInterfaceUnit2,
xEmergencyStopOk:= xEmergencyStopOk,
rSetpointPosolytPumpInlet:= GVL_CONFIG.rPumpPosolytOnPower,
rSetpointNegolytPumpInlet:= GVL_CONFIG.rPumpNegolytOnPower,
xReleaseErrors:= xReleaseErrors,
xReleaseLimitErrors:= xReleaseLimitErrors,
xConfirmAlarms:= xConfirmAlarms,
_xWarningConfirmPending=> );
IF _fbUnit2.xWarning THEN
xWarning := TRUE;
END_IF
IF _fbUnit2.xError THEN
xError := TRUE;
END_IF
// ===============================
// Unit 3
// ===============================
_fbUnit3(
xEnable := xEnable,
stUnitConfig:= GVL_CONFIG.stUnitConfig,
stHMIInterface:= stHMIInterface.stHMIInterfaceUnit3,
xEmergencyStopOk:= xEmergencyStopOk,
rSetpointPosolytPumpInlet:= GVL_CONFIG.rPumpPosolytOnPower,
rSetpointNegolytPumpInlet:= GVL_CONFIG.rPumpNegolytOnPower,
xReleaseErrors:= xReleaseErrors,
xReleaseLimitErrors:= xReleaseLimitErrors,
xConfirmAlarms:= xConfirmAlarms,
_xWarningConfirmPending=> );
IF _fbUnit3.xWarning THEN
xWarning := TRUE;
END_IF
IF _fbUnit3.xError THEN
xError := TRUE;
END_IF
// ===============================
// Unit 4
// ===============================
_fbUnit4(
xEnable := xEnable,
stUnitConfig:= GVL_CONFIG.stUnitConfig,
stHMIInterface:= stHMIInterface.stHMIInterfaceUnit4,
xEmergencyStopOk:= xEmergencyStopOk,
rSetpointPosolytPumpInlet:= GVL_CONFIG.rPumpPosolytOnPower,
rSetpointNegolytPumpInlet:= GVL_CONFIG.rPumpNegolytOnPower,
xReleaseErrors:= xReleaseErrors,
xReleaseLimitErrors:= xReleaseLimitErrors,
xConfirmAlarms:= xConfirmAlarms,
_xWarningConfirmPending=> );
IF _fbUnit4.xWarning THEN
xWarning := TRUE;
END_IF
IF _fbUnit4.xError THEN
xError := TRUE;
END_IF
// ===============================
// Units ready check
// ===============================
_xAllUnitsReady := _fbUnit1.xReady AND _fbUnit2.xReady AND _fbUnit3.xReady AND _fbUnit4.xReady;
// ===============================
// Units in shutdown discharge mode
// ===============================
xInShutdownDischargeMode := _fbUnit1.xInShutdownDischargeMode AND _fbUnit2.xInShutdownDischargeMode AND _fbUnit3.xInShutdownDischargeMode AND _fbUnit4.xInShutdownDischargeMode;
// ===============================
// Units shutdown discharge allowed
// ===============================
xShutdownDischargeAllowed := _fbUnit1.xShutdownDischargeAllowed AND _fbUnit2.xShutdownDischargeAllowed AND _fbUnit3.xShutdownDischargeAllowed AND _fbUnit4.xShutdownDischargeAllowed;
// ===============================
// All units off
// ===============================
xOff := _fbUnit1.xOff AND _fbUnit2.xOff AND _fbUnit3.xOff AND _fbUnit4.xOff;
// ===============================
// Calculate module voltage
// ===============================
rCurrentVoltage := _fbUnit1.rCurrentVoltage + _fbUnit2.rCurrentVoltage + _fbUnit3.rCurrentVoltage + _fbUnit4.rCurrentVoltage;
// ===============================
// Module balance check
// ===============================
// Reset balance ok flag
_xBalanceOk := TRUE;
// Test unit 1 with unit 2
IF ABS(_fbUnit1.rCurrentVoltage - _fbUnit2.rCurrentVoltage) > GVL_CONFIG.rMaxAbsDiffVoltageUnitsOnModule THEN
_xBalanceOk := FALSE;
END_IF
// Test unit 1 with unit 3
IF ABS(_fbUnit1.rCurrentVoltage - _fbUnit3.rCurrentVoltage) > GVL_CONFIG.rMaxAbsDiffVoltageUnitsOnModule THEN
_xBalanceOk := FALSE;
END_IF
// Test unit 1 with unit 4
IF ABS(_fbUnit1.rCurrentVoltage - _fbUnit4.rCurrentVoltage) > GVL_CONFIG.rMaxAbsDiffVoltageUnitsOnModule THEN
_xBalanceOk := FALSE;
END_IF
// Test unit 2 with unit 3
IF ABS(_fbUnit2.rCurrentVoltage - _fbUnit3.rCurrentVoltage) > GVL_CONFIG.rMaxAbsDiffVoltageUnitsOnModule THEN
_xBalanceOk := FALSE;
END_IF
// Test unit 2 with unit 4
IF ABS(_fbUnit2.rCurrentVoltage - _fbUnit4.rCurrentVoltage) > GVL_CONFIG.rMaxAbsDiffVoltageUnitsOnModule THEN
_xBalanceOk := FALSE;
END_IF
// Test unit 3 with unit 4
IF ABS(_fbUnit3.rCurrentVoltage - _fbUnit4.rCurrentVoltage) > GVL_CONFIG.rMaxAbsDiffVoltageUnitsOnModule THEN
_xBalanceOk := FALSE;
END_IF
// Signal an error if all units are ready and module is out of balance
IF _xAllUnitsReady AND (NOT _xBalanceOk) THEN
xError := TRUE;
END_IF
// ===============================
// Module ready validation check
// ===============================
IF _xAllUnitsReady AND _xBalanceOk THEN
xReady := TRUE;
ELSE
xReady := FALSE;
END_IF]]></ST>
</Implementation>
<Method Name="FB_init" Id="{369c1d27-76e4-45f8-9dbe-03524d3389df}">
<Declaration><![CDATA[METHOD FB_init : BOOL
VAR_INPUT
bInitRetains : BOOL; // if TRUE, the retain variables are initialized (warm start / cold start)
bInCopyCode : BOOL; // if TRUE, the instance afterwards gets moved into the copy code (online change)
sName : STRING;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[_sName := sName;]]></ST>
</Implementation>
</Method>
<LineIds Name="FB_Module">
<LineId Id="248" Count="7" />
<LineId Id="456" Count="0" />
<LineId Id="256" Count="22" />
<LineId Id="457" Count="0" />
<LineId Id="279" Count="22" />
<LineId Id="458" Count="0" />
<LineId Id="302" Count="22" />
<LineId Id="459" Count="0" />
<LineId Id="325" Count="15" />
<LineId Id="188" Count="0" />
<LineId Id="441" Count="0" />
<LineId Id="436" Count="0" />
<LineId Id="438" Count="1" />
<LineId Id="437" Count="0" />
<LineId Id="435" Count="0" />
<LineId Id="465" Count="0" />
<LineId Id="464" Count="0" />
<LineId Id="466" Count="1" />
<LineId Id="448" Count="0" />
<LineId Id="469" Count="0" />
<LineId Id="486" Count="0" />
<LineId Id="483" Count="2" />
<LineId Id="482" Count="0" />
<LineId Id="468" Count="0" />
<LineId Id="495" Count="0" />
<LineId Id="491" Count="1" />
<LineId Id="487" Count="0" />
<LineId Id="494" Count="0" />
<LineId Id="493" Count="0" />
<LineId Id="444" Count="0" />
<LineId Id="446" Count="1" />
<LineId Id="445" Count="0" />
<LineId Id="442" Count="0" />
<LineId Id="440" Count="0" />
<LineId Id="378" Count="3" />
<LineId Id="387" Count="0" />
<LineId Id="389" Count="0" />
<LineId Id="393" Count="0" />
<LineId Id="388" Count="0" />
<LineId Id="404" Count="2" />
<LineId Id="395" Count="0" />
<LineId Id="394" Count="0" />
<LineId Id="408" Count="1" />
<LineId Id="407" Count="0" />
<LineId Id="397" Count="0" />
<LineId Id="396" Count="0" />
<LineId Id="411" Count="1" />
<LineId Id="410" Count="0" />
<LineId Id="399" Count="0" />
<LineId Id="398" Count="0" />
<LineId Id="414" Count="1" />
<LineId Id="413" Count="0" />
<LineId Id="401" Count="0" />
<LineId Id="400" Count="0" />
<LineId Id="417" Count="1" />
<LineId Id="416" Count="0" />
<LineId Id="403" Count="0" />
<LineId Id="402" Count="0" />
<LineId Id="420" Count="1" />
<LineId Id="419" Count="0" />
<LineId Id="423" Count="0" />
<LineId Id="422" Count="0" />
<LineId Id="377" Count="0" />
<LineId Id="449" Count="1" />
<LineId Id="452" Count="0" />
<LineId Id="460" Count="1" />
<LineId Id="451" Count="0" />
<LineId Id="453" Count="1" />
<LineId Id="463" Count="0" />
<LineId Id="462" Count="0" />
<LineId Id="455" Count="0" />
</LineIds>
<LineIds Name="FB_Module.FB_init">
<LineId Id="7" Count="0" />
</LineIds>
</POU>
</TcPlcObject>