Page 68 - Programmable Logic Controllers, Fifth Edition - Mobile version
P. 68

15  14  13  12  11  10  9  8  7  6  5  4  3   2  1   0  Address
                                        1   1  0   0  0   0   1  0  1   1  1   1  0   0  0   1  O:1
                                        0   0  1   1  0   1   0  0  0   0  0   0  1   1  1   1  O:2
                                        1   0  1   0  1   1   0  0  1   1  1   0  0   0  0   1  O:3
                                        0   0  0   0  0   0   0  0  0   1  0   0  1   0  0   0  O:4
                                        1   1  1   0  1   0   0  1  1   1  0   0  1   1  0   1  O:5
                                       Figure 3-7  SLC 500 output status file.




                   These points are numbered 0 through 15 across the top   Another method of expressing a negative number in
                   row from right to left. The column on the far right lists the   a digital system is by using the complement of a binary
                   output module address. Although the table in Figure 3-7   number. To complement a binary number, change all the
                   illustrates sequentially addressed output status file words,   1s to 0s and all the 0s to 1s. This is known as the 1’s
                   in reality a word is created in the table only if the proces-  complement form of a binary number. For example, the
                   sor finds an output module residing in a particular slot. If   1’s complement of 1001 is 0110.
                   the slot is empty, no word will be created.             The most common way to express a negative binary
                                                                         number is to show it as a 2’s complement number. The
                   3.3  Negative Numbers                                 2’s complement is the binary number that results when
                                                                         1 is added to the 1’s complement. This system is shown
                   If a decimal number is positive, it has a plus sign; if a   in Table 3-3. A zero sign bit means a positive number,
                   number is negative, it has a minus sign. In binary number   whereas a 1 sign bit means a negative number.
                   systems, such as used in a PLC, it is not possible to use   Using the 2’s complement makes it easier for the PLC
                   positive and negative symbols to represent the polarity of   to perform mathematical operations. The correct sign bit
                   a number. One method of representing a binary number as   is generated by forming the 2’s complement. The PLC
                   either a positive or negative value is to use an extra digit,   knows that a number retrieved from memory is a nega-
                   or sign bit, at the MSB side of the number. In the sign bit   tive number if the MSB is 1. Whenever a negative num-
                   position, a 0 indicates that the number is positive, and a   ber is entered from a keyboard, the PLC stores it as a 2’s
                   1 indicates a negative number (Table 3-2).
                                                                         complement. What follows is the original number in true
                                                                         binary followed by its 1’s complement, its 2’s comple-
                                                                         ment, and finally, its decimal equivalent.
                     Table 3-2 Signed Binary Numbers
                          Magnitude                    Decimal           3.4  Octal System
                                Sign                    Value
                                                                         To express the number in the binary system requires
                                         0111                         +7
                                         0110                         +6  many more digits than in the decimal system. Too many
                                                                         binary digits can become cumbersome to read or write.
                                         0101                         +5
                          Same as        0100                         +4  To solve this problem, other related numbering systems
                          binary                                         are used.
                          numbers        0011                         +3   The octal numbering system, a base 8 system, is used
                                         0010                         +2  because 8 data bits make up a byte of information that
                                         0001                         +1  can be addressed. Octal is a convenient means of handling
                                         0000                           0  large binary numbers. As shown in Table 3-4, one octal
                                         1001                         −1  digit can be used to express three binary digits. As in all
                                         1010                         −2  other numbering systems, each digit in an octal number
                                         1011                         −3  has a weighted decimal value according to its position.
                                         1100                         −4  Figure 3-8 illustrates how the octal number 462 is con-
                                         1101                         −5  verted to its decimal equivalent: 306.
                                         1110                         −6   Octal converts easily to binary equivalents. For example,
                                         1111                         −7  the octal number 462 is converted to its binary equivalent
                                                                         by assembling the 3-bit groups, as illustrated in Figure 3-9.




                                                                                 Number Systems and Codes  Chapter 3     49







          pet73842_ch03_046-060.indd   49                                                                               03/11/15   3:50 PM
   63   64   65   66   67   68   69   70   71   72   73