Table of Contents

Switcher Block (v3.0)

Description

ST call

PROGRAM PUMP_CONTROL_DEMO
    VAR
        Heating_Demand : BOOL;
        Pressure_Switch : BOOL;
        Thermal_Fault : BOOL;
 
        PumpSwitcher : Lib.Mervis.v3_0.SwitcherBlock;
        Pump_Relay : BOOL;
    END_VAR
 
    PumpSwitcher(
        Demand := Heating_Demand, 
        Feedback := BOOL_TO_USINT(Pressure_Switch), 
        Failure := Thermal_Fault,
        RunDown := T#2m,                // 2 minutes overrun to cool down
        FeedbackTimeout := T#10s        // Wait 10s for pressure to build up
    );
 
    Pump_Relay := PumpSwitcher.Command;
END_PROGRAM

Inputs

Name Data Type Allowed Range Retain Required Description
OperatingMode OperatingModeType Yes No Desired operating mode. The “Off” mode is dominant and prevents starting by any other function.
Demand bool No Yes Industry standard for “Requesting” an operational state in automatic mode. Often used in “Call for Heat” scenarios to avoid confusion with economic “Supply/Demand” terms.
Feedback usint 0..2 No No Running status feedback. Describes the logic requirement of waiting for confirmation while a Command is active (e.g., a fan dependent on pressure differentiation). You can directly map a boolean feedback using BOOL_TO_USINT.
FeedbackManual bool No No Feedback indicating a manual hardware override (e.g., HOA switch on the cabinet panel).
Failure bool No No External hardware fault report. Clarifies the source is hardware, not logic. Triggered by external reports like a motor trip, thermal overload, or frequency inverter fault.
EmergencyShutdown bool No No Emergency stop command. Overrides all modes.
OperatingHoursReset bool No No Trigger to reset the accumulated operating hours counter.
RunDown time No No Overrun / post-run time. HVAC standard for heat dissipation cycles to safely dissipate residual heat. The device will continue running for this duration after Demand is removed. If zero, the function is disabled.
FeedbackTimeout time No No Time allowed for the feedback signal to become active after the Command is issued before an alarm is raised.
KickFunctionInterval time No No Interval for the periodic maintenance/exercise function. Ensures the system is used regularly to maintain fluid movement and prevent seizing (e.g., run every 7 days). If zero, disabled.
KickFunctionDuration time No No How long the device should run during the periodic maintenance/exercise kick to maintain fluid movement and prevent seizing.
NotRunAlarmPriority AlarmPriorityType No No Alarm class for the “Fail to Start” (Not running) alarm.
FailureAlarmPriority AlarmPriorityType No No Alarm class for the external Failure alarm.
EmergencyAlarmPriority AlarmPriorityType No No Alarm class for the Emergency Shutdown alarm.
ControlFlags uint 0..15 No No Bit array defining extended block behavior (see table below).

Description of Feedback values

Value Meaning
0 Feedback is inactive (Not running)
1 Feedback is active (Running)
2 Feedback is not connected (Default value - ignores feedback logic)

Description of ControlFlags values

Bit Mask Meaning
0 1 If TRUE (1), all alarm evaluations are completely disabled.
1 2 Defines Command output behavior during an alarm in Automatic mode. If TRUE, Command is deactivated on alarm.
2 4 Defines Command output behavior during an alarm in Manual mode. If TRUE, Command is deactivated on alarm.
3 8 Defines the alarm reaction to EmergencyShutdown. If TRUE, an Emergency Shutdown will trigger a Failure alarm.
4..15 - Unused

Outputs

Name Data Type Description
Command bool The operational command output (TRUE = Run, FALSE = Stop).
AlarmsInterface ptr_to BaseAlarmBlock Composite interface pointer for unified alarm indication handling.
CompositeState uint Bit array describing the complete internal state of the block.
OperatingHours time Total accumulated running time of the device.
StartCounter udint Total number of times the device has been started.

Description of CompositeState output values

Bit Mask Meaning
0 1 Command is active.
1 2 Feedback is active. (If Feedback = 2, this simply mirrors the Command state).
2 4 Manual Mode is active.
3 8 Manual On is active.
4 16 Demand is active.
5 32 Kick (Periodic exercise) is currently active.
6 64 Run-down (Overrun) is currently active.
7 128 Failure/Fault is present.
8-9 - Current OperatingMode representation.

Detailed Function Description

This block integrates standard, highly-used functionalities required for safely and effectively switching physical devices (such as pumps, fans, or compressors). The core capabilities include:

Execution Logic: A switch command is generated based on the Demand input (in Auto mode) or forced by the Manual ON mode. Once the Command is active, the block monitors the Feedback. If the feedback is not detected within the FeedbackTimeout, a Not Run alarm is generated.

If an external fault occurs (e.g., a frequency inverter fault or thermal overload), the Failure input generates a Failure alarm. Setting the EmergencyShutdown input to TRUE immediately deactivates the Command regardless of the selected operating mode.

In Automatic mode, the device may also start independently of the Demand if the KickFunctionInterval expires. It will run strictly for the KickFunctionDuration.

When the Demand becomes inactive, the run-down timer begins. The Command remains active for the duration specified by RunDown, ensuring safe shutdown procedures (like cooling down a boiler loop) are completed before the relay is finally deactivated.

Application Example from a Real Project

This block is highly recommended for controlling physical outputs like circulation pumps or exhaust fans.

Scenario: Heating Circulation Pump In a standard commercial boiler room, a circulation pump must run whenever the heating controller requests heat (Demand). However, abruptly stopping the pump when the burner turns off can cause water to boil in the heat exchanger due to residual heat.