L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 1056

Advertising
background image

L-force | PLC Designer

Programming Reference

1054

DMS 4.1 EN 03/2011 TD29

Example in ST:

PROGRAM rol_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:=ROL(in_byte,n); (* Result is 16#15 *)
erg_word:=ROL(in_word,n); (* Result is 16#0114 *)

Example in FBD:

Example in IL:

ROR
IEC Operator: Bitwise rotation of an operand to the right.

erg = ROR (in, n)

Allowed data types: BYTE, WORD, DWORD, LWORD.
in will be shifted one bit position to the right n times while the bit that is furthest to
the left will be reinserted from the left.

Note: Please note, that the amount of bits, which is noticed 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 noticed. 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