ROL
Function Name |
ROL (Rotate Left) |
---|---|
Description |
Rotates each bit n positions to the left. So, rotating by 1 means the first bit in the string becomes the last bit in the string, the second bit becomes the new first bit and so on. |
Arguments |
IN {ANY_BIT} IN is a bit string. N {ANY_INT} N is an integer that defines the number of positions the ROL function will move the characters. For more information on the data types for the inputs and outputs, see Data Type Hierarchy. |
Returns |
Output {Same data type as input} The Output is the number that represents the new binary string. |
Example:
Function Block Diagram - ROL:
The ROL function has two inputs. The top input (IN) is 146 which corresponds to the binary string of 10010010. The bottom input (N) is 3 which instructs the function to rotate the bits left by 3 positions. The output is 148 which corresponds to the binary string 10010100. So, the ROL function has rotated the bits 3 positions to the left:
Input String |
10010010 |
Rotation Left x3 |
10010100 |
ST Program - ROL:
The ROL function is used to rotate the positions of the bits in the Input string to the left:
- Output := ROL (IN, N);
Where Output, IN and N are defined as variables earlier in the ST program.
Alternatively, you can use the following syntax:
- Output := ROL (IN:= 146, N:= 3);
Where the numbers are the input values (in this case, they are the same numbers as used in the Function Block Diagram example).