Learn PLCs free
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

20 Production-Ready Ladder Logic Templates

Stop writing the same rungs from scratch. Get copy-paste-ready templates for motor control, PID loops, safety interlocks, conveyors, and more.

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.

Stop Writing Ladder Logic From Scratch

Get 20 production-ready ladder logic templates for $29 -- download instantly and use them on your next project today.

20
Ready-Made Templates
LD + ST
Both Languages Included
$29
One-Time Purchase
Get Instant Access -- $29

Instant download - 30-day money-back guarantee - Use on unlimited projects

Free PLC simulator

Wire this block up and run it

Drop the instruction into a rung, hit Run, and watch it execute in your browser. 12 guided lessons across 8 PLC dialects — free account, no credit card.

Practice PLCs free →