Projektdateien hinzufügen.

This commit is contained in:
Matthias Heisig
2024-01-04 15:15:26 +01:00
parent 4c6f8dc5bd
commit faa33db290
94 changed files with 15104 additions and 0 deletions

View File

@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.12">
<POU Name="FB_AnalogSensorMockup" Id="{198f1df4-73a2-495b-b972-189adc06c969}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FB_AnalogSensorMockup
VAR_INPUT
// Raise sensor level from min to max
xEnable : BOOL;
// Sensor value when enabled
rOnValue : REAL;
// Sensor value when dissabled
rOffValue : 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;
END_VAR
VAR_OUTPUT
iAnalogValue AT %Q* : INT;
END_VAR
VAR
// Internal target value
_rTargetValue : REAL;
// Temp variable
_lrTmp : LREAL;
// Filter data
_rFilterParam : REAL := 0.005;
_rFilterParam2 : REAL := 1.0 - _rFilterParam;
// Calculated value
_rValue : REAL;
// Last calculated value
_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;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[// Pressure only if enabled
IF xEnable THEN
_rTargetValue := rOnValue;
ELSE
_rTargetValue := rOffValue;
END_IF
// Get a random number
GVL_GLOBAL.fbRandom(Seed := 1337, Num => _lrTmp);
// Exponential smoothing
_rValue := _rFilterParam * _rTargetValue + _rFilterParam2 * _rPrevValue;
_rPrevValue := _rValue;
// Add some random noise
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(
rSetpoint:= _rValue,
stScalingConfig:= _stAnalogScaling,
xReleaseErrors:= FALSE,
xReleaseHardwareErrors:= FALSE,
xConfirmAlarms:= ,
iAnalogValue=> iAnalogValue,
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="9" Count="0" />
</LineIds>
</POU>
</TcPlcObject>