260 lines
7.1 KiB
XML
260 lines
7.1 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
|
|
<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;
|
|
|
|
// Emergency stop ok
|
|
xEmergencyStopOk : BOOL;
|
|
|
|
// Release alarms
|
|
xReleaseErrors : BOOL;
|
|
|
|
// Release analog io limit errors
|
|
xReleaseLimitErrors : BOOL;
|
|
|
|
// Input to confirm all errors
|
|
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
|
|
VAR
|
|
_fbModule1 : FB_Module(CONCAT(_sName, 'Module 1'));
|
|
_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[// Reset error flag
|
|
xError := FALSE;
|
|
|
|
// ===============================
|
|
// Module 1
|
|
// ===============================
|
|
_fbModule1(
|
|
xEnable := xEnable,
|
|
xEmergencyStopOk:= xEmergencyStopOk,
|
|
stHMIInterface:= stHMIInterface.stHMIInterfaceModule1,
|
|
xReleaseErrors:= xReleaseErrors,
|
|
xReleaseLimitErrors:= xReleaseLimitErrors,
|
|
xConfirmAlarms:= xConfirmAlarms);
|
|
|
|
IF _fbModule1.xWarning THEN
|
|
xWarning := TRUE;
|
|
END_IF
|
|
|
|
IF _fbModule1.xError THEN
|
|
xError := TRUE;
|
|
END_IF
|
|
|
|
|
|
// ===============================
|
|
// Module 2
|
|
// ===============================
|
|
_fbModule2(
|
|
xEnable := xEnable,
|
|
xEmergencyStopOk:= xEmergencyStopOk,
|
|
stHMIInterface:= stHMIInterface.stHMIInterfaceModule2,
|
|
xReleaseErrors:= xReleaseErrors,
|
|
xReleaseLimitErrors:= xReleaseLimitErrors,
|
|
xConfirmAlarms:= xConfirmAlarms);
|
|
|
|
IF _fbModule2.xWarning THEN
|
|
xWarning := TRUE;
|
|
END_IF
|
|
|
|
IF _fbModule2.xError THEN
|
|
xError := TRUE;
|
|
END_IF
|
|
|
|
|
|
// ===============================
|
|
// Module 3
|
|
// ===============================
|
|
_fbModule3(
|
|
xEnable := xEnable,
|
|
xEmergencyStopOk:= xEmergencyStopOk,
|
|
stHMIInterface:= stHMIInterface.stHMIInterfaceModule3,
|
|
xReleaseErrors:= xReleaseErrors,
|
|
xReleaseLimitErrors:= xReleaseLimitErrors,
|
|
xConfirmAlarms:= xConfirmAlarms);
|
|
|
|
IF _fbModule3.xWarning THEN
|
|
xWarning := TRUE;
|
|
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}">
|
|
<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_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="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" />
|
|
<LineId Id="64" Count="0" />
|
|
<LineId Id="66" Count="0" />
|
|
<LineId Id="63" Count="0" />
|
|
<LineId Id="59" Count="2" />
|
|
<LineId Id="71" Count="5" />
|
|
<LineId Id="141" Count="0" />
|
|
<LineId Id="77" Count="11" />
|
|
<LineId Id="70" Count="0" />
|
|
<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" />
|
|
</LineIds>
|
|
</POU>
|
|
</TcPlcObject> |