FB_ThresholdSwitch

FB_ThresholdSwitch 1:

If the input signal exceeds the limit value fUpperLimit for the duration specified by tUpperLimitDelay, the output bCrossUpperLimit is set for one PLC cycle. The bSwitchingSignal output is also set. This remains set until the input signal passes below the value of fLowerLimit for the duration specified by tLowerLimitDelay. In this case, the output fCrossLowerLimit is set for one PLC cycle.

VAR_INPUT

fSignal           : LREAL;
fLowerLimit       : LREAL := 16000;
fUpperLimit       : LREAL := 17000;
tLowerLimitDelay  : TIME := t#100ms;
tUpperLimitDelay  : TIME := t#100ms;

fSignal: Input signal.

fLowerLimit: Lower limit value.

fUpperLimit: Upper limit value.

tLowerLimitDelay: Switching delay when passing beyond the lower limit.

tUpperLimitDelay: Switching delay when passing beyond the upper limit.

VAR_OUTPUT

bSwitchingSignal      : BOOL;
bCrossLowerLimit      : BOOL;
bCrossUpperLimit      : BOOL;

bSwitchingSignal: State depends on bCrossLowerLimit and bCrossUpperLimit.

bCrossLowerLimit: Is TRUE for one cycle, once fLowerLimit has fallen short of for the time tLowerLimitDelay. Simultaneously bSwitchingSignal is FALSE.

bCrossUpperLimit: Is TRUE for one cycle, once fUpperLimit was exceeded for the time tUpperLimitDelay. Simultaneously bSwitchingSignal is TRUE.

Example

In the following example, the two lamps can each be controlled with one switch. The two lamps are automatically switched in response to the outside brightness and the threshold switch. The lamps are switched on if the outside brightness is less than 1000 lux for 15 minutes. The lamps are switched off as soon as the brightness is greater than 2000 lux for more than 15 minutes.

FB_ThresholdSwitch 2: