SHL block

Short summary

Name

SHL

→POU type

→function

Category

IEC-block, Bitstring

Conform to →IEC-standard

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/error.svg currently restricted
(IEC demands ANY_INT for the input N and an error handling in case of values < 0 for input N.)

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/add.svg more possible than defined in IEC-standard
(IEC demands ANY_BIT only for the input IN and the return value.)

Graphical interface

images/download/thumbnails/414781555/SHL-version-1-modificationdate-1535019068366-api-v2.png

Available since

  • version 1.10.0 (for logi.CAD 3) – initial variant: ANY_BIT for input IN and return value

  • version 1.23.0 (for logi.CAD 3) – enhancement: ANY_INT for input IN and return value

Functionality

The block returns the result of a bitwise shift to the left .

At input IN, enter the value to be shifted. At input N, enter the bits to left-shift the value. The bits cleared on the right are filled with 0.

Deviation from IEC-standard

If a negative value is connected to the input N, logi.CAD 3 does not treat this as an error but performs an opposite shift, hence a shift to the right. This behavior is a deviation from the →IEC-standard that specifies that values < 0 for the input N are an error .

Inputs, return value


Identifier

→Data type

Description

Inputs:

IN

BOOL, BYTE, WORD, DWORD or LWORD(corresponds to →generic data type ANY_BIT)
and
USINT, UINT, UDINT, ULINT, SINT, INT, DINT or LINT(corresponds to →generic data type ANY_INT)

input value

N

INT

number of bits to shift

Return value:

BOOL, BYTE, WORD, DWORD or LWORD(corresponds to →generic data type ANY_BIT)
and
USINT, UINT, UDINT, ULINT, SINT, INT, DINT or LINT(corresponds to →generic data type ANY_INT)


Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.

See:

Example for usage within ST-editor

PROGRAM Test
VAR
result1, result2 : BYTE;
END_VAR
result1 := SHL(IN := 16#40, N := 1); (* The variable 'result1' evaluates to '16#80'. *)
result2 := SHL(IN := 16#8, N := 1); (* The variable 'result2' evaluates to '16#10'. *)
END_PROGRAM

When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.