34
SECTION
1
Introductory
Concepts
Industrial Text & Video Company 1-800-752-8398
www.industrialtext.com
Number Systems
and Codes
CHAPTER
2
CHAPTER
HIGHLIGHTS
In this chapter, we will explain the number systems and digital codes that are
most often used in programmable controller applications. We will first
introduce the four number systems most frequently used during input/output
address assignment and programming: binary, octal, decimal, and hexadeci-
mal. Then, we will discuss the binary coded decimal (BCD) and Gray codes,
along with the ASCII character set and several PLC register formats. Since
these codes and systems are the foundation of the logic behind PLCs, a basic
knowledge of them will help you understand how PLCs work.
2-1 NUMBER SYSTEMS
A familiarity with number systems is quite useful when working with
programmable controllers, since a basic function of these devices is to
represent, store, and operate on numbers, even when performing the simplest
of operations. In general, programmable controllers use binary numbers in
one form or another to represent various codes and quantities. Although these
number operations are transparent for the most part, there are occasions where
a knowledge of number systems is helpful.
First, let’s review some basics. The following statements apply to any
number system:
• Every number system has a base or radix.
• Every system can be used for counting.
• Every system can be used to represent quantities or codes.
• Every system has a set of symbols.
The base of a number system determines the total number of unique symbols
used by that system. The largest-valued symbol always has a value of one less
than the base. Since the base defines the number of symbols, it is possible to
have a number system of any base. However, number system bases are
typically chosen for their convenience. The number systems usually
encountered while using programmable controllers are base 2, base 8, base
10, and base 16. These systems are called binary, octal, decimal, and
hexadecimal, respectively. To demonstrate the common characteristics of
number systems, let’s first turn to the familiar decimal system.
DECIMAL NUMBER SYSTEM
The decimal number system, which is the most common to us, was
undoubtedly developed because humans have ten fingers and ten toes. Thus,
the base of the decimal number system is 10. The symbols, or digits, used in
this system are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. As noted earlier, the total number
of symbols (10) is the same as the base, with the largest-valued symbol being