Page 66 - Programmable Logic Controllers, Fifth Edition
P. 66

3.1  Decimal System
                                                                                +5                              High (H)  (1)
                   Knowledge of different number systems and digital codes   Volts
                   is quite useful when working with PLCs or with almost                                        Low (L)  (0)
                   any type of digital computer. This is true because a basic    0            Time
                   requirement of these devices is to represent, store, and op-
                   erate on numbers. In general, PLCs work on binary num-  Figure 3-2  Digital signal waveform.
                   bers in one form or another; these are used to represent
                   various codes or quantities.                          changes, and then a 1 is carried to the immediate left po-
                     The decimal system, which is most common to us, has   sition. Table 3-1 shows a comparison among four com-
                   a base of 10. The radix or base of a number system de-  mon number systems: decimal (base 10), octal (base 8),
                   termines the total number of different symbols or digits   hexadecimal (base 16), and binary (base 2). Note that all
                   used by that system. For instance, in the decimal system,    numbering systems start at zero.
                   10 unique numbers or digits—i.e., the digits 0 through 9—  The decimal equivalent of a binary number can be de-
                   are used: the total number of symbols is the same as the base,   termined in a manner similar to that used for a decimal
                   and the symbol with the largest value is 1 less than the base.  number. This time the weighted values of the positions
                     The value of a decimal number depends on the dig-   are 1, 2, 4, 8, 16, 32, 64, and so on. The weighted value,
                   its that make up the number and the place value of each   instead of being 10 raised to the power of the position, is
                   digit. A place (weight) value is assigned to each position   2 raised to the power of the position. Figure 3-3 illustrates
                   that a digit would hold from right to left. In the decimal   how the binary number 10101101 is converted to its deci-
                   system the first position, starting from the rightmost po-  mal equivalent: 173.
                   sition, is 0; the second is 1; the third is 2; and so on up   Each digit of a binary number is known as a bit. In a
                   to the last position. The weighted value of each position   PLC the processor-memory element consists of hundreds
                   can be expressed as the base (10 in this case) raised to   or thousands of locations. These locations, or registers,
                   the power of the position. For the decimal system then,
                   the position weights are 1, 10, 100, 1000, and so on.
                   Figure 3-1 illustrates how the value of a decimal number   Table 3-1 Number System Comparisons
                   can be calculated by multiplying each digit by the weight
                   of its position and summing the results.              Decimal       Octal       Hexadecimal       Binary
                                                                             0                       0                           0                               0
                   3.2  Binary System                                        1                       1                           1                                1

                   The binary system uses the number 2 as the base. The      2                       2                           2                              10
                   only allowable digits are 0 and 1. With digital circuits it is   3                       3                            3                              11
                   easy to distinguish between two voltage levels (i.e., +5 V   4                       4                            4                            100
                   and 0 V), which can be related to the binary digits 1 and 0   5                       5                            5                            101
                   (Figure 3-2). Therefore, the binary system can be applied   6                       6                            6                            110
                   quite easily to PLCs and computer systems.                7                       7                            7                            111
                     Since the binary system uses only two digits, each      8                     10                            8                          1000
                   position of a binary number can go through only two
                                                                             9                     11                            9                          1001
                                                                            10                     12                            A                          1010
                      Decimal                                               11                     13                            B                          1011
                      number                                                12                     14                            C                          1100
                             3  2  1  0
                                                                            13                     15                            D                          1101
                             1  9  6  2
                                        10                                  14                     16                            E                          1110
                                              0
                                          2 × 10 = 2 ×  1  =  2             15                     17                            F                          1111
                                              1
                                          6 × 10   = 6 ×  10  =  60         16                     20                          10                        10000
                                              2
                                          9 × 10 = 9 × 100  =  900          17                     21                         11                        10001
                                              3
                                          1  × 10 = 1  × 1000  =  1000
                                                                            18                     22                         12                        10010
                                                          1962 10
                                                      (Sum of products)     19                     23                         13                        10011
                                                                            20                     24                         14                        10100
                   Figure 3-1  Weighted value in the decimal system.

                                                                                 Number Systems and Codes  Chapter 3     47







          pet73842_ch03_046-060.indd   47                                                                               03/11/15   3:50 PM
   61   62   63   64   65   66   67   68   69   70   71