858 lines
26 KiB
XML
858 lines
26 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
|
|
<POU Name="FB_Unit" Id="{e9bb815b-eb46-4920-800d-910484e58b22}" SpecialFunc="None">
|
|
<Declaration><![CDATA[FUNCTION_BLOCK FB_Unit
|
|
VAR_INPUT
|
|
// Unit configuration
|
|
stUnitConfig : REFERENCE TO ST_UNIT_CONFIG;
|
|
|
|
// HMI interface
|
|
stHMIInterface : REFERENCE TO ST_UNIT_HMI_INTERFACE;
|
|
|
|
// Start unit
|
|
xEnable : BOOL;
|
|
|
|
// Emergency stop ok
|
|
xEmergencyStopOk : BOOL;
|
|
|
|
// Setpoint posolyt pump inlet
|
|
rSetpointPosolytPumpInlet : REAL;
|
|
|
|
// Setpoint negolyt pump inlet
|
|
rSetpointNegolytPumpInlet : REAL;
|
|
|
|
// Release alarms
|
|
xReleaseErrors : BOOL;
|
|
|
|
// Release analog io limit errors
|
|
xReleaseLimitErrors : BOOL;
|
|
|
|
// Release manual mode
|
|
xReleaseManualMode : BOOL;
|
|
|
|
// Input to confirm all errors
|
|
xConfirmAlarms : BOOL;
|
|
END_VAR
|
|
VAR_OUTPUT
|
|
// Unit ready
|
|
xReady : BOOL;
|
|
|
|
// Unit completely off
|
|
xOff : BOOL := TRUE;
|
|
|
|
// All safetyinterlocks are ok
|
|
xSafetyIntlksOk : BOOL;
|
|
|
|
// Unit can be discharged during shutdown sequence
|
|
xShutdownDischargeAllowed : BOOL;
|
|
|
|
// Unit in shutdown segment discharge mode
|
|
xInShutdownDischargeMode : BOOL;
|
|
|
|
// Error active
|
|
xError : BOOL;
|
|
|
|
// Warning active
|
|
xWarning : BOOL;
|
|
|
|
// Warning confirmation still pending
|
|
_xWarningConfirmPending : BOOL;
|
|
|
|
// Current Unit voltage
|
|
rCurrentVoltage : REAL;
|
|
END_VAR
|
|
VAR
|
|
// Check unit condition after some time during startup
|
|
// _timUnitStartupWaitTime : TIME := T#10S;
|
|
|
|
// Valves posolyt
|
|
_fbPosolytValveTankOutlet : FB_Valve('Posolyt tank outlet');
|
|
|
|
// Valves negolyt
|
|
_fbNegolytValveTankOutlet : FB_Valve('Negolyt tank outlet');
|
|
|
|
// Pumps posolyt
|
|
_fbPosolytPumpInlet : FB_MotorAnalog('Posolyt segment inlet');
|
|
|
|
// Pumps negolyt
|
|
_fbNegolytPumpInlet : FB_MotorAnalog('Negolyt segment inlet');
|
|
|
|
// Pressure sensors posolyt
|
|
_fbPressurePosolytSegmentInlet : FB_AnalogInput('P1_P');
|
|
_fbPressurePosolytTankInlet : FB_AnalogInput('P3_P');
|
|
|
|
// Pressure sensors negolyt
|
|
_fbPressureNegolytSegmentInlet : FB_AnalogInput('P1_N');
|
|
_fbPressureNegolytTankInlet : FB_AnalogInput('P3_N');
|
|
|
|
// Temperature sensor posolyt
|
|
_fbTempSensorPosolyt : FB_AnalogInput('T1_P');
|
|
|
|
// Temperature sensor negolyt
|
|
_fbTempSensorNegolyt : FB_AnalogInput('T1_N');
|
|
|
|
// Unit voltage
|
|
_fbVoltageSegment : FB_AnalogInput('Voltage');
|
|
|
|
// Valve posolyt tank outlet interlocks
|
|
_stPosolytValveTankOutletPIntlk : T_INTERLOCK;
|
|
_stPosolytValveTankOutletPIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0000;
|
|
|
|
_stPosolytValveTankOutletSIntlk : T_INTERLOCK;
|
|
_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_0001;
|
|
|
|
// Pump posolyt inlet interlocks
|
|
_stPosolytPumpInletPIntlk : T_INTERLOCK;
|
|
_stPosolytPumpInletPIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0000;
|
|
_stPosolytPumpInletSIntlk : T_INTERLOCK;
|
|
_stPosolytPumpInletSIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0001;
|
|
|
|
// Pump negolyt inlet interlocks
|
|
_stNegolytPumpInletPIntlk : T_INTERLOCK;
|
|
_stNegolytPumpInletPIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0000;
|
|
_stNegolytPumpInletSIntlk : T_INTERLOCK;
|
|
_stNegolytPumpInletSIntlkUsed : T_INTERLOCK := 2#0000_0000_0000_0001;
|
|
|
|
// Error active
|
|
_xErrorActive : BOOL;
|
|
|
|
// Warning active
|
|
_xWarningActive : BOOL;
|
|
|
|
// Shutdown discharge allowed voltage
|
|
_rShutdownDischargeVoltageThreshold : REAL;
|
|
|
|
// Current state
|
|
_iState: INT;
|
|
|
|
// All components in automatic mode
|
|
_xAllComponentsInAutomatic : BOOL;
|
|
|
|
// Not all components in automatic mode alarm
|
|
_fbNotAllAutomaticAlarm : FB_TcAlarm;
|
|
|
|
// Unit name
|
|
_sName : STRING;
|
|
|
|
// Unit startup check timer
|
|
_tonStartupCheck : TON;
|
|
|
|
// Enable voltage limit checks
|
|
_xEnableVoltageLimitChecks : BOOL;
|
|
|
|
// Manual mode allowed flag
|
|
_xReleaseManualMode : BOOL;
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[// Reset error active
|
|
_xErrorActive := FALSE;
|
|
|
|
// Reset warning active
|
|
_xWarningActive := FALSE;
|
|
|
|
// Reset safety interlocks flag
|
|
xSafetyIntlksOk := TRUE;
|
|
|
|
// Copy release manual mode
|
|
_xReleaseManualMode := xReleaseManualMode;
|
|
|
|
// ===============================
|
|
// Valve posolyt tank outlet
|
|
// ===============================
|
|
|
|
// Safety Interlocks
|
|
stHMIInterface.stPosolytValve.stInterlock.asSafetyINTLKName[0] := 'Emergency stop ok';
|
|
_stPosolytValveTankOutletSIntlk.0 := xEmergencyStopOk;
|
|
|
|
// Valve fb
|
|
_fbPosolytValveTankOutlet(
|
|
xReleaseManualMode:= _xReleaseManualMode,
|
|
wProcessINTLK:= _stPosolytValveTankOutletPIntlk,
|
|
wProcessINTLKUsed:= _stPosolytValveTankOutletPIntlkUsed,
|
|
wSafetyINTLK:= _stPosolytValveTankOutletSIntlk,
|
|
wSafetyINTLKUsed:= _stPosolytValveTankOutletSIntlkUsed,
|
|
xConfirmAlarms:= xConfirmAlarms,
|
|
xReleaseErrors:= xReleaseErrors,
|
|
stValveConfig:= stUnitConfig.stConfigPosolytValve,
|
|
stHMIInterface:= stHMIInterface.stPosolytValve);
|
|
|
|
// Set error active if fb has error
|
|
IF _fbPosolytValveTankOutlet.xError THEN
|
|
_xErrorActive := TRUE;
|
|
END_IF
|
|
|
|
// Set safety interlock flag if fb has safety interlocks active
|
|
IF NOT stHMIInterface.stPosolytValve.stInterlock.xSafetyINTLKOk THEN
|
|
xSafetyIntlksOk := FALSE;
|
|
END_IF
|
|
|
|
|
|
// ===============================
|
|
// Valve negolyt tank outlet
|
|
// ===============================
|
|
|
|
// Safety Interlocks
|
|
stHMIInterface.stNegolytValve.stInterlock.asSafetyINTLKName[0] := 'Emergency stop ok';
|
|
_stNegolytValveTankOutletSIntlk.0 := xEmergencyStopOk;
|
|
|
|
// Valve fb
|
|
_fbNegolytValveTankOutlet(
|
|
xReleaseManualMode:= _xReleaseManualMode,
|
|
wProcessINTLK:= _stNegolytValveTankOutletPIntlk,
|
|
wProcessINTLKUsed:= _stNegolytValveTankOutletPIntlkUsed,
|
|
wSafetyINTLK:= _stNegolytValveTankOutletSIntlk,
|
|
wSafetyINTLKUsed:= _stNegolytValveTankOutletSIntlkUsed,
|
|
xConfirmAlarms:= xConfirmAlarms,
|
|
xReleaseErrors:= xReleaseErrors,
|
|
stValveConfig:= stUnitConfig.stConfigNegolytValve,
|
|
stHMIInterface:= stHMIInterface.stNegolytValve);
|
|
|
|
// Set error active if fb has error
|
|
IF _fbNegolytValveTankOutlet.xError THEN
|
|
_xErrorActive := TRUE;
|
|
END_IF
|
|
|
|
// Set safety interlock flag if fb has safety interlocks active
|
|
IF NOT stHMIInterface.stNegolytValve.stInterlock.xSafetyINTLKOk THEN
|
|
xSafetyIntlksOk := FALSE;
|
|
END_IF
|
|
|
|
|
|
// ===============================
|
|
// Pump posolyt segment inlet
|
|
// ===============================
|
|
|
|
// Safety Interlocks
|
|
stHMIInterface.stPosolytPump.stInterlock.asSafetyINTLKName[0] := 'Emergency stop ok';
|
|
_stPosolytPumpInletSIntlk.0 := xEmergencyStopOk;
|
|
|
|
// Process interlocks
|
|
// stHMIInterface.stPosolytPump.stInterlock.asProcessINTLKName[0] := 'At least one valve is open';
|
|
//_stPosolytPumpInletPIntlk.0 := _fbPosolytValveTankOutlet.IsOpen;
|
|
|
|
|
|
// Valve fb
|
|
_fbPosolytPumpInlet(
|
|
xReleaseManualMode:= _xReleaseManualMode,
|
|
wProcessINTLK:= _stPosolytPumpInletPIntlk,
|
|
wProcessINTLKUsed:= _stPosolytPumpInletPIntlkUsed,
|
|
wSafetyINTLK:= _stPosolytPumpInletSIntlk,
|
|
wSafetyINTLKUsed:= _stPosolytPumpInletSIntlkUsed,
|
|
xReleaseErrors:= xReleaseErrors,
|
|
xConfirmAlarms:= xConfirmAlarms,
|
|
rSPautomatic:= rSetpointPosolytPumpInlet,
|
|
xReleaseAnalogInLimitErrors:= xReleaseLimitErrors,
|
|
stMotorAnalogConfig:= stUnitConfig.stConfigPosolytPump,
|
|
stHMIInterface:= stHMIInterface.stPosolytPump,
|
|
xWarning=> );
|
|
|
|
// Set error active if fb has error
|
|
IF _fbPosolytPumpInlet.xError THEN
|
|
_xErrorActive := TRUE;
|
|
END_IF
|
|
|
|
// Set warning if fb has warning
|
|
IF _fbPosolytPumpInlet.xWarning THEN
|
|
_xWarningActive := TRUE;
|
|
END_IF
|
|
|
|
// Set safety interlock flag if fb has safety interlocks active
|
|
IF NOT stHMIInterface.stPosolytPump.stInterlock.xSafetyINTLKOk THEN
|
|
xSafetyIntlksOk := FALSE;
|
|
END_IF
|
|
|
|
|
|
// ===============================
|
|
// Pump negolyt segment inlet
|
|
// ===============================
|
|
|
|
// Safety Interlocks
|
|
stHMIInterface.stNegolytPump.stInterlock.asSafetyINTLKName[0] := 'Emergency stop ok';
|
|
_stNegolytPumpInletSIntlk.0 := xEmergencyStopOk;
|
|
|
|
// Process interlocks
|
|
//stHMIInterface.stNegolytPump.stInterlock.asProcessINTLKName[0] := 'At least one valve is open';
|
|
//_stNegolytPumpInletPIntlk.0 := _fbNegolytValveTankOutlet.IsOpen;
|
|
|
|
|
|
// Valve fb
|
|
_fbNegolytPumpInlet(
|
|
xReleaseManualMode:= _xReleaseManualMode,
|
|
wProcessINTLK:= _stNegolytPumpInletPIntlk,
|
|
wProcessINTLKUsed:= _stNegolytPumpInletPIntlkUsed,
|
|
wSafetyINTLK:= _stNegolytPumpInletSIntlk,
|
|
wSafetyINTLKUsed:= _stNegolytPumpInletSIntlkUsed,
|
|
xReleaseErrors:= xReleaseErrors,
|
|
xConfirmAlarms:= xConfirmAlarms,
|
|
rSPautomatic:= rSetpointNegolytPumpInlet,
|
|
xReleaseAnalogInLimitErrors:= xReleaseLimitErrors,
|
|
stMotorAnalogConfig:= stUnitConfig.stConfigNegolytPump,
|
|
stHMIInterface:= stHMIInterface.stNegolytPump,
|
|
xWarning=> );
|
|
|
|
// Set error active if fb has error
|
|
IF _fbNegolytPumpInlet.xError THEN
|
|
_xErrorActive := TRUE;
|
|
END_IF
|
|
|
|
// Set warning if fb has warning
|
|
IF _fbNegolytPumpInlet.xWarning THEN
|
|
_xWarningActive := TRUE;
|
|
END_IF
|
|
|
|
// Set safety interlock flag if fb has safety interlocks active
|
|
IF NOT stHMIInterface.stNegolytPump.stInterlock.xSafetyINTLKOk THEN
|
|
xSafetyIntlksOk := FALSE;
|
|
END_IF
|
|
|
|
|
|
// ===============================
|
|
// Pressure sensor posolyt segment inlet
|
|
// ===============================
|
|
_fbPressurePosolytSegmentInlet(
|
|
stScalingConfig:= stUnitConfig.stConfigPosolytPressureSegmentInlet,
|
|
stEWConfig:= stUnitConfig.stEWLPosolytPressureSegmentInlet,
|
|
stEWDelayConfig:= stUnitConfig.stEWDPosolytPressureSegmentInlet,
|
|
xReleaseErrors:= xReleaseErrors,
|
|
xReleaseLimitErrors:= xReleaseLimitErrors AND _fbPosolytPumpInlet.IsRunning AND _fbPosolytPumpInlet.xInTarget,
|
|
xReleaseHardwareErrors:= xReleaseErrors,
|
|
xConfirmAlarms:= xConfirmAlarms,
|
|
stHMIInterface => stHMIInterface.stPosolytPressureSegmentInlet);
|
|
|
|
// Set error active if fb has error
|
|
IF _fbPressurePosolytSegmentInlet.xError THEN
|
|
_xErrorActive := TRUE;
|
|
END_IF
|
|
|
|
// Set warning if fb has warning
|
|
IF _fbPressurePosolytSegmentInlet.xWarning THEN
|
|
_xWarningActive := TRUE;
|
|
END_IF
|
|
|
|
|
|
// ===============================
|
|
// Pressure sensors negolyt segment inlet
|
|
// ===============================
|
|
_fbPressureNegolytSegmentInlet(
|
|
stScalingConfig:= stUnitConfig.stConfigNegolytPressureSegmentInlet,
|
|
stEWConfig:= stUnitConfig.stEWLNegolytPressureSegmentInlet,
|
|
stEWDelayConfig:= stUnitConfig.stEWDNegolytPressureSegmentInlet,
|
|
xReleaseErrors:= xReleaseErrors,
|
|
xReleaseLimitErrors:= xReleaseLimitErrors AND _fbNegolytPumpInlet.IsRunning AND _fbNegolytPumpInlet.xInTarget,
|
|
xReleaseHardwareErrors:= xReleaseErrors,
|
|
xConfirmAlarms:= xConfirmAlarms,
|
|
stHMIInterface => stHMIInterface.stNegolytPressureSegmentInlet);
|
|
|
|
// Set error active if fb has error
|
|
IF _fbPressureNegolytSegmentInlet.xError THEN
|
|
_xErrorActive := TRUE;
|
|
END_IF
|
|
|
|
// Set warning if fb has warning
|
|
IF _fbPressureNegolytSegmentInlet.xWarning THEN
|
|
_xWarningActive := TRUE;
|
|
END_IF
|
|
|
|
|
|
// ===============================
|
|
// Pressure sensors posolyt tank inlet
|
|
// ===============================
|
|
_fbPressurePosolytTankInlet(
|
|
stScalingConfig:= stUnitConfig.stConfigPosolytPressureTankInlet,
|
|
stEWConfig:= stUnitConfig.stEWLPosolytPressureTankInlet,
|
|
stEWDelayConfig:= stUnitConfig.stEWDPosolytPressureTankInlet,
|
|
xReleaseErrors:= xReleaseErrors,
|
|
xReleaseLimitErrors:= xReleaseLimitErrors,
|
|
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,
|
|
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.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
|
|
_xErrorActive := TRUE;
|
|
END_IF
|
|
|
|
// Set warning if fb has warning
|
|
IF _fbVoltageSegment.xWarning THEN
|
|
_xWarningActive := TRUE;
|
|
END_IF
|
|
|
|
|
|
// ===============================
|
|
// Check if all components are in automatic
|
|
// ===============================
|
|
_xAllComponentsInAutomatic := _fbPosolytValveTankOutlet.IsInAutomaticMode
|
|
AND _fbNegolytValveTankOutlet.IsInAutomaticMode
|
|
AND _fbPosolytPumpInlet.IsInAutomaticMode
|
|
AND _fbNegolytPumpInlet.IsInAutomaticMode;
|
|
|
|
// Raise warning
|
|
IF NOT _fbNotAllAutomaticAlarm.bRaised AND (NOT _xAllComponentsInAutomatic) THEN
|
|
_fbNotAllAutomaticAlarm.Raise(0);
|
|
END_IF
|
|
|
|
// Clear warning and reset
|
|
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 (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
|
|
_xReleaseManualMode := TRUE;
|
|
_iState := 1000;
|
|
END_IF
|
|
|
|
20: // Start pumps
|
|
_fbPosolytPumpInlet.ReqAutomaticStart();
|
|
_fbNegolytPumpInlet.ReqAutomaticStart();
|
|
_iState := 25;
|
|
|
|
25: // Wait for all pumps to run
|
|
IF _fbPosolytPumpInlet.xInTarget AND _fbNegolytPumpInlet.xInTarget THEN
|
|
_iState := 30;
|
|
END_IF
|
|
|
|
// If enable signal is lost, goto shutdown
|
|
IF (NOT xEnable) OR _xErrorActive THEN
|
|
_iState := 40;
|
|
END_IF
|
|
|
|
30: // Wait some time
|
|
_tonStartupCheck(In := TRUE, PT := GVL_CONFIG.timUnitStartupTime);
|
|
|
|
// 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
|
|
xReady := TRUE;
|
|
_xEnableVoltageLimitChecks := TRUE;
|
|
_iState := 35;
|
|
ELSE
|
|
_iState := 40;
|
|
END_IF
|
|
END_IF
|
|
|
|
// If enable signal is lost, goto shutdown
|
|
IF (NOT xEnable) OR _xErrorActive THEN
|
|
_iState := 40;
|
|
END_IF
|
|
|
|
35: // Unit in enabled state
|
|
IF (NOT xEnable) AND NOT _xErrorActive THEN
|
|
_iState := 40;
|
|
END_IF
|
|
|
|
// Goto error shutdown if an error occured
|
|
IF _xErrorActive THEN
|
|
_iState := 1000;
|
|
END_IF
|
|
|
|
40: // Close all valves
|
|
_fbNegolytValveTankOutlet.ReqAutomaticClose();
|
|
_fbPosolytValveTankOutlet.ReqAutomaticClose();
|
|
_iState := 45;
|
|
|
|
45: // Wait for valves to be closed
|
|
IF _fbNegolytValveTankOutlet.IsClosed AND _fbPosolytValveTankOutlet.IsClosed THEN
|
|
xInShutdownDischargeMode := TRUE;
|
|
_iState := 50;
|
|
END_IF
|
|
|
|
// When there is an error trying to close the valves,
|
|
// dont try to discharge the segment
|
|
IF _fbNegolytValveTankOutlet.xError OR _fbPosolytValveTankOutlet.xError THEN
|
|
_xEnableVoltageLimitChecks := FALSE;
|
|
_iState := 60;
|
|
END_IF
|
|
|
|
// Check for restart condition
|
|
IF xEnable AND (NOT _xErrorActive) THEN
|
|
_iState := 0;
|
|
END_IF
|
|
|
|
50: // Wait for unit voltage to drop below a certain threshold
|
|
IF (_fbVoltageSegment.rScaledValue > _rShutdownDischargeVoltageThreshold) THEN
|
|
xShutdownDischargeAllowed := TRUE;
|
|
ELSE
|
|
xShutdownDischargeAllowed := FALSE;
|
|
_xEnableVoltageLimitChecks := 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
|
|
|
|
60: // Disable pumps
|
|
_fbPosolytPumpInlet.ReqAutomaticStop();
|
|
_fbNegolytPumpInlet.ReqAutomaticStop();
|
|
_iState := 65;
|
|
|
|
65: // Wait for pumps to be stopped
|
|
IF _fbPosolytPumpInlet.IsStopped AND _fbNegolytPumpInlet.IsStopped THEN
|
|
xOff := TRUE;
|
|
_xReleaseManualMode := TRUE;
|
|
IF NOT _xErrorActive THEN
|
|
_iState := 1000;
|
|
END_IF
|
|
END_IF
|
|
|
|
// Check for restart condition
|
|
IF xEnable AND (NOT _xErrorActive) THEN
|
|
_iState := 0;
|
|
END_IF
|
|
|
|
// Check for error
|
|
IF _xErrorActive THEN
|
|
_iState := 1000;
|
|
END_IF
|
|
|
|
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
|
|
_iState := 0;
|
|
END_IF
|
|
END_CASE
|
|
|
|
|
|
// ===============================
|
|
// Output error and warning flags
|
|
// ===============================
|
|
xError := _xErrorActive;
|
|
xWarning := _xWarningActive;]]></ST>
|
|
</Implementation>
|
|
<Method Name="FB_init" Id="{08f1cd44-6483-4d20-ab45-d1938e8ec885}">
|
|
<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;
|
|
|
|
// Create not all components in automatic mode alarm
|
|
_fbNotAllAutomaticAlarm.CreateEx(TC_EVENTS.General.NotAllCompInAutomatic, bWithConfirmation := FALSE, 0);
|
|
_fbNotAllAutomaticAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
|
|
</Implementation>
|
|
</Method>
|
|
<Property Name="Name" Id="{a82783d4-f1f5-481b-bbb0-7ea8279de793}">
|
|
<Declaration><![CDATA[PROPERTY Name : String]]></Declaration>
|
|
<Get Name="Get" Id="{62ca6bce-5aa4-40f1-aa68-f3e5d22ad4a4}">
|
|
<Declaration><![CDATA[VAR
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[Name := _sName;]]></ST>
|
|
</Implementation>
|
|
</Get>
|
|
<Set Name="Set" Id="{b2e0f6da-5412-45b8-aacd-c140a5beab95}">
|
|
<Declaration><![CDATA[VAR
|
|
END_VAR
|
|
]]></Declaration>
|
|
<Implementation>
|
|
<ST><![CDATA[_sName := Name;
|
|
|
|
// Create alarm message
|
|
_fbNotAllAutomaticAlarm.ipArguments.Clear().AddString(_sName);]]></ST>
|
|
</Implementation>
|
|
</Set>
|
|
</Property>
|
|
<LineIds Name="FB_Unit">
|
|
<LineId Id="4232" Count="4" />
|
|
<LineId Id="5406" Count="1" />
|
|
<LineId Id="5405" Count="0" />
|
|
<LineId Id="5592" Count="0" />
|
|
<LineId Id="5591" Count="0" />
|
|
<LineId Id="5593" Count="0" />
|
|
<LineId Id="4237" Count="24" />
|
|
<LineId Id="5408" Count="0" />
|
|
<LineId Id="4584" Count="0" />
|
|
<LineId Id="5409" Count="2" />
|
|
<LineId Id="5418" Count="0" />
|
|
<LineId Id="4263" Count="25" />
|
|
<LineId Id="5412" Count="2" />
|
|
<LineId Id="4289" Count="0" />
|
|
<LineId Id="5416" Count="0" />
|
|
<LineId Id="5415" Count="0" />
|
|
<LineId Id="4290" Count="36" />
|
|
<LineId Id="5420" Count="3" />
|
|
<LineId Id="5419" Count="0" />
|
|
<LineId Id="4327" Count="38" />
|
|
<LineId Id="5425" Count="3" />
|
|
<LineId Id="5424" Count="0" />
|
|
<LineId Id="4619" Count="0" />
|
|
<LineId Id="4367" Count="46" />
|
|
<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="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="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="5" />
|
|
<LineId Id="5441" Count="0" />
|
|
<LineId Id="4527" Count="1" />
|
|
<LineId Id="4653" Count="0" />
|
|
<LineId Id="4655" Count="2" />
|
|
<LineId Id="4654" Count="0" />
|
|
<LineId Id="4529" Count="1" />
|
|
<LineId Id="5220" Count="0" />
|
|
<LineId Id="5223" Count="0" />
|
|
<LineId Id="5225" Count="1" />
|
|
<LineId Id="5440" Count="0" />
|
|
<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="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="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="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="5434" 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>
|
|
<LineIds Name="FB_Unit.FB_init">
|
|
<LineId Id="11" Count="0" />
|
|
<LineId Id="20" Count="0" />
|
|
<LineId Id="12" Count="0" />
|
|
<LineId Id="7" Count="1" />
|
|
</LineIds>
|
|
<LineIds Name="FB_Unit.Name.Get">
|
|
<LineId Id="2" Count="0" />
|
|
</LineIds>
|
|
<LineIds Name="FB_Unit.Name.Set">
|
|
<LineId Id="2" Count="0" />
|
|
<LineId Id="7" Count="0" />
|
|
<LineId Id="6" Count="0" />
|
|
<LineId Id="5" Count="0" />
|
|
</LineIds>
|
|
</POU>
|
|
</TcPlcObject> |