Discrete Transfer Commands
15
3.3
Bit Shifting
The Remote I/O Interface supports bit shifting of up to 7 bits for values returned in signed 16-bit format, or 4 bits
for values returned in the unsigned 20-bit format. Maximum values are limited by the 7-digit capacity of the
indicators.
Table 3-9 shows an example of a 20-bit value with 4-bit bit shifting. The maximum possible value of the 20-bit
number is increased from 1,048,575 without shifting to 16,777,200 with 4-bit bit shifting. The number shown
above each bit position represents the value of that bit if the bit is set to 1. The maximum value that can be
returned in a given number of bits, n, is the sum of these values, or 2
n
– 1.
Table 3-10 shows the maximum values and resolutions possible for signed 16-bit and unsigned 20-bit values.
Maximum resolved values compensate for the discarded low order (shifted-out) bits.
For example, a signed 16-bit value contains 15 data bits (the 16th bit is used as a sign bit). The maximum value
that can be returned in 15 bits is 2
15
– 1, or 32,767.
With bit shifting, the maximum value that can be returned is increased to (2
n+b
– 1) – (2
b
– 1), where n is the
number of data bits (15 or 20) and b is the number of bits shifted. For 4-bit bit shifting using 16-bit format, the
maximum value that can be returned is (2
15+4
– 1) – (2
4
– 1), or 524,272.
8 388 608
4 194 304
2 097 152
1 048 576
524 288
262 144
131 072
65 536
32 768
16 384
8 192
4 096
2 048
1024
512
256
128
64
32
16
8
4
2
1
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
<<<< Bit Shift = 4
Table 3-9. 20-bit Value with 4-bit Bit Shift
Format
Bit Shift
Maximum
Shifted Value (±)
Resolution
Maximum
Resolved Value (±)
16-bit
(includes sign bit)
0
N/A
1
32 767
1
65 535
2
65 534
2
131 071
4
131 068
3
262 143
8
262 136
4
524 287
16
524 272
5
1 048 575
32
1 048 544
6
2 097 151
64
2 097 088
7
4 194 303
128
4 194 176
20-bit 0
N/A
1
1 048 575
1
2 097 151
2
2 097 150
2
4 194 303
4
4 194 300
3
8 388 607
8
8 388 600
4
16 777 215
16
16 777 200
Table 3-10. Maximum Values for 16- and 20-bit Format Values Using Bit Shifting
DISCONTINUED