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

Binary                                                        Bits
                   number                                                        15 14 13 12 11 10 98 76 54 32 10
                    7  6  5  4  3  2  1  0                                  0000
                                                                            0001
                    1  0  1  0  1  1  0  1
                                        2                                   0002
                                            0
                                         1  × 2 = 1  ×  1   =  1
                                            1
                                         0 × 2 = 0 ×  2  =  0               0003
                                            2
                                         1  × 2 = 1  ×  4  =  4             0004  01 10 01 10 00 111 01 1
                                            3
                                         1  × 2 = 1  ×  8  =  8             0005
                                            4
                                         0 × 2 = 0 × 16   =  0
                                            5
                                         1  × 2 = 1  × 32  =  32             1018
                                            6
                                         0 × 2 = 0 × 64  =  0                1019
                                            7
                                         1  × 2 = 1  × 128   =  128          1020
                                     Decimal  number   173 10                1021
                                                  (Sum of products)          1022
               Figure 3-3  Converting a binary number to a decimal number.   1023
                                                                            Word
                                                                            Addresses
               are referred to as words. Each word is capable of storing   Figure 3-5  1-K word memory.
               data in the form of binary digits, or bits. The number of
               bits that a word can store depends on the type of PLC sys-
               tem used. Sixteen-bit and 32-bit words are the most com-  there is a remainder, it is placed in the LSB of the binary
               mon. Bits can also be grouped within a word into bytes.   number. If there is no remainder, a 0 is placed in the LSB.
               A group of 8 bits is a byte, and a group of 2 or more bytes   The result of the division is brought down and the pro-
               is a word. Figure 3-4 illustrates a 16-bit word made up   cess is repeated until the result of successive divisions has
               of 2 bytes. The least significant bit (LSB) is the digit that   been reduced to 0.
               represents the smallest value, and the most significant bit   Even though the binary system has only two digits, it
               (MSB) is the digit that represents the largest value. A bit   can be used to represent any quantity that can be repre-
               within the word can exist only in two states: a logical 1 (or   sented in the decimal system. All PLCs work internally in
               ON) condition, or a logical 0 (or OFF) condition.     the binary system. The processor, being a digital device,
                  PLC memory is organized using bytes, single words,   understands only 0s and 1s, or binary.
               or double words. Older PLCs use 8-bit or 16-bit memory   Computer memory is, then, a series of binary 1s and 0s.
               words while newer systems, such as the ControlLogix plat-  Figure 3-7 shows the output status file for an Allen-Bradley
               form from Allen-Bradley, use 32-bit double words. The   SLC 500 modular chassis, which is made up of single
               size of the programmable controller memory relates to the   bits grouped into 16-bit words. One or more 16-bit out-
               amount of user program that can be stored. If the mem-  put file word is reserved for each slot in the chassis. Each
               ory size is 1 K word (Figure 3-5), it can store 1024 words   bit represents the ON or OFF state of one output point.
               or 16,384 (1024 × 16) bits of information using 16-bit
               words, or 32,768 (1024 × 32) bits using 32-bit words.      Decimal number
                  To convert a decimal number to its binary equivalent,
               we must perform a series of divisions by 2. Figure 3-6      47  ÷ 2 = 23 with a remainder of  1  LSB
               illustrates the conversion of the decimal number 47 to        23  ÷ 2 = 11  with a remainder of  1
               binary. We start by dividing the decimal number by 2. If
                                                                             11  ÷ 2 =  5 with a  remainder  of  1
                                                                              5  ÷ 2 =  2 with a  remainder  of  1
                 MSB                           Bit           LSB              2  ÷ 2 =  1  with a  remainder  of  0

                  0  1  1  0  0  1  1  0  0  0  1  1  1  0  1  1              1  ÷ 2 =    with a remainder of  1  MSB
                         Upper byte              Lower byte
                                                                                               Binary number   101111
                                     16-bit word
                                                                     Figure 3-6  Converting a decimal number to a binary
               Figure 3-4  A 16-bit word.                            number.





               48         Chapter 3  Number Systems and Codes







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