44 Chapter 3 Number Systems and Codes
3.1 Decimal System
Knowledge of different number systems and digital codes
is quite useful when working with PLCs or with most any
type of digital computer. This is true because a basic re-
quirement of these devices is to represent, store, and oper-
ate on numbers. In general, PLCs work on binary numbers
in one form or another; these are used to represent various
codes or quantities.
The decimal system, which is most common to us, has a
base of 10. The radix or base of a number system determines
the total number of different symbols or digits used by that
system. For instance, in the decimal system, 10 unique num-
bers or digits—i.e., the digits 0 through 9—are used: the
total number of symbols is the same as the base, and the
symbol with the largest value is 1 less than the base.
The value of a decimal number depends on the dig-
its that make up the number and the place value of each
digit. A place (weight) value is assigned to each position
that a digit would hold from right to left. In the decimal
system the rst position, starting from the rightmost po-
sition, is 0; the second is 1; the third is 2; and so on up
to the last position. The weighted value of each position
can be expressed as the base (10 in this case) raised to
the power of the position. For the decimal system then,
the position weights are 1, 10, 100, 1000, and so on. Fig-
ure3-1 illustrates how the value of a decimal number can
be calculated by multiplying each digit by the weight of
its position and summing the results.
3.2 Binary System
The binary system uses the number 2 as the base. The
only allowable digits are 0 and 1. With digital circuits it is
easy to distinguish between two voltage levels (i.e., 15 V
and 0 V), which can be related to the binary digits 1 and 0
( Figure 3-2 ). Therefore the binary system can be applied
quite easily to PLCs and computer systems.
Since the binary system uses only two digits, each
position of a binary number can go through only two
changes, and then a 1 is carried to the immediate left po-
sition. Table 3-1 shows a comparison among four com-
mon number systems: decimal (base 10), octal (base 8),
hexadecimal (base 16), and binary (base 2). Note that all
numbering systems start at zero.
The decimal equivalent of a binary number can be de-
termined in a manner similar to that used for a decimal
number. This time the weighted values of the positions
are 1, 2, 4, 8, 16, 32, 64, and so on. The weighted value,
instead of being 10 raised to the power of the position, is
2 raised to the power of the position. Figure 3-3 illustrates
how the binary number 10101101 is converted to its deci-
mal equivalent: 173.
Each digit of a binary number is known as a bit. In a
PLC the processor-memory element consists of hundreds
or thousands of locations. These locations, or registers,
Decimal Octal Hexadecimal Binary
0 . . . . . . 0 . . . . . . . . 0 . . . . . . . . . . 0
1 . . . . . . 1 . . . . . . . . 1 . . . . . . . . . . 1
2 . . . . . . 2 . . . . . . . . 2 . . . . . . . . . . 10
3 . . . . . . 3 . . . . . . . . 3 . . . . . . . . . . 11
4 . . . . . . 4 . . . . . . . . 4 . . . . . . . . . 100
5 . . . . . . 5 . . . . . . . . 5 . . . . . . . . . 101
6 . . . . . . 6 . . . . . . . . 6 . . . . . . . . . 110
7 . . . . . . 7 . . . . . . . . 7 . . . . . . . . . 111
8 . . . . . . 10 . . . . . . . . 8 . . . . . . . . 1000
9 . . . . . . 11 . . . . . . . . 9 . . . . . . . . 1001
10 . . . . . . 12 . . . . . . . . A . . . . . . . . 1010
11 . . . . . . 13 . . . . . . . . B . . . . . . . . 1011
12 . . . . . . 14 . . . . . . . . C . . . . . . . . 1100
13 . . . . . . 15 . . . . . . . . D . . . . . . . . 1101
14 . . . . . . 16
. . . . . . . . E
. . . . . . . . 1110
15 . . . . . . 17 . . . . . . . . F . . . . . . . . 1111
16 . . . . . . 20 . . . . . . . . 10 . . . . . . . . 10000
17 . . . . . . 21 . . . . . . . . 11 . . . . . . . . 10001
18 . . . . . . 22 . . . . . . . . 12 . . . . . . . . 10010
19 . . . . . . 23 . . . . . . . . 13 . . . . . . . . 10011
20 . . . . . . 24 . . . . . . . . 14 . . . . . . . . 10100
Table 3-1 Number System Comparisons
Figure 3-1 Weighted value in the decimal system.
2196
0321
2
60
900
1000
1962
2 10
6 10
9 10
1 10
0
1
2
3
2 1
6 10
9 100
1 1000
10
(Sum of products)
Decimal
number
10
Figure 3-2 Digital signal waveform.
+5
0
Volts
Time
High (H) (1)
Low (L) (0)
pet10882_ch03_043-056.indd 44pet10882_ch03_043-056.indd 44 7/23/10 9:09 PM7/23/10 9:09 PM