Logic Gate
LogicThe LogicGate block implements standard combinatorial Boolean logic operations across multiple incoming signals. It supports four fundamental operations—AND, OR, NOT, and XOR—with a configurable number of inputs. Input values are interpreted in accordance with standard engineering logic conventions (zero is false, any non-zero value is true), and the block outputs a clean discrete binary signal ( for true, for false). It is widely used in supervisory control, safety interlock chains, fault detection alarms, and digital state machines.
Mathematical Model
Incoming scalar signals are converted into Boolean values using non-zero thresholding:
The output is evaluated across inputs () based on the selected operation:
- AND: Output is if all inputs are non-zero:
```latex
y(t) = \bigwedge_{k=1}^M b_k(t) = \prod_{k=1}^M b_k(t)
```
- OR: Output is if at least one input is non-zero:
```latex
y(t) = \bigvee_{k=1}^M b_k(t) = 1 - \prod_{k=1}^M (1 - b_k(t))
```
- NOT: Output inverts the primary input signal ():
```latex
y(t) = \neg b_1(t) = 1 - b_1(t)
```
- XOR: Output is if an odd number of inputs are non-zero:
```latex
y(t) = \left( \sum_{k=1}^M b_k(t) \right) \bmod 2
```
Inputs & Outputs
| Direction | ID | Label | Type | Status |
|---|---|---|---|---|
| → In | in |
Input | number | Required |
| ← Out | out |
Output | boolean | Output |
Parameters
| Parameters | Label | Type | Default | Description |
|---|---|---|---|---|
operation |
Operation | select | AND |
|
numInputs |
Number of Inputs | number | 2 |
Usage Examples
Example 1: Redundant Dual-Sensor Safety Interlock
In an industrial furnace burner management system, fuel flow is only permitted if both flame ionization sensors detect an active pilot flame. Routing the two sensor threshold comparator outputs into a LogicGate with operation = "AND" and numInputs = 2 ensures the fuel solenoid valve is energised only when both sensors register active flame status simultaneously.
Example 2: Multi-Zone Fire Alarm OR Detection
Connecting three independent temperature alarm comparator flags to a single LogicGate configured with operation = "OR" and numInputs = 3. If any zone detects an over-temperature condition (), the output immediately switches to , commanding emergency building ventilation and audible alarms.
Remarks & Best Practices
- Non-Zero Truth Value Convention: Any numerical value not equal to zero (, including negative numbers) is treated as boolean true (). Only exact zero () evaluates to false ().
- Clean Boolean Output: The block strictly outputs normalized values of (true) or (false), making it directly compatible with the control ports of
Switch,Relay, andTimerblocks. - NOT Operation Input Count: Selecting
operation = "NOT"automatically overrides the input count to , ignoring thenumInputssetting. - Zero Execution Latency: Combinatorial logic is evaluated directly as native WebAssembly boolean operations without internal state delays or iteration loops.
Related Components
- Comparator: Evaluates relational inequalities (, ) to produce boolean signals.
- IntervalTest: Tests whether a continuous signal lies within a bounded interval .
- Switch: Selects between two signals based on a boolean control condition.
- Relay: Hysteresis switching element for on-off control.