TIA Portal Instructions

Word Logic Operations
Bitwise & Selection

Manipulate data at the heart of registers. From bit-by-bit binary masking to complex multiplexing, optimize your data word processing.

What are Word Logic Operations in TIA Portal?

Word logic operations allow performing Boolean calculations on all bits of a word (Word, DWord, LWord). They are essential for bit masking, comparing binary patterns, or simplified management of grouped signals.

This section also includes powerful selection functions like SEL and MUX, which allow dynamically choosing one value among several based on a condition or index, as well as encoding (ENCO) and decoding (DECO) tools for state management.

Bitwise Logic

Boolean processing on Word and DWord

AND / OR / XOR — Binary Operations

AND

What it does

Performs a logical operation (AND, OR, Exclusive OR) on each corresponding bit between two or more inputs. The result is provided in a word of the same size.

When to use it

Mask specific bits (AND with a mask), combine alarms, or detect state changes bit by bit.

Pro Tips

AND is perfect for 'turning off' bits, OR for 'turning them on'.

XOR is ideal for comparing two words and identifying which bits differ.

You can add extra inputs to the block by clicking the yellow icon.

INVERT — Ones' Complement

INV

What it does

Inverts the state of each bit in the input word (0 becomes 1, 1 becomes 0).

When to use it

Invert a group of sensor signals or prepare specific binary calculations.

Pro Tips

Equivalent to the NOT operator in classic programming but applied to the whole word.

Very useful for communications with third-party equipment having inverted logic.

Be careful not to confuse it with two's complement (NEG).

Selection & Multiplexing

Dynamic value routing

SEL — Binary Selection

SEL

What it does

Selects one of two inputs (IN0 or IN1) based on the state of a binary input G (G=0 -> IN0, G=1 -> IN1).

When to use it

Choose between manual and automatic setpoints, or switch between two temperature thresholds.

Pro Tips

Graphical equivalent of the ternary operator (condition ? a : b).

More compact than an IF block or two conditional transfer networks.

Works with almost all data types (Int, Real, Time...).

MUX / DEMUX — Multiplexers

MUX

What they do

MUX selects one input among N based on an index K. DEMUX routes an input to one of N outputs based on index K.

When to use it

Recipe management (selection by index), dynamic HMI display, or data routing to different workstations.

Pro Tips

Index K starts at 0. If K=0, IN0 is selected.

Use the MUX ELSE input to define a default value if the index is out of bounds.

DEMUX is very powerful for distributing a measurement to different history logs.

Encoding & Decoding

Conversion between index and bit position

DECO — Decoding

DECO

What it does

Activates the bit whose number corresponds to the input value. All other bits of the output word are set to 0.

When to use it

Convert a step number into a binary signal to drive a specific output.

Pro Tips

If the input is 3, bit 3 (the 4th) of the output word will be 1.

Allows easily going from an integer to a bit mask.

Ideal for driving signal towers or status indicators.

ENCO — Encoding

ENCO

What it does

Returns the number of the least significant bit (LSB) that is in state 1 in the input word.

When to use it

Identify which fault appeared in an alarm word to display the corresponding message.

Pro Tips

If the input word contains 2#0000_1000, ENCO returns 3.

Inverse operation of DECO.

Very useful for transforming signals from discrete position sensors into a numerical value.

Word Processing vs Individual Bit

Why work on the complete word?

ScenarioWord Logic ApproachAdvantage
Force 8 outputs to 0MOVE 0 -> Word1 network vs 8 contacts
Mask a byteAND 16#00FFSurgical precision
Invert 16 signalsINVERTExecution speed
Choose 1 value / 10MUXMaximum readability
Route a measurementDEMUXFlexible logic
Alarm priorityENCOInstant diagnostic

Frequently Asked Questions

What is the difference between MUX and an Array?

MUX is a hardcoded instruction for a few values (often < 10). For hundreds of values, use an Array with dynamic indexing [i] in SCL.

Can I perform AND on REAL types?

No, bitwise logic operations (AND, OR, XOR) are only allowed on binary types (Byte, Word, DWord, LWord).

How does the DEMUX index work?

The K input defines which output the IN value is copied to. If K=2, IN is copied to OUT2. All other outputs remain at their previous value or 0 depending on configuration.

Does INVERT change the sign of a number?

No, INVERT flips bits. To change the sign (two's complement), use the NEG (Math) instruction or multiply by -1.

Optimize your data manipulation

Need a complex multiplexer or a specific bit mask? T-IA Connect generates your word logic blocks instantly.