Try a PLC free — no signup
Data Movement & Bit ShiftingIntermediateIEC 61131-3

SHL (Shift Left)

Shifts bits left by N positions, filling right with zeros. Equivalent to multiply by 2^N.

The SHL (Shift Left) function shifts the bits of the input value to the left by a specified number of positions. Vacated bit positions on the right are filled with zeros. Bits shifted past the leftmost position are lost. Each left shift by 1 position is equivalent to multiplying by 2. SHL is used for bit manipulation, creating bitmasks, multiplying by powers of 2, and protocol encoding.

Parameters

Inputs

NameTypeDescription
INANY_BITValue to shift
NINTNumber of bit positions to shift left

Outputs

NameTypeDescription
OUTANY_BITShifted result

Ladder Logic Example

// Ladder Logic - SHL (Create Bitmask)
//
// |----[SHL]----|
// | IN: 16#0001          |
// | N:  Bit_Position     |
// | OUT: Bit_Mask        |

Structured Text Example

Bit_Mask := SHL(16#0001, Bit_Position);
// Position 0: 0000_0001
// Position 3: 0000_1000
// Position 7: 1000_0000

// Quick multiply by 8:
Result := SHL(Value, 3);  // Value * 2^3 = Value * 8

Free · no signup to try

Run this block in your browser

Try the instruction on a live rung before you copy it into a project — nothing to install.

Try it in your browser — no signup

Opens plcsimulationsoftware.com — same team

Prefer ready-made code? Ladder Logic Pack — $29 on Gumroad

Platform-Specific Implementation

S

Siemens (TIA Portal)

Use SHL instruction in TIA Portal.

AB

Allen-Bradley (Studio 5000)

Use BSL (Bit Shift Left) instruction for single-bit shifts, or SHL for word-level.

C

CODESYS

Use SHL() function in ST.

Common Applications

  • Bitmask creation
  • Fast multiplication by powers of 2
  • Protocol data packing
  • Status word construction
  • LED pattern generation

Frequently Asked Questions

What is SHL (Shift Left) in PLC programming?

Shifts bits left by N positions, filling right with zeros. Equivalent to multiply by 2^N. The SHL (Shift Left) function shifts the bits of the input value to the left by a specified number of positions. Vacated bit positions on the right are filled with zeros.

What are common applications of SHL (Shift Left)?

SHL (Shift Left) is commonly used for: Bitmask creation, Fast multiplication by powers of 2, Protocol data packing, Status word construction, LED pattern generation.

How do I use SHL (Shift Left) in different PLC platforms?

Siemens: Use SHL instruction in TIA Portal. Allen-Bradley: Use BSL (Bit Shift Left) instruction for single-bit shifts, or SHL for word-level. CODESYS: Use SHL() function in ST.

Free · no signup to try

Wire this block up and run it

Drop the instruction into a rung, press Run and watch it execute in your browser — then adapt it to your vendor tool.

Try it in your browser — no signup

Opens plcsimulationsoftware.com — same team

Prefer ready-made code? Ladder Logic Pack — $29 on Gumroad