Functions ► ET/MT-3x6, ET/MT-2x8 ► Scale ► Shift and mask
Can be programmed for:
only ET - / MT - 208 from SPSPlusWIN 5.4.1. onwards
This function can be programmed for an analogue variable.
With this function, you may shift a bit pattern allocated to this variable
b) | to mask it with a bit pattern. |
c) | or to shift it by n bits and to mask it with a bit pattern. |

The variable can have the following formats:
Byte
|
Integer
|
Unsigned integer
|
Long integer
|
Unsigned long integer
|
Function parameters:
Bits to shift
|
Number of bits by which the incoming value is to be shifted.
If the value = 0, no bits are shifted.
|
Bits to mask (decimal)
|
Decimal value with which the incoming value (or the value of the bit shift)
is to be masked (AND linked). If the value = 0 there will be no masking.
|
The following examples show the result and their binary actions
for the transferred value *1 for different actions and masking values:
|
Decimal
|
Hex value
|
Binary
|
Original value *1
|
4095
|
0FFF
|
0000111111111111
|
Action
|
Result
|
Decimal
|
Hex value
|
Binary
|
Shift +4
|
255
|
00FF
|
*1 0000111111111111
4→ 0000000011111111
|
Shift -4
|
65520
|
FFF0
|
*1 0000111111111111
4← 1111111111110000
|
Mask *2
|
4080
|
0FF0
|
*1 0000111111111111
ᐱ 1111111111110000
|
= 0000111111110000
|
Shift +4 & Mask *3
|
15
|
000F
|
*1 0000111111111111
4→ 0000000011111111
|
ᐱ 0000000000001111
|
0000000000001111
|
Shift -4 & Mask *4
|
240
|
00F0
|
*1 0000111111111111
4← 1111111111110000
|
ᐱ 0000000011111111
|
0000000011110000
|
Masking value
|
Decimal
|
Hex value
|
Binary
|
*2
|
65520
|
0FFF
|
1111111111110000
|
*3
|
15
|
000F
|
0000000000001111
|
*4
|
255
|
00FF
|
0000000011111111
|
<< return
|