Page 70 - Programmable Logic Controllers, Fifth Edition
P. 70
Table 3-5 Hexadecimal Numbering 3.6 Binary Coded Decimal (BCD)
System System
Hexadecimal Binary Decimal The binary coded decimal (BCD) system provides a
convenient way of handling large numbers that need to be
0 0000 0 input to or output from a PLC. As you can see from look-
1 0001 1 ing at the various number systems, there is no easy way
2 0010 2 to go from binary to decimal and back. The BCD system
3 0011 3 provides a means of converting a code readily handled
4 0100 4 by humans (decimal) to a code readily handled by the
5 0101 5 equipment (binary). PLC thumbwheel switches and LED
6 0110 6 displays are examples of PLC devices that make use of
7 0111 7 the BCD number system. Table 3-6 shows examples of
8 1000 8 numeric values in decimal, binary, BCD, and hexadeci-
9 1001 9 mal representation.
A 1010 10 The BCD system uses 4 bits to represent each deci-
B 1011 11 mal digit. The 4 bits used are the binary equivalents of
C 1100 12 the numbers from 0 to 9. In the BCD system, the larg-
est decimal number that can be displayed by any four
D 1101 13 digits is 9.
E 1110 14 The BCD representation of a decimal number is ob-
F 1111 15 tained by replacing each decimal digit by its BCD equiva-
lent. To distinguish the BCD numbering system from a
binary system, a BCD designation is placed to the right
1 B 7 of the units digit. The BCD representation of the decimal
number 7863 is shown in Figure 3-12.
Hex 7 × 16 = 7 × = A thumbwheel switch is one example of an input de-
0
number 1 7
11 × 16 1 = 11 × 16 = 176 vice that uses BCD. Figure 3-13 shows a single-digit
BCD thumbwheel. The circuit board attached to the
1 × 16 2 = 1 × 256 = 256 thumbwheel has one connection for each bit’s weight
Decimal number 439 10 plus a common connection. The operator dials in a dec-
(Sum of products) imal digit between 0 and 9, and the thumbwheel switch
outputs the equivalent 4 bits of BCD data. In this
Figure 3-10 Converting a hexadecimal number to a
decimal number. example, the number eight is dialed to produce the input
bit pattern of 1000. A four-digit thumbwheel switch,
number to its decimal equivalent, the hexadecimal digits similar to the one shown, would control a total of
in the columns are multiplied by the base 16 weight, de- 16 (4 × 4) PLC inputs.
pending on digit significance. Figure 3-10 illustrates how Scientific calculators are available to convert num-
the conversion would be done for the hex number 1B7. bers back and forth between decimal, binary, octal, and
Hexadecimal numbers can easily be converted to bi- hexadecimal. In addition, PLCs contain number conver-
nary numbers. Conversion is accomplished by writing the sion functions such as illustrated in Figure 3-14. BCD-
4-bit binary equivalent of the hex digit for each position, to-binary conversion is required for the input while
as illustrated in Figure 3-11. binary-to-BCD conversion is required for the output. The
Convert-to-BCD instruction will convert the binary bit
pattern at the source address, N7:23, into a BCD bit pat-
Hex number 1 B 7
tern of the same decimal value and store it at the destina-
tion address, O:20. The instruction executes every time it
Binary is scanned, and the instruction is true.
0 0 0 1 1 0 1 1 0 1 1 1
number Many PLCs allow you to change the format of the data
Figure 3-11 Converting a hexadecimal number to a binary that the data monitor displays. For example, the change
number. radix function found on Allen-Bradley controllers allows
Number Systems and Codes Chapter 3 51
pet73842_ch03_046-060.indd 51 03/11/15 3:50 PM