numbers.
Explain the octal number system and its equivalency with decimal numbers and binary numbers.
Explain the hexadecimal number system and its equivalency with decimal numbers and binary numbers.
Identify the techniques of number conversions between two number systems.
Convert decimal numbers to their binary, octal, and hexadecimal equivalents.
Convert binary numbers to decimal, octal, and hexadecimal equivalents.
Convert octal and hexadecimal to binary.
Identify three binary coding standards.
Understand the ASCII code.
Explain BCD code and its use.
Explain Gray code and its use.
Describe the data structure for PLC data.
Know how PLC handles signed and unsigned numbers.
Use one’s complement and two’s complement to represent negative numbers.
Identify the floating-point decimal numbers.
Overview
PLCs use numbers to implement control functions. We will introduce four commonly used number systems, digital code standards, and PLC data formats in this chapter. The four number systems are binary, octal, decimal, and hexadecimal systems. Number conversions between two different number systems are presented. The digital code standards include binary coded decimal (BCD), Gray code, and ASCII code. The format in which data is represented determines how the binary pattern is to be interpreted. The basic word format, decimal numbers, negative numbers, and floating point decimal numbers to represent numeric values in PLCs are presented.
3.1 Number Systems
PLCs are digital machines that rely on numbers to implement their basic operations and store various types of information. A number system is a standardized scheme whereby a fixed set of symbols is used to represent numeric values. Each number system has the following characteristics:
•Has a base number
•Has a set of symbols
•Is used for counting
The base number or radix of a number system determines the maximum number of unique symbols used by that number system. The base 10 number system, for instance, has the number 10 as its base and has ten unique symbols, 0 through 9. The largest valued symbol has a value of one less than the base.
PLCs use four number systems: base 2, base 8, base 10, and base 16. These four number systems are also referred to as binary (base 2), octal (base 8), decimal (base 10), and hexadecimal (base 16). Table 3.1 summarizes the base and counting symbols of these four commonly used number systems.
Extra digits are used to express any number that is greater than the base number. The place value, also referred to as position weight, is used to assign a value to each position of a number. The second digit from the right in a base 10 number, for instance, is assigned a place value of 10. The third digit from the right in a base 10 number has a place value of 100.
Table 3.1: Four number systems
Number System | Base | Counting Symbols |
---|---|---|
Binary | 2 | 0, 1 |
Octal | 8 | 0, 1, 2, 3, 4, 5, 6, 7 |
Decimal | 10 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 |
Hexadecimal | 16 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F |
3.2 Decimal Number System
The decimal number system uses the base number 10. It has a total of 10 unique symbols (0, 1, 2, 3, 4, 5, 6, 7, 8, and 9) to count the numbers. Multiple-digit numbers are used to count any number greater than 9. The position of each digit in a number determines its weighted value. The zero position is the right-most position and increments by one to the left. The right-most position is the least significant position, and the left-most is the most significant position. The weighted-value of each position can be expressed as the base raised to the power of position. In decimal number system, the position weights from right to left are 1 (or 100), 10 (or 101), 100 (or 102), 1000 (or 103), etc. Table 3.2 illustrates the position, place value, and place value as power of 10 for decimal number system.
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