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

@@ -32,7 +32,16 @@ VAR_INPUT
END_VAR
VAR_OUTPUT
// Unit ready
xReady : BOOL;
xReady : BOOL;
// Unit completely off
xOff : BOOL := TRUE;
// Unit can be discharged during shutdown sequence
xShutdownDischargeAllowed : BOOL;
// Unit in shutdown segment discharge mode
xInShutdownDischargeMode : BOOL;
// Error active
xError : BOOL;
@@ -42,6 +51,9 @@ VAR_OUTPUT
// Warning confirmation still pending
_xWarningConfirmPending : BOOL;
// Current Unit voltage
rCurrentVoltage : REAL;
END_VAR
VAR
// Check unit condition after some time during startup
@@ -81,26 +93,26 @@ VAR
_stPosolytValveTankOutletPIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0000;
_stPosolytValveTankOutletSIntlk : T_INTERLOCK;
_stPosolytValveTankOutletSIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0011;
_stPosolytValveTankOutletSIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0001;
// Valve negolyt tank outlet interlocks
_stNegolytValveTankOutletPIntlk : T_INTERLOCK;
_stNegolytValveTankOutletPIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0000;
_stNegolytValveTankOutletSIntlk : T_INTERLOCK;
_stNegolytValveTankOutletSIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0011;
_stNegolytValveTankOutletSIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0001;
// Pump posolyt inlet interlocks
_stPosolytPumpInletPIntlk : T_INTERLOCK;
_stPosolytPumpInletPIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0001;
_stPosolytPumpInletSIntlk : T_INTERLOCK;
_stPosolytPumpInletSIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0011;
_stPosolytPumpInletSIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0001;
// Pump negolyt inlet interlocks
_stNegolytPumpInletPIntlk : T_INTERLOCK;
_stNegolytPumpInletPIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0001;
_stNegolytPumpInletSIntlk : T_INTERLOCK;
_stNegolytPumpInletSIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0011;
_stNegolytPumpInletSIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0001;
// Error active
_xErrorActive : BOOL;
@@ -108,6 +120,9 @@ VAR
// Warning active
_xWarningActive : BOOL;
// Shutdown discharge allowed voltage
_rShutdownDischargeVoltageThreshold : REAL;
// Current state
_iState: INT;
@@ -122,6 +137,12 @@ VAR
// Unit startup check timer
_tonStartupCheck : TON;
// Enable voltage limit checks
_xEnableVoltageLimitChecks : BOOL;
// Manual mode allowed flag
_xReleaseManualMode : BOOL;
END_VAR
]]></Declaration>
<Implementation>
@@ -141,7 +162,7 @@ _stPosolytValveTankOutletSIntlk.0 := xEmergencyStopOk;
// Valve fb
_fbPosolytValveTankOutlet(
xReleaseManualMode:= TRUE,
xReleaseManualMode:= _xReleaseManualMode,
wProcessINTLK:= _stPosolytValveTankOutletPIntlk,
wProcessINTLKUsed:= _stPosolytValveTankOutletPIntlkUsed,
wSafetyINTLK:= _stPosolytValveTankOutletSIntlk,
@@ -167,7 +188,7 @@ _stNegolytValveTankOutletSIntlk.0 := xEmergencyStopOk;
// Valve fb
_fbNegolytValveTankOutlet(
xReleaseManualMode:= TRUE,
xReleaseManualMode:= _xReleaseManualMode,
wProcessINTLK:= _stNegolytValveTankOutletPIntlk,
wProcessINTLKUsed:= _stNegolytValveTankOutletPIntlkUsed,
wSafetyINTLK:= _stNegolytValveTankOutletSIntlk,
@@ -198,7 +219,7 @@ _stPosolytPumpInletPIntlk.0 := _fbPosolytValveTankOutlet.IsOpen;
// Valve fb
_fbPosolytPumpInlet(
xReleaseManualMode:= TRUE,
xReleaseManualMode:= _xReleaseManualMode,
wProcessINTLK:= _stPosolytPumpInletPIntlk,
wProcessINTLKUsed:= _stPosolytPumpInletPIntlkUsed,
wSafetyINTLK:= _stPosolytPumpInletSIntlk,
@@ -237,7 +258,7 @@ _stNegolytPumpInletPIntlk.0 := _fbNegolytValveTankOutlet.IsOpen;
// Valve fb
_fbNegolytPumpInlet(
xReleaseManualMode:= TRUE,
xReleaseManualMode:= _xReleaseManualMode,
wProcessINTLK:= _stNegolytPumpInletPIntlk,
wProcessINTLKUsed:= _stNegolytPumpInletPIntlkUsed,
wSafetyINTLK:= _stNegolytPumpInletSIntlk,
@@ -262,14 +283,14 @@ END_IF
// ===============================
// Pressure sensors posolyt segment inlet
// Pressure sensor posolyt segment inlet
// ===============================
_fbPressurePosolytSegmentInlet(
stScalingConfig:= stUnitConfig.stConfigPosolytPressureSegmentInlet,
stEWConfig:= stUnitConfig.stEWLPosolytPressureSegmentInlet,
stEWDelayConfig:= stUnitConfig.stEWDPosolytPressureSegmentInlet,
xReleaseErrors:= xReleaseErrors,
xReleaseLimitErrors:= xReleaseLimitErrors,
xReleaseLimitErrors:= xReleaseLimitErrors AND _fbPosolytPumpInlet.IsRunning AND _fbPosolytPumpInlet.xInTarget,
xReleaseHardwareErrors:= xReleaseErrors,
xConfirmAlarms:= xConfirmAlarms,
stHMIInterface => stHMIInterface.stPosolytPressureSegmentInlet);
@@ -293,7 +314,7 @@ _fbPressureNegolytSegmentInlet(
stEWConfig:= stUnitConfig.stEWLNegolytPressureSegmentInlet,
stEWDelayConfig:= stUnitConfig.stEWDNegolytPressureSegmentInlet,
xReleaseErrors:= xReleaseErrors,
xReleaseLimitErrors:= xReleaseLimitErrors,
xReleaseLimitErrors:= xReleaseLimitErrors AND _fbNegolytPumpInlet.IsRunning AND _fbNegolytPumpInlet.xInTarget,
xReleaseHardwareErrors:= xReleaseErrors,
xConfirmAlarms:= xConfirmAlarms,
stHMIInterface => stHMIInterface.stNegolytPressureSegmentInlet);
@@ -310,17 +331,107 @@ END_IF
// ===============================
// Voltage segment
// Pressure sensors posolyt tank inlet
// ===============================
_fbVoltageSegment(
stScalingConfig:= ,
stEWConfig:= ,
stEWDelayConfig:= ,
_fbPressurePosolytTankInlet(
stScalingConfig:= stUnitConfig.stConfigPosolytPressureTankInlet,
stEWConfig:= stUnitConfig.stEWLPosolytPressureTankInlet,
stEWDelayConfig:= stUnitConfig.stEWDPosolytPressureTankInlet,
xReleaseErrors:= xReleaseErrors,
xReleaseLimitErrors:= xReleaseLimitErrors AND _fbPosolytPumpInlet.IsRunning AND _fbPosolytPumpInlet.xInTarget,
xReleaseHardwareErrors:= xReleaseErrors,
xConfirmAlarms:= xConfirmAlarms,
stHMIInterface => stHMIInterface.stPosolytPressureTankInlet);
// Set error active if fb has error
IF _fbPressurePosolytTankInlet.xError THEN
_xErrorActive := TRUE;
END_IF
// Set warning if fb has warning
IF _fbPressurePosolytTankInlet.xWarning THEN
_xWarningActive := TRUE;
END_IF
// ===============================
// Pressure sensors negolyt tank inlet
// ===============================
_fbPressureNegolytTankInlet(
stScalingConfig:= stUnitConfig.stConfigNegolytPressureTankInlet,
stEWConfig:= stUnitConfig.stEWLNegolytPressureTankInlet,
stEWDelayConfig:= stUnitConfig.stEWDNegolytPressureTankInlet,
xReleaseErrors:= xReleaseErrors,
xReleaseLimitErrors:= xReleaseLimitErrors AND _fbNegolytPumpInlet.IsRunning AND _fbNegolytPumpInlet.xInTarget,
xReleaseHardwareErrors:= xReleaseErrors,
xConfirmAlarms:= xConfirmAlarms,
stHMIInterface => stHMIInterface.stNegolytPressureTankInlet);
// Set error active if fb has error
IF _fbPressureNegolytTankInlet.xError THEN
_xErrorActive := TRUE;
END_IF
// Set warning if fb has warning
IF _fbPressureNegolytTankInlet.xWarning THEN
_xWarningActive := TRUE;
END_IF
// ===============================
// Temperature sensor posolyt tank inlet
// ===============================
_fbTempSensorPosolyt(
stScalingConfig:= stUnitConfig.stConfigPosolytTempTankInlet,
stEWConfig:= GVL_CONFIG.stUnitConfig.stEWLPosolytTempTankInlet,
stEWDelayConfig:= GVL_CONFIG.stUnitConfig.stEWDPosolytTempTankInlet,
xReleaseErrors:= xReleaseErrors,
xReleaseLimitErrors:= xReleaseLimitErrors,
xReleaseHardwareErrors:= xReleaseErrors,
xConfirmAlarms:= xConfirmAlarms,
stHMIInterface=> stHMIInterface.stVoltageSegment);
stHMIInterface=> stHMIInterface.stPosolytTempTankInlet);
IF _fbTempSensorPosolyt.xError THEN
_xErrorActive := TRUE;
END_IF
IF _fbTempSensorPosolyt.xWarning THEN
_xWarningActive := TRUE;
END_IF
// ===============================
// Temperature sensor negolyt tank inlet
// ===============================
_fbTempSensorNegolyt(
stScalingConfig:= stUnitConfig.stConfigNegolytTempTankInlet,
stEWConfig:= GVL_CONFIG.stUnitConfig.stEWLNegolytTempTankInlet,
stEWDelayConfig:= GVL_CONFIG.stUnitConfig.stEWDNegolytTempTankInlet,
xReleaseErrors:= xReleaseErrors,
xReleaseLimitErrors:= xReleaseLimitErrors,
xReleaseHardwareErrors:= xReleaseErrors,
xConfirmAlarms:= xConfirmAlarms,
stHMIInterface=> stHMIInterface.stNegolytTempTankInlet);
IF _fbTempSensorNegolyt.xError THEN
_xErrorActive := TRUE;
END_IF
IF _fbTempSensorNegolyt.xWarning THEN
_xWarningActive := TRUE;
END_IF
// ===============================
// Voltage segment
// ===============================
_fbVoltageSegment(
stScalingConfig:= GVL_CONFIG.stUnitConfig.stConfigVoltageSegment,
stEWConfig:= GVL_CONFIG.stUnitConfig.stEWLVoltageSegment,
stEWDelayConfig:= GVL_CONFIG.stUnitConfig.stEWDVoltageSegment,
xReleaseErrors:= xReleaseErrors,
xReleaseLimitErrors:= xReleaseLimitErrors AND _xEnableVoltageLimitChecks,
xReleaseHardwareErrors:= xReleaseErrors,
xConfirmAlarms:= xConfirmAlarms,
stHMIInterface=> stHMIInterface.stVoltageSegment,
rScaledValue => rCurrentVoltage);
// Set error active if fb has error
IF _fbVoltageSegment.xError THEN
@@ -351,30 +462,36 @@ IF _fbNotAllAutomaticAlarm.bRaised AND _xAllComponentsInAutomatic THEN
_fbNotAllAutomaticAlarm.Clear(0, TRUE);
END_IF
// Calculate shutdown discharge threshold
_rShutdownDischargeVoltageThreshold := GVL_CONFIG.rMinimumUnitVoltage + GVL_CONFIG.rDeltaUnitVoltageShutdownDischarge;
// ===============================
// Run state machine for startup and shutdown
// ===============================
CASE _iState OF
0: // Off
IF xEnable AND _xAllComponentsInAutomatic AND (NOT _xErrorActive) THEN
_xReleaseManualMode := FALSE;
_iState := 10;
END_IF
10: // Open all valves
_fbPosolytValveTankOutlet.ReqAutomaticOpen();
_fbNegolytValveTankOutlet.ReqAutomaticOpen();
xOff := FALSE;
_iState := 15;
15: // Wait for all valves to be open
IF _fbPosolytValveTankOutlet.IsOpen AND _fbNegolytValveTankOutlet.IsOpen THEN
IF NOT _fbPosolytValveTankOutlet.xError AND _fbNegolytValveTankOutlet.xError THEN
IF (NOT _fbPosolytValveTankOutlet.xError) AND (NOT _fbNegolytValveTankOutlet.xError) THEN
_iState := 20;
END_IF
END_IF
// If enable signal is lost, or there is an error, goto shutdown
IF (NOT xEnable) OR _xErrorActive THEN
_iState := 40;
_xReleaseManualMode := TRUE;
_iState := 1000;
END_IF
20: // Start pumps
@@ -397,11 +514,13 @@ CASE _iState OF
// After some time, check if all values are ok
IF _tonStartupCheck.Q THEN
_tonStartupCheck(In := FALSE);
// Check for minimum unit voltage
IF _fbVoltageSegment.rScaledValue >= GVL_CONFIG.rMinimumUnitVoltage AND
NOT _xErrorActive AND
NOT _xWarningActive THEN
IF (_fbVoltageSegment.rScaledValue >= GVL_CONFIG.rMinimumUnitVoltage)
AND NOT _xErrorActive
AND NOT _xWarningActive THEN
xReady := TRUE;
_xEnableVoltageLimitChecks := TRUE;
_iState := 35;
ELSE
_iState := 40;
@@ -414,9 +533,15 @@ CASE _iState OF
END_IF
35: // Unit in enabled state
IF (NOT xEnable) OR _xErrorActive THEN
IF (NOT xEnable) AND NOT _xErrorActive THEN
_xEnableVoltageLimitChecks := FALSE;
_iState := 40;
END_IF
// Goto error shutdown if an error occured
IF _xErrorActive THEN
_iState := 1000;
END_IF
40: // Close all valves
_fbNegolytValveTankOutlet.ReqAutomaticClose();
@@ -425,6 +550,7 @@ CASE _iState OF
45: // Wait for valves to be closed
IF _fbNegolytValveTankOutlet.IsClosed AND _fbPosolytValveTankOutlet.IsClosed THEN
xInShutdownDischargeMode := TRUE;
_iState := 50;
END_IF
@@ -440,12 +566,22 @@ CASE _iState OF
END_IF
50: // Wait for unit voltage to drop below a certain threshold
IF (_fbVoltageSegment.rScaledValue > _rShutdownDischargeVoltageThreshold) THEN
xShutdownDischargeAllowed := TRUE;
ELSE
xShutdownDischargeAllowed := FALSE;
END_IF
IF (_fbVoltageSegment.rScaledValue <= GVL_CONFIG.rPumpshutoffThreshold) THEN
xShutdownDischargeAllowed := FALSE;
xInShutdownDischargeMode := FALSE;
_iState := 60;
END_IF
// Check for restart condition
IF xEnable AND (NOT _xErrorActive) THEN
xShutdownDischargeAllowed := FALSE;
xInShutdownDischargeMode := FALSE;
_iState := 0;
END_IF
@@ -456,10 +592,10 @@ CASE _iState OF
65: // Wait for pumps to be stopped
IF _fbPosolytPumpInlet.IsStopped AND _fbNegolytPumpInlet.IsStopped THEN
IF _xErrorActive THEN
xOff := TRUE;
_xReleaseManualMode := TRUE;
IF NOT _xErrorActive THEN
_iState := 1000;
ELSE
_iState := 0;
END_IF
END_IF
@@ -467,8 +603,25 @@ CASE _iState OF
IF xEnable AND (NOT _xErrorActive) THEN
_iState := 0;
END_IF
// Check for error
IF _xErrorActive THEN
_iState := 1000;
END_IF
1000: // Alarm active
1000: // Error shutdown
_fbNegolytValveTankOutlet.ReqAutomaticClose();
_fbPosolytValveTankOutlet.ReqAutomaticClose();
_fbPosolytPumpInlet.ReqAutomaticStop();
_fbNegolytPumpInlet.ReqAutomaticStop();
_xEnableVoltageLimitChecks := FALSE;
xShutdownDischargeAllowed := FALSE;
xInShutdownDischargeMode := FALSE;
xReady := FALSE;
xOff := TRUE;
_iState := 1001;
1001: // Alarm active
// Only allow reset when enable is deactivated to avoid an
// automatic restart of the unit
IF (NOT _xErrorActive) AND (NOT xEnable) THEN
@@ -505,29 +658,107 @@ _fbNotAllAutomaticAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
<LineId Id="4263" Count="102" />
<LineId Id="4619" Count="0" />
<LineId Id="4367" Count="46" />
<LineId Id="4621" Count="22" />
<LineId Id="5099" Count="0" />
<LineId Id="5101" Count="2" />
<LineId Id="5095" Count="0" />
<LineId Id="5124" Count="17" />
<LineId Id="5104" Count="1" />
<LineId Id="5096" Count="2" />
<LineId Id="5094" Count="0" />
<LineId Id="5106" Count="17" />
<LineId Id="4621" Count="0" />
<LineId Id="5143" Count="2" />
<LineId Id="5142" Count="0" />
<LineId Id="5151" Count="0" />
<LineId Id="5153" Count="2" />
<LineId Id="5159" Count="3" />
<LineId Id="5150" Count="0" />
<LineId Id="5190" Count="3" />
<LineId Id="5195" Count="0" />
<LineId Id="5194" Count="0" />
<LineId Id="5196" Count="1" />
<LineId Id="5147" Count="2" />
<LineId Id="5146" Count="0" />
<LineId Id="5198" Count="15" />
<LineId Id="5170" Count="0" />
<LineId Id="4622" Count="12" />
<LineId Id="4937" Count="0" />
<LineId Id="4635" Count="8" />
<LineId Id="4620" Count="0" />
<LineId Id="4644" Count="1" />
<LineId Id="4414" Count="0" />
<LineId Id="4647" Count="0" />
<LineId Id="4646" Count="0" />
<LineId Id="4416" Count="17" />
<LineId Id="4444" Count="26" />
<LineId Id="4476" Count="33" />
<LineId Id="4511" Count="17" />
<LineId Id="4416" Count="13" />
<LineId Id="5234" Count="0" />
<LineId Id="5233" Count="0" />
<LineId Id="5235" Count="0" />
<LineId Id="4430" Count="3" />
<LineId Id="4444" Count="2" />
<LineId Id="4941" Count="0" />
<LineId Id="4447" Count="5" />
<LineId Id="5249" Count="0" />
<LineId Id="4453" Count="10" />
<LineId Id="5076" Count="0" />
<LineId Id="4464" Count="6" />
<LineId Id="4476" Count="15" />
<LineId Id="4790" Count="0" />
<LineId Id="4492" Count="1" />
<LineId Id="4926" Count="1" />
<LineId Id="4496" Count="0" />
<LineId Id="4794" Count="0" />
<LineId Id="4497" Count="12" />
<LineId Id="4795" Count="0" />
<LineId Id="4511" Count="1" />
<LineId Id="5078" Count="0" />
<LineId Id="5083" Count="0" />
<LineId Id="5079" Count="0" />
<LineId Id="5082" Count="0" />
<LineId Id="5081" Count="0" />
<LineId Id="4513" Count="7" />
<LineId Id="5239" Count="0" />
<LineId Id="4521" Count="7" />
<LineId Id="4653" Count="0" />
<LineId Id="4655" Count="2" />
<LineId Id="4654" Count="0" />
<LineId Id="4529" Count="4" />
<LineId Id="4529" Count="1" />
<LineId Id="5220" Count="0" />
<LineId Id="5223" Count="0" />
<LineId Id="5225" Count="1" />
<LineId Id="5224" Count="0" />
<LineId Id="5221" Count="0" />
<LineId Id="4531" Count="0" />
<LineId Id="5228" Count="0" />
<LineId Id="5242" Count="0" />
<LineId Id="4532" Count="1" />
<LineId Id="4658" Count="0" />
<LineId Id="4660" Count="2" />
<LineId Id="4660" Count="1" />
<LineId Id="5229" Count="0" />
<LineId Id="5243" Count="0" />
<LineId Id="4662" Count="0" />
<LineId Id="4659" Count="0" />
<LineId Id="4569" Count="0" />
<LineId Id="4535" Count="12" />
<LineId Id="4535" Count="6" />
<LineId Id="5251" Count="0" />
<LineId Id="4944" Count="0" />
<LineId Id="4542" Count="1" />
<LineId Id="4546" Count="1" />
<LineId Id="4663" Count="0" />
<LineId Id="4665" Count="2" />
<LineId Id="4664" Count="0" />
<LineId Id="4548" Count="6" />
<LineId Id="5252" Count="4" />
<LineId Id="4548" Count="0" />
<LineId Id="5084" Count="0" />
<LineId Id="5086" Count="1" />
<LineId Id="5089" Count="1" />
<LineId Id="5093" Count="0" />
<LineId Id="5227" Count="0" />
<LineId Id="5240" Count="0" />
<LineId Id="5092" Count="0" />
<LineId Id="5258" Count="0" />
<LineId Id="5091" Count="0" />
<LineId Id="5085" Count="0" />
<LineId Id="4549" Count="5" />
<LineId Id="4556" Count="6" />
<LineId Id="2754" Count="0" />
</LineIds>