Programmable Logic Controllers. Su Chen Jonathon Lin
Чтение книги онлайн.
Читать онлайн книгу Programmable Logic Controllers - Su Chen Jonathon Lin страница 15
The sum of the weights method is used to compute the value of a number. The value of a decimal number is computed by multiplying each digit by its corresponding place value and adding the results. The number 8357, for instance, can be expressed as 8(1000) + 3(100) + 5(10) + 7(1).
3.3 Binary Number System
The binary number system uses the number 2 as the base. It has only two symbols: 0 and 1. The binary is the main number system used in digital devices including computers and PLCs. The binary number can be readily applied to such devices that operate on only two states: a switch is ON or OFF; a valve is Open or Closed, etc. The two states of binary are normally distinguished by two voltage levels: +5V and 0V. The 0 (or low) volt represents binary 0 and +5 (or high) volts represents the binary 1.
Any number greater than 1 is expressed in multiple digits in binary number system. A place value is assigned to each position starting from right to left. The place value is computed as the base 2 raised to the power of the position. Table 3.3 illustrates the position, place value, and place value as power of 2 of binary numbers.
Table 3.2 Position and place values of decimal number system
Table 3.3: Position and place value of binary numbers
Table 3.4 shows the corresponding binary numbers of some decimal numbers. All binary numbers are represented using only ones and zeros
Each digit of a binary number is referred to as a bit. The term BIT comes from the contraction of two words Binary digIT. A binary number 110011 has 6 bits. A group of 8 bits is a byte. A word normally consists of 2 bytes (16 bits). Bytes and words are the most commonly used units for storing and manipulating digital data. Figure 3.1 shows a word of 2 bytes (or 16 bits). The right-most bit is the least significant bit (LSB) and the left-most bit is the most significant bit (MSB). The decimal equivalent of a binary number can be computed by multiplying each binary digit by its corresponding place value and summing the results of each position. The decimal equivalent of a binary number 11001 becomes 25 (or 16 + 8 + 0 + 0 + 1).
Table 3.4: Binary and decimal numbers
Decimal | Binary |
---|---|
0 | 0 |
1 | 1 |
2 | 10 |
3 | 11 |
4 | 100 |
5 | 101 |
6 | 110 |
7 | 111 |
8 | 1000 |
9 | 1001 |
10 | 1010 |
Figure 3.1: A 2-byte word
3.4 Octal Number System
The octal number system uses the number 8 as its base. It has eight unique counting symbols (0, 1, 2, 3, 4, 5, 6, and 7). Table 3.5 shows octal numbering with their decimal and binary equivalents.
Each digit in an octal number has a place value that is a power of eight raised to n (or 8n), where n is the position, as shown in Table 3.6.
The octal number 25738 is equivalent to the decimal number 1403 (or 1024 + 320 + 56 + 3). Its conversion is shown below.
We can express 25738 = 140310.
The octal numbering system uses one digit to represent three binary digits (or bits). In this way, a large binary number can be readily represented by an octal number with much fewer digits (Figure 3.2). As can be seen, that one 15-bit binary number is expressed by a 5-digit octal number.
Table 3.5: Octal numbering with decimal and binary equivalents
Octal | Decimal | Binary |
---|---|---|
0 | 0 | 0 |
1 | 1 | 1 |
2 | 2 | 10 |
3 | 3 | 11 |
4 | 4 | 100 |
5 | 5 | 101 |
6 | 6 | 110 |
7 | 7 | 111 |
10 | 8 | 1000 |
11 | 9 | 1001 |
12 | 10 | 1010 |
13 | 11 | 1011 |
14 | 12 | 1100 |
15 | 13 | 1101 |
16 | 14 | 1110 |
17 | 15 | 1111 |
3.5 Hexadecimal Number System
The hexadecimal number system uses the number 16 as its base. It has sixteen unique counting symbols, the numerals 0 – 9 and the letters A – F. Table 3.7 shows hexadecimal numbering with their decimal and binary equivalents.
Each digit in a hexadecimal number has a place value 16n that is a power of sixteen raised to n, where n is the position as shown in Table 3.8.
Table 3.6: Place values of octal numbers
Figure 3.2: An octal number
The hexadecimal number 23B16 is equivalent to the decimal number 57110 (or 512 + 48 + 11). Its conversion is shown below:
The decimal equivalent of 23B16 = 57110.
The hexadecimal numbering system uses one digit to represent four binary digits (or bits). In this way, a very large binary number can be concisely represented by a hexadecimal number with very few digits (Figure 3.3). In this example, one 16-bit binary number is expressed by a 4-digit hexadecimal number.
Table 3.7:: Hexadecimal numbering with decimal and binary equivalents
Hexadecimal | Decimal | Binary |
---|---|---|
0 | 0 | 0 |
1 | 1 | 1 |
2 | 2 | 10 |
3 | 3 | 11 |
4 | 4 | 100 |
5 | 5 | 101 |
6 | 6 | 110 |
7 | 7 | 111 |
8 | 8 | 1000 |
9 | 9 | 1001 |
A | 10 | 1010 |
B | 11 | 1011 |
C | 12 | 1100 |
D | 13 | 1101 |
E | 14 | 1110 |
F | 15 | 1111 |
3.6 Number Conversions
The same numerical quantity can be expressed in different numbering systems and their expressions are equivalent to each other. To facilitate the number conversions in various numbering systems, numbers need to be expressed with their numbering base. A numerical quantity of 12 is expressed in four number systems as follows:
1210 = 148 = C16 = 11002
Table 3.8: Place values of hexadecimal numbers