SHR

The IEC operator is used for bitwise shifting of an operand to the right.

Syntax: erg := SHR (in, n)

in: Operand that is moved to the right.

n: Number of bits in move to the right.

SHR 1:

If n exceeds the width of the data type, it depends on the target system how BYTE, WORD, DWORD and LWORD operands are populated. The target systems cause padding with zeros or with n MOD <register width>.

Examples:

ST:

PROGRAM Shr_st
VAR
    nInByte  :  BYTE:=16#45; (*2#01000101*)
    nInWord  :  WORD:=16#0045; (*2#0000000001000101*)
    nResByte :  BYTE;
    nResWord :  WORD;
    nVar : BYTE := 2; 
END_VAR

nResByte := SHR(nInByte,nVar); (*Result is 16#11, 2#00010001*)
nResWord := SHR(nInWord,nVar); (*Result is 16#0011, 2#0000000000010001*)

FBD:

SHR 2: