Block that performs a binary logical left shift operation in a value passed by Value, storing the result in Result.
Ladder Representation

Block Structure
Variable Type |
Name |
Data Type |
Description |
VAR_INPUT |
EN |
BOOL |
Block enabling |
Value |
BYTE USINT SINT WORD UINT INT DWORD UDINT DINT |
Variable to undergo shift |
|
Shift |
BYTE USINT |
Shift index |
|
VAR_OUTPUT |
ENO |
BOOL |
End of operation |
Result |
BYTE USINT SINT WORD UINT INT DWORD UDINT DINT |
Variable that stores the result of the operation |
Operation
When this block has a TRUE value in EN, it sends to the Result output the value of the Value variable after performing a number of logical shifts left, according to the Shift value.
When EN has FALSE value, Result remains unchanged.
The ENO value forwards to the next Ladder block the EN value after the operation is completed.
Block Flowchart

Example in Ladder

The above example performs a logical right shift by four positions in the VALUE variable whose initial value is 56 (0011 1000 in binary). The bits on the left are being discarded, and on the left new zeros are inserted. The final result (0011 1000 0000 in binary) is stored in RESULT.

The above example performs a logical right shift by four positions in the VALUE variable whose initial value is -56 (1100 1000 in binary). The bits on the left are being discarded, and on the left new zeros are inserted. The final result (1100 1000 0000 in binary) is stored in RESULT. Since RESULT is SINT type, it only accepts the first eight bits (1000 0000).
Example in ST
The example below displays the instructions for applying the example above in the ST language.
VAR VALUE : SINT := -56; SHIFT : USINT := 4; RESULT : SINT; END_VAR
RESULT := FB_SHL( EN:=DI1, Value:=VALUE, Shift:=SHIFT, ENO=>DO1);
|
|---|