beautypg.com

Hex mask – Rockwell Automation 1747-PT1, D1747NP002 Hand-Held Terminal User Manual

Page 453

background image

Appendix B
Number Systems, Hex Mask

B–5

Hexadecimal and binary numbers have the following equivalence:

1

2

8 A

0

0

1 0

0

0

0 1

0

1

0 0

0

1

1 0

8192

1x2

13

256

1x2

8

128

1x2

7

10

1x2

3

+1x2

1

Binary

= 8586

Hexadecimal

= 8586

Example: Decimal number –8586 in equivalent binary and hexadecimal
forms:

1

1

0 1

1

1

1 0

1

0

1 1

1

0

1 0

Binary

= –8586

E

D

7 6

Hexadecimal

= 56950
(negative number, –8586)

Hex number DE76 = 13x16

3

+14x16

2

+7x16

1

+6x16

0

= 56950. This is a

negative number because it exceeds the maximum positive value of 32767.
To calculate its value, subtract 16

4

(the next higher power of 16) from 56950:

56950 – 65536 = –8586.

This is a 4-character code, entered as a parameter in SQO, SQC, and other
instructions to exclude selected bits of a word from being operated on by the
instruction. The hex values are used in their binary equivalent form, as
indicated in the figure below. The figure also shows an example of a hex
code and the corresponding mask word.

0

0

F F

0

0

0 0

0

0

0 0

1

1

1 1

1

1

1 1

Hex Code

Mask Word

Hex

Value

0
1
2
3
4
5
6
7
8
9

A
B
C
D
E

F

Binary

Value

0000
0001
0010
0011
0100
0101
0110

0111

1000
1001
1010
1011
1100
1101

1110
1111

Hex Mask