Files
BasicComponents/PLC/POUs/Components/Utilities/FB_ReleaseSignal.TcPOU
2025-11-13 09:19:39 +01:00

44 lines
1.2 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<POU Name="FB_ReleaseSignal" Id="{95131698-43c9-4438-8f9f-0d910656ef66}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FINAL FB_ReleaseSignal
VAR_INPUT
// Signal to filter
xSignal : BOOL := FALSE;
// Release signal output
xRelease : BOOL := TRUE;
// Time for xSignal to be true before setting xReleaseSignal to true
timOnDelay : TIME := T#0MS;
// Time for xSignal to be false before setting xReleaseSignal to false
timOffDelay : TIME := T#0MS;
END_VAR
VAR_OUTPUT
// Filtered signal
xReleaseSignal : BOOL;
END_VAR
VAR
// Timer for on filtering
_fbOnDelayTimer : TON;
// Timer for off filtering
_fbOffDelayTimer : TON;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[// Delay on signal if signal is released
_fbOnDelayTimer(IN:= xSignal AND xRelease, PT:= timOnDelay);
IF _fbOnDelayTimer.Q THEN
xReleaseSignal := TRUE;
END_IF
// Delay off signal, return false even if off timer is still active
_fbOffDelayTimer(IN:= (NOT xSignal), PT:= timOffDelay);
IF _fbOffDelayTimer.Q OR (NOT xRelease) THEN
xReleaseSignal := FALSE;
END_IF]]></ST>
</Implementation>
</POU>
</TcPlcObject>