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

SHR (Shift Right)

Shifts bits right by N positions. Equivalent to integer division by 2^N.

The SHR (Shift Right) function shifts the bits of the input value to the right by a specified number of positions. Vacated bit positions on the left are filled with zeros (for unsigned types) or the sign bit (for signed types). Each right shift by 1 is equivalent to integer division by 2. SHR is used for extracting specific bits, fast division by powers of 2, and decoding packed status words.

Parameters

Inputs

NameTypeDescription
INANY_BITValue to shift
NINTNumber of bit positions to shift right

Outputs

NameTypeDescription
OUTANY_BITShifted result

Ladder Logic Example

// Ladder Logic - SHR (Extract Byte)
//
// |----[SHR]----|
// | IN: Status_Word       |
// | N:  8                 |
// | OUT: High_Byte        |

Structured Text Example

High_Byte := SHR(Status_Word, 8);  // Extract upper byte

// Fast divide by 4:
Result := SHR(Value, 2);  // Value / 2^2 = Value / 4

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 SHR instruction in TIA Portal.

AB

Allen-Bradley (Studio 5000)

Use BSR (Bit Shift Right) for single-bit shifts, or SHR for word-level.

C

CODESYS

Use SHR() function in ST.

Common Applications

  • Bit field extraction
  • Fast division by powers of 2
  • Status word decoding
  • Protocol data unpacking
  • Byte extraction from words

Frequently Asked Questions

What is SHR (Shift Right) in PLC programming?

Shifts bits right by N positions. Equivalent to integer division by 2^N. The SHR (Shift Right) function shifts the bits of the input value to the right by a specified number of positions. Vacated bit positions on the left are filled with zeros (for unsigned types) or the sign bit (for signed types).

What are common applications of SHR (Shift Right)?

SHR (Shift Right) is commonly used for: Bit field extraction, Fast division by powers of 2, Status word decoding, Protocol data unpacking, Byte extraction from words.

How do I use SHR (Shift Right) in different PLC platforms?

Siemens: Use SHR instruction in TIA Portal. Allen-Bradley: Use BSR (Bit Shift Right) for single-bit shifts, or SHR for word-level. CODESYS: Use SHR() 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