L-force | plc designer – Lenze PLC Designer PLC Designer (R2-x) User Manual

Page 473

Advertising
background image

L-force | PLC Designer

IEC Operators and additional norm extending functions



DMS 3.2 EN 02/2011 TD29

471

Example in ST:

PROGRAM shr_st

VAR
in_byte : BYTE:=16#45;
in_word : WORD:=16#45;
erg_byte : BYTE;
erg_word : WORD;
n: BYTE :=2;
END_VAR

erg_byte:=SHR(in_byte,n); (* Result is 11 *)

erg_word:=SHR(in_word,n); (* Result is 0011 *)

Example in FBD:

Example in IL:

LD 16#45

SHR 2

ST erg_byte

9.4.3

ROL

PLC Designer IEC operator: Bitwise rotation of an operand to the left: erg:= ROL (in, n)

erg, in and n should be of the type BYTE, WORD or DWORD. in will be shifted one bit
position to the left n times while the bit that is furthest to the left will be reinserted
from the right.

Note!

Please note, that the amount of bits, which is regarded for the arithmetic operation,
is pretended by the data type of the input variable !. If the input variable is a
constant the smallest possible data type is regarded. The data type of the output
variable has no effect at all on the arithmetic operation.

See in the following example in hexadecimal notation that you get different results
for erg_byte and erg_word depending on the data type of the input variable (BYTE or
WORD), although the values of the input variables in_byte and in_word are the same.

Advertising