Added Simulation plc and removed unnecessary files from repository

This commit is contained in:
Matthias Heisig
2024-01-04 18:39:55 +01:00
parent 2bd41279b1
commit bd0bbd9c8b
43 changed files with 4692 additions and 1328 deletions

View File

@@ -6,20 +6,29 @@ VAR_INPUT
// Raise sensor level from min to max
xEnable : BOOL;
// Switch to error high
xErrorHigh : BOOL := FALSE;
// Switch to error low
xErrorLow : BOOL := FALSE;
// Sensor value when enabled
rOnValue : REAL;
// Sensor value when dissabled
rOffValue : REAL;
// Sensor value error high
rErrorLowValue : REAL;
// Sensor value error high
rErrorHighValue : REAL;
// Sensor noise value
rNoise : REAL := 0.0;
// Sensor min value for analog scaling
rMinValue : REAL := 0.0;
// Sensor max value for analog scaling
rMaxValue : REAL := 1.0;
// Analog output scaling
stAnalogScaling : ST_ANALOG_IO_CONFIG;
END_VAR
VAR_OUTPUT
iAnalogValue AT %Q* : INT;
@@ -42,18 +51,25 @@ VAR
_rPrevValue : REAL := 0.0;
// Analog output
_fbValveAnalogOutput : FB_AnalogOutput('');
// Analog output scaling
_stAnalogScaling : ST_ANALOG_IO_CONFIG;
_stAnalogEWConfig : ST_ANALOG_EW_LEVELS;
_stAnalogEWDelays : ST_ANALOG_EW_DELAYS;
{attribute 'hide'}
_fbAnalogOutput : FB_AnalogOutput('');
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[// Pressure only if enabled
IF xEnable THEN
// Normal enable value
_rTargetValue := rOnValue;
// Switch to error high value
IF xErrorHigh AND (NOT xErrorLow) THEN
_rTargetValue := rErrorHighValue;
END_IF
// Switch to error low value
IF xErrorLow AND (NOT xErrorHigh) THEN
_rTargetValue := rErrorHighValue;
END_IF
ELSE
_rTargetValue := rOffValue;
END_IF
@@ -70,16 +86,11 @@ IF xEnable THEN
_rValue := _rValue + (LREAL_TO_REAL(_lrTmp - 0.5) * rNoise);
END_IF
// Set analog output scaling
_stAnalogScaling.iAIMax := 32767;
_stAnalogScaling.iAIMin := 0;
_stAnalogScaling.rPVMax := rMaxValue;
_stAnalogScaling.rPVMin := rMinValue;
// Calculate analog output from ramp generator setpoint
_fbValveAnalogOutput(
_fbAnalogOutput(
rSetpoint:= _rValue,
stScalingConfig:= _stAnalogScaling,
stScalingConfig:= stAnalogScaling,
xReleaseErrors:= FALSE,
xReleaseHardwareErrors:= FALSE,
xConfirmAlarms:= ,
@@ -87,11 +98,7 @@ _fbValveAnalogOutput(
xError=> );]]></ST>
</Implementation>
<LineIds Name="FB_AnalogSensorMockup">
<LineId Id="719" Count="14" />
<LineId Id="798" Count="0" />
<LineId Id="734" Count="0" />
<LineId Id="799" Count="0" />
<LineId Id="735" Count="14" />
<LineId Id="1084" Count="38" />
<LineId Id="9" Count="0" />
</LineIds>
</POU>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
<POU Name="FB_ModuleMockup" Id="{7849a7a0-5044-422d-86cf-733e0cdbe96b}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FB_ModuleMockup
VAR_INPUT
stModuleError : REFERENCE TO ST_MODULE_ERROR;
END_VAR
VAR_OUTPUT
END_VAR
VAR
// Unit array
afbUnits : ARRAY[0..3] OF FB_UnitMockup;
i : INT;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[FOR i := 0 TO 3 DO
afbUnits[i](stUnitError:= stModuleError.astUnitErrors[i]);
END_FOR]]></ST>
</Implementation>
<LineIds Name="FB_ModuleMockup">
<LineId Id="9" Count="0" />
<LineId Id="14" Count="1" />
</LineIds>
</POU>
</TcPlcObject>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
<POU Name="FB_StringMockup" Id="{f680b9a5-3af1-4e93-b52d-21296306c101}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FB_StringMockup
VAR_INPUT
stStringError : REFERENCE TO ST_STRING_ERROR;
END_VAR
VAR_OUTPUT
END_VAR
VAR
afbModules : ARRAY[0..2] OF FB_ModuleMockup;
i : INT;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[FOR i := 0 TO 2 DO
afbModules[i](stModuleError:= stStringError.stModuleError[i]);
END_FOR]]></ST>
</Implementation>
<LineIds Name="FB_StringMockup">
<LineId Id="9" Count="0" />
<LineId Id="15" Count="1" />
</LineIds>
</POU>
</TcPlcObject>

View File

@@ -3,6 +3,7 @@
<POU Name="FB_UnitMockup" Id="{a1155b26-00e6-4710-a8e4-140d6d5cd082}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FB_UnitMockup
VAR_INPUT
stUnitError : REFERENCE TO ST_UNIT_ERROR;
END_VAR
VAR_OUTPUT
END_VAR
@@ -19,16 +20,21 @@ VAR
// Pumps negolyt
_fbNegolytPumpInlet : FB_MotorMockup;
// Pressure sensors posolyt
_fbPressurePosolytSegmentInlet : FB_AnalogSensorMockup;
_fbPressurePosolytTankInlet : FB_AnalogSensorMockup;
// Pressure sensors negolyt
_fbPressureNegolytSegmentInlet : FB_AnalogSensorMockup;
_fbPressureNegolytTankInlet : FB_AnalogSensorMockup;
// Temperature sensors
_fbTemperatureSensorPosolyt : FB_AnalogSensorMockup;
_fbTemperatureSensorNegolyt : FB_AnalogSensorMockup;
// Segment Voltage
_fbVoltageSegment : FB_AnalogSensorMockup;
// Helping variables
_xFlowThroughtSegmentPosolyt : BOOL;
_xFlowThroughtBypassPosolyt : BOOL;
@@ -38,74 +44,214 @@ VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[// Valves posolyt
<ST><![CDATA[// ===============================
// Valves posolyt
// ===============================
_fbPosolytValveTankOutlet();
// ===============================
// Valves negolyt
// ===============================
_fbNegolytValveTankOutlet();
// ===============================
// Pumps posolyt
// ===============================
_fbPosolytPumpInlet();
// ===============================
// Pumps negolyt
// ===============================
_fbNegolytPumpInlet();
// ===============================
// Simulate flow posolyt
// ===============================
_xFlowThroughtSegmentPosolyt := _fbPosolytPumpInlet.xEnable AND _fbPosolytValveTankOutlet.xOpenFeedback;
_xFlowThroughtBypassPosolyt := _fbPosolytPumpInlet.xEnable AND NOT _fbPosolytValveTankOutlet.xOpenFeedback;
_xFlowThroughtSegmentNegolyt := _fbNegolytPumpInlet.xEnable AND _fbNegolytValveTankOutlet.xOpenFeedback;
_xFlowThroughtBypassNegolyt := _fbNegolytPumpInlet.xEnable AND NOT _fbNegolytValveTankOutlet.xOpenFeedback ;
// ===============================
// Pressure sensors posolyt
// ===============================
_fbPressurePosolytSegmentInlet(
xEnable:= _xFlowThroughtSegmentPosolyt,
rOnValue:= 0.487,
rOffValue:= 0.0,
rNoise:= 0.002,
rMinValue:= -1.0,
rMaxValue:= 1.5);
xEnable:= _xFlowThroughtSegmentPosolyt,
xErrorHigh := stUnitError.xErrorHighPressurePosolytSegmentInlet,
xErrorLow := stUnitError.xErrorLowPressurePosolytSegmentInlet,
stAnalogScaling := GVL_CONFIG.stPressureSensorConfig,
rOnValue:= 487,
rOffValue:= 0.0,
rErrorHighValue := 750,
rErrorLowValue := 0.0,
rNoise:= 0.002);
_fbPressurePosolytTankInlet(
xEnable:= _xFlowThroughtSegmentPosolyt,
rOnValue:= 0.0429,
rOffValue:= 0.0,
rNoise:= 0.002,
rMinValue:= -1.0,
rMaxValue:= 1.5);
xEnable:= _xFlowThroughtSegmentPosolyt,
xErrorHigh := stUnitError.xErrorHighPressurePosolytTankInlet,
xErrorLow := stUnitError.xErrorLowPressurePosolytTankInlet,
stAnalogScaling := GVL_CONFIG.stPressureSensorConfig,
rOnValue:= 42.9,
rOffValue:= 0.0,
rErrorHighValue := 150,
rErrorLowValue := 0.0,
rNoise:= 0.002);
// ===============================
// Pressure sensors negolyt
// ===============================
_fbPressureNegolytSegmentInlet(
xEnable:= _xFlowThroughtSegmentNegolyt,
rOnValue:= 0.487,
rOffValue:= 0.0,
rNoise:= 0.002,
rMinValue:= -1.0,
rMaxValue:= 1.5);
xEnable:= _xFlowThroughtSegmentNegolyt,
xErrorHigh := stUnitError.xErrorHighPressureNegolytSegmentInlet,
xErrorLow := stUnitError.xErrorLowPressureNegolytSegmentInlet,
stAnalogScaling := GVL_CONFIG.stPressureSensorConfig,
rOnValue:= 487,
rOffValue:= 0.0,
rErrorHighValue := 750,
rErrorLowValue := 0.0,
rNoise:= 0.002);
_fbPressureNegolytTankInlet(
xEnable:= _xFlowThroughtSegmentNegolyt,
rOnValue:= 0.0429,
xEnable:= _xFlowThroughtSegmentNegolyt,
xErrorHigh := stUnitError.xErrorHighPressureNegolytTankInlet,
xErrorLow := stUnitError.xErrorLowPressureNegolytTankInlet,
stAnalogScaling := GVL_CONFIG.stPressureSensorConfig,
rOnValue:= 42.9,
rOffValue:= 0.0,
rErrorHighValue := 150,
rErrorLowValue := 0.0,
rNoise:= 0.002);
// ===============================
// Temperatur sensors
// ===============================
_fbTemperatureSensorPosolyt(
xEnable:= _xFlowThroughtSegmentPosolyt,
xErrorHigh := stUnitError.xErrorHighTempPosolyt,
xErrorLow := stUnitError.xErrorLowTempPosolyt,
stAnalogScaling := GVL_CONFIG.stTempSensorConfig,
rOnValue:= 40.0,
rOffValue:= 21.0,
rErrorHighValue := 60.0,
rErrorLowValue := -10.0);
_fbTemperatureSensorNegolyt(
xEnable:= _xFlowThroughtSegmentNegolyt,
xErrorHigh := stUnitError.xErrorHighTempNegolyt,
xErrorLow := stUnitError.xErrorLowTempNegolyt,
stAnalogScaling := GVL_CONFIG.stTempSensorConfig,
rOnValue:= 40.0,
rOffValue:= 21.0,
rErrorHighValue := 60.0,
rErrorLowValue := -10.0);
// ===============================
// Voltage sensor
// ===============================
_fbVoltageSegment(
xEnable:= _xFlowThroughtSegmentPosolyt AND _xFlowThroughtSegmentNegolyt,
xErrorHigh:= stUnitError.xErrorHighVoltageSegment,
xErrorLow:= stUnitError.xErrorLowVoltageSegment,
rOnValue:= 64.3,
rOffValue:= 0.0,
rNoise:= 0.002,
rMinValue:= -1.0,
rMaxValue:= 1.5);
]]></ST>
rErrorLowValue:= 35.0,
rErrorHighValue:= 80.0,
rNoise:= 0.05,
stAnalogScaling:= GVL_CONFIG.stVoltageSensorconfig);]]></ST>
</Implementation>
<LineIds Name="FB_UnitMockup">
<LineId Id="482" Count="1" />
<LineId Id="486" Count="2" />
<LineId Id="491" Count="2" />
<LineId Id="495" Count="2" />
<LineId Id="499" Count="2" />
<LineId Id="812" Count="0" />
<LineId Id="482" Count="0" />
<LineId Id="813" Count="0" />
<LineId Id="483" Count="0" />
<LineId Id="822" Count="0" />
<LineId Id="814" Count="0" />
<LineId Id="486" Count="1" />
<LineId Id="815" Count="0" />
<LineId Id="488" Count="0" />
<LineId Id="823" Count="0" />
<LineId Id="816" Count="0" />
<LineId Id="491" Count="1" />
<LineId Id="817" Count="0" />
<LineId Id="493" Count="0" />
<LineId Id="824" Count="0" />
<LineId Id="818" Count="0" />
<LineId Id="495" Count="1" />
<LineId Id="819" Count="0" />
<LineId Id="497" Count="0" />
<LineId Id="825" Count="0" />
<LineId Id="820" Count="0" />
<LineId Id="499" Count="1" />
<LineId Id="821" Count="0" />
<LineId Id="501" Count="0" />
<LineId Id="695" Count="3" />
<LineId Id="502" Count="8" />
<LineId Id="519" Count="7" />
<LineId Id="568" Count="3" />
<LineId Id="699" Count="3" />
<LineId Id="826" Count="0" />
<LineId Id="810" Count="0" />
<LineId Id="502" Count="1" />
<LineId Id="811" Count="0" />
<LineId Id="504" Count="1" />
<LineId Id="804" Count="1" />
<LineId Id="788" Count="0" />
<LineId Id="506" Count="1" />
<LineId Id="864" Count="0" />
<LineId Id="882" Count="0" />
<LineId Id="510" Count="0" />
<LineId Id="519" Count="2" />
<LineId Id="806" Count="1" />
<LineId Id="789" Count="0" />
<LineId Id="522" Count="1" />
<LineId Id="866" Count="0" />
<LineId Id="881" Count="0" />
<LineId Id="524" Count="0" />
<LineId Id="899" Count="0" />
<LineId Id="809" Count="0" />
<LineId Id="568" Count="1" />
<LineId Id="808" Count="0" />
<LineId Id="570" Count="1" />
<LineId Id="830" Count="1" />
<LineId Id="790" Count="0" />
<LineId Id="699" Count="1" />
<LineId Id="868" Count="0" />
<LineId Id="880" Count="0" />
<LineId Id="576" Count="0" />
<LineId Id="585" Count="7" />
<LineId Id="600" Count="0" />
<LineId Id="585" Count="2" />
<LineId Id="845" Count="1" />
<LineId Id="791" Count="0" />
<LineId Id="588" Count="1" />
<LineId Id="879" Count="0" />
<LineId Id="870" Count="0" />
<LineId Id="592" Count="0" />
<LineId Id="829" Count="0" />
<LineId Id="827" Count="0" />
<LineId Id="769" Count="1" />
<LineId Id="828" Count="0" />
<LineId Id="856" Count="2" />
<LineId Id="863" Count="0" />
<LineId Id="860" Count="1" />
<LineId Id="855" Count="0" />
<LineId Id="874" Count="0" />
<LineId Id="878" Count="0" />
<LineId Id="862" Count="0" />
<LineId Id="772" Count="1" />
<LineId Id="851" Count="1" />
<LineId Id="792" Count="0" />
<LineId Id="774" Count="1" />
<LineId Id="877" Count="0" />
<LineId Id="875" Count="0" />
<LineId Id="779" Count="0" />
<LineId Id="898" Count="0" />
<LineId Id="896" Count="1" />
<LineId Id="784" Count="0" />
<LineId Id="886" Count="9" />
</LineIds>
</POU>
</TcPlcObject>

View File

@@ -1,13 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<POU Name="MAIN" Id="{bb83bde3-1093-40be-b27d-d7bc60ebb5a6}">
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
<POU Name="MAIN" Id="{bb83bde3-1093-40be-b27d-d7bc60ebb5a6}" SpecialFunc="None">
<Declaration><![CDATA[PROGRAM MAIN
VAR
// String mockup
fbString : FB_StringMockup;
END_VAR
]]>
</Declaration>
]]></Declaration>
<Implementation>
<ST><![CDATA[]]></ST>
<ST><![CDATA[// Call string mockup
fbString(stStringError:= GVL_GLOBAL.astStringError);]]></ST>
</Implementation>
<LineIds Name="MAIN">
<LineId Id="7" Count="0" />
<LineId Id="2" Count="0" />
</LineIds>
</POU>
</TcPlcObject>

View File

@@ -7,13 +7,15 @@ VAR_INPUT
xEnable AT%I* : BOOL;
// Motor setpoint
iSetpoint AT%I* : INT;
iSetpoint AT %I* : INT;
END_VAR
VAR_OUTPUT
// Motor circuit breaker ok
{attribute 'hide'}
xMCBOk AT %Q* : BOOL;
// Repair switch ok
{attribute 'hide'}
xRepairSwitchOk AT %Q* : BOOL;
// Motor speed feedback
@@ -24,11 +26,14 @@ VAR
_fbRampGenerator : FB_RampGenerator;
{attribute 'hide'}
_fbValveAnalogInput : FB_AnalogInput('');
_stAnalogScaling : ST_ANALOG_IO_CONFIG := (iAIMax := 32767, iAIMin := 0, rPVMax := 100, rPVMin := 0);
_stAnalogEWConfig : ST_ANALOG_EW_LEVELS;
_stAnalogEWDelays : ST_ANALOG_EW_DELAYS;
{attribute 'hide'}
_fbValveAnalogOutput : FB_AnalogOutput('');
END_VAR
]]></Declaration>

View File

@@ -5,6 +5,9 @@
VAR_INPUT
xOpenValve AT %I* : BOOL;
xCloseValve AT %I* : BOOL;
xErrorOpen : BOOL := FALSE;
xErrorClose : BOOL := FALSE;
END_VAR
VAR_OUTPUT
xOpenFeedback AT %Q* : BOOL;
@@ -21,8 +24,8 @@ _tonOpen(IN := xOpenValve);
_tonClose(IN := xCloseValve);
// Open and close feedback
xOpenFeedback := _tonOpen.Q;
xCloseFeedback := _tonClose.Q;]]></ST>
xOpenFeedback := _tonOpen.Q AND (NOT xErrorOpen);
xCloseFeedback := _tonClose.Q AND (NOT xErrorClose);]]></ST>
</Implementation>
<LineIds Name="FB_ValveMockup">
<LineId Id="54" Count="5" />