Su Chen Jonathon Lin

Programmable Logic Controllers


Скачать книгу

binary number of 150 expressed in 16-bit word is:

      00000000100101102

      Convert each bit of this binary number as below.

image

      The binary number for –15010 in one’s complement becomes

      –15010 = 11111111011010012

      The one’s complement of a negative number expressed in binary becomes a positive number with the same quantity. The one’s complement of a negative number is obtained in the same fashion.

       Example 3.14: Find the one’s complement of binary 11010101111110012 (-1075810)

      The procedure is listed below.

image

      The binary number for the one’s complement of –1075810 becomes

      +1075810 = 00101010000001102

       3.10.3The Two’s Complement Method

      The two’s complement method is similar to the one’s complement except that only those bits after the first 1 is detected are inverted. The first 1 is examined from right to left.

       Example 3.15: Find the two’s complement of +5010

      The binary number for 5010 is 1100102

      Fill in this binary number to a 16-bit word and convert the digits as follows:

image

      The binary number for the two’s complement of +5010 becomes

      –5010 = 11111111110011102

      If a negative number is given in two’s complement, its complement becomes a positive number. Its complement is derived in the same way.

       Example 3.16: Find the two’s complement of a negative number –2110

      The binary number of –2110 given in two’s complement is

      1111111111101011

      Convert the binary number as follows:

image

      The two’s complement of –2110 becomes:

      +2110 = 00000000000101012

      A floating-point number consists of two parts: whole number and decimal fraction. The number 648.35 is an example of a floating-point number with 648 being the whole number and 0.35 being the decimal fraction. Floating-point numbers provide a greater accuracy for arithmetic calculations and measured quantities.

      Scientific notation is a common form of expressing very large or very small numbers. It expresses numbers in two parts: fractional part and power of ten. Some examples are:

4.56789 x 104for 45678.9
2.356 x 10-5for 0.00002356

      The floating-point format is very similar to scientific notation. It also consists of two parts: mantissa and exponent. The mantissa has a fixed number of digits to express the significant digits of the number. The exponent has two digits for expressing the signed power of ten. It determines the direction and the number of places the decimal point must be moved with respect to the most significant digit for finding the actual decimal number being expressed. Table 3.12 shows the floating-point expression with its corresponding decimal and scientific notation.

      PLCs use two words to represent a floating-point number in binary (Figure 3.10). The numbers are stored in memory in 3 parts — the sign, the exponent, and the mantissa; the base is assumed to be 2 or binary.

      IEEE Standard 754 is a technical standard for floating-point computation established in 1985 by the Institute of Electrical and Electronics Engineers (IEEE). IEEE floating-point numbers have three basic components: the sign, the exponent, and the mantissa.

      Table 3.12: Floating point, decimal, and scientific notation

DecimalFloating-PointScientific Notation
9876.549.87654 +039.87654 x 103
0.0003453.45000 -043.45000 x 10-4
–23.456–2.34560 +01–2.34560 x 101
–0.004567–4.56700 -03–4.56700 x 10-3
image

      Figure 3.10: Representing a fl oating-point number in binary

       3.11.1The Sign Bit

      The sign bit is the most significant bit. The value of 0 denotes a positive number; 1 denotes a negative number.

       3.11.2The Exponent

      The exponent field needs to represent both positive and negative exponents. To do this, a bias is added to the actual exponent in order to get the stored exponent.

       3.11.3The Mantissa

      The mantissa, also called the significand, represents the precision bits of the number. It is composed of an implicit leading bit and the fraction bits. To find out the value of the implicit leading bit, consider that any number can be expressed in scientific notation in many different ways. For example, the number 5.6 can be represented as any of these:

      5.6 x 100

      0.056 x 102

      5600 x 10-3

      In order to maximize the quantity of representable numbers, floating-point numbers are typically stored in normalized form. This puts the radix point after the first non-zero digit. In normalized form, 5.6 is represented as 5.6 x 100.

       Example 3.17: Find the effective range

      6497.3 = 6.4973 x 103

      0.000075 = 7.5 x 10-5

      The effective range of IEEE floating-point numbers:

BinaryDecimal
Single precision (32 bits)± (2 – 2-23) x 2127~ ± 1038.53

      Review Questions

      1. Describe the characteristics of a number system.

      2. What is the base number of a number system?

      3. What four number systems do PLCs use?

      4. List the counting symbols of the binary system.

      5. List the counting symbols of the octal system.

      6. List the counting symbols of the decimal system.

      7. List the counting symbols of the hexadecimal system.

      8. Write the corresponding binary numbers of the decimal numbers from 0 to 10.

      9. What is the octal number system?

      10. Write the corresponding octal numbers of the decimal numbers from 0 to 15.

      11. Write the corresponding binary numbers of the octal numbers from 0 to 17.

      12. Convert the octal number 34748 to its equivalent decimal number.

      13. Write the corresponding hexadecimal numbers of the