BlockWerk Documentation
⊕

Switch

Logic

The Switch block selects between two input signals based on a selector signal. If the selector is non-negative (≥ 0), it outputs the first input; otherwise, it outputs the second input. Essential for conditional signal routing and mode selection.

Simulate in BlockWerk

Interactive sandbox directly in your browser — zero installation, WASM-powered.

Simulate in BlockWerk →

Mathematical Model

y={u1,usel≥0u2,usel<0y = \begin{cases} u_1, & u_{\text{sel}} \ge 0 \\ u_2, & u_{\text{sel}} < 0 \end{cases}

Inputs & Outputs

Direction ID Label Type Status
→ In selector Selector number Required
→ In in1 If ≥ 0 number Required
→ In in2 If < 0 number Required
← Out out Output number Output

Parameters

Parameters Label Type Default Description
threshold Threshold number 0
criteria Criteria select u2 >= threshold

Usage Examples

Signal Selection (1 second)

Two signals (constant 5 and ramp 0→5) selected by a step function. At t=0.5s, selector switches from negative to positive, changing output signal.

Conditional Mode Switch

Selector from comparator output (0 or 1) routes between manual (constant) and automatic (ramp) control.

Remarks & Best Practices

  • No Parameters: Simple threshold logic (selector ≥ 0)
  • Combinatorial: Zero delay, instantaneous switching
  • Zero Crossing: Switches exactly at selector = 0
  • Routing: Essential for mode selection in complex systems
  • Glitch-Free: No oscillation at boundary

Related Components

  • Comparator: Generates binary selector signal
  • Step: Input signal for selector
  • Gain: Scale selector signal
  • Subtraction: Compute error for switching logic