Logic

The Logic block combines Boolean conditions and returns their shared result. Use it when a decision depends on multiple conditions.

Loading preview …

Typical use cases

  • Combine multiple conditions before a branch.
  • Check whether at least one condition is met.
  • Activate an output only when every input is true.
  • Negate conditions or check for an odd number of true values.

Inputs

The block starts with the two Boolean inputs a and b. Use the + and − controls to add or remove inputs.

OperatorMinimum inputsMaximum inputs
AND, OR, XOR, NAND, NOR210
NOT110

Each input accepts either a connected Boolean value or a fixed value selected directly in the block. New inputs default to false. Connecting an input disables its local selector.

Inputs are labelled alphabetically from a through j. Removing an input also removes its connections.

Operators

OperatorResult
ANDtrue when every input is true.
ORtrue when at least one input is true.
XORtrue when an odd number of inputs are true.
NANDNegated AND; only false when every input is true.
NORNegated OR; only true when every input is false.
NOTInverts every input separately.

Truth table for two inputs

abANDORXORNANDNOR
falsefalsefalsefalsefalsetruetrue
falsetruefalsetruetruetruefalse
truefalsefalsetruetruetruefalse
truetruetruetruefalsefalsefalse

With more than two inputs, XOR acts as a parity check: its result is true when an odd number of inputs are true.

NOT preview

The NOT operator inverts every input separately and provides an individual output for each input.

Loading preview …

Outputs

For AND, OR, XOR, NAND and NOR, the block has one Boolean output named Value, containing the combined result.

With NOT, every input has a separate output:

InputOutputResult
aNot a!a
bNot b!b
c–jNot c–Not jInverted value of the corresponding input.

Configuration

  1. Select the required operator from the dropdown.
  2. Set the required number of inputs with + or −.
  3. Connect Boolean values to the inputs or select fixed values.
  4. Connect Value, or the required Not … outputs, to the next blocks.

Example: alarm condition

An alarm should only be activated when the system is armed and a window is open:

  1. Select AND.
  2. Connect the “system armed” state to a.
  3. Connect the “window open” state to b.
  4. Connect Value to Condition on an IF Else block.

Only when both inputs are true does Value return true.

Notes and troubleshooting

  • The block only accepts Boolean inputs and only produces Boolean outputs.
  • After switching to NOT, make sure the required individual output is connected.
  • With three or more inputs, XOR means “an odd number are true”, not “exactly one is true”.
  • Check disconnected inputs: their locally selected values still affect the result.

Related blocks

  • IF Else — selects a program branch from a Boolean result.
  • Compare Values — creates a Boolean condition from two numeric values.