Chapter 03 Sect. 3-1 to 3-3
Supplement and Reinforcement of
Number Systems
Why Do I Have To Learn
About Number Systems
 If you are taking a trip to a
foreign country you would
probably want to learn some
of the language that is spoken
in that country. After all, it
would be nice to be able to
order a nice dinner or ask for
the location of a restroom.
 Working with computers and
PLCs is like visiting a foreign
country. The language
spoken in these countries is
numbers, therefore it is a
good idea to learn some of
the language.
Number Systems
 Decimal
 Binary
 Octal
 Hexadecimal
 These are the number systems we will be
studying
 Learn them well, because they WILL
keep coming back to haunt you.
Decimal System
 The decimal number system is the most common
numbering system. It’s the number system we use
everyday.
 Number systems have a base or radix. The radix
determines the total number of different symbols, or
digits used by the system.
 Decimal is a Base-10 numbering system, therefore there
are 10-digits starting with the number zero.
 Valid numbers in the decimal system are:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
 Base-10 numbers can be written; as an example: 410 or
4d
Decimal System
 Each digit in a number system has a weight value
assigned to it.
 Decimal is a Base-10 number system, therefore the
weight of each digit of a number is 10 raised to the
power of the digit position.
 The first digit on the right is position zero, the next digit
to the left is position one, to the left again is position two,
etc.
 The value of the decimal number is calculated by
multiplying the digit value of each position by10 to the
power of that position number and summing the
products.
What was just said???
Decimal System
5 3 1 9
3 2 1 0
9 * 100  9 * 1 = 9
1 * 101  1 * 10 = 10
3 * 102  3 * 100 = 300
5 * 103  5 * 1000 = 5000
531910Sum of the products
The base (radix) of the number system.
For Base-10 it is normally not shown. It is
shown here as an example.
Position Number
Base or
Radix is 10
Decimal Number
Binary System
 The binary number system is used by computers, PLCs, PACs and
any other digital and µP controlled device.
 Bi means two, therefore the valid numbers in the binary system are:
0 and 1.
 One digit of a binary number is called a Bit (BOOL data type).
 A group of 4-Bits is called a Nibble (term is not often used).
 A group of 8-Bits is called a Byte (SINT or BYTE data type).
 A group of 16-Bits is called a Word (WORD or Integer (INT) data
type).
 A group of 32-Bits is called a Double Word or DWORD. (DWORD
or DINT data type).
 A group of 64-Bits is called a Quad Word or QWORD.
 A group of 128-Bits is called a Double Quad Word or DQWORD
 The binary number system is used in computers and PLCs because
bits can be represented as voltage levels within the computer. A
zero = 0VDC or GND, a one = +VDC.
Binary System
 Each bit in the binary system has a weight assigned to it.
 Binary is a Base-2 number system, therefore the weight
of each bit is a power of 2. (2 raised to the power of the
bit position)
 Base-2 numbers can be written, as and example: 01012
or 0101b
 The bit on the right is position zero, the next bit to the left
is position one, to the left again is position two, etc.
 The weight value of the bit in each position is the base of
the number system raised to the power of the position.
 The value of the binary number is then calculated by
calculating the sum of products of the bit position weight
value(s).
Binary System
1 0 0 1
3 2 1 0
1 * 20  1 * 1 = 1
0 * 21  0 * 2 = 0
0 * 22  0 * 4 = 0
1 * 23  1 * 8 = 8
20110
Sum of the products
1 0 0
6 5 4
1
7
0 * 24  0 * 16 = 0
0 * 25  0 * 32 = 0
1 * 26  1 * 64 = 64
1 * 27  1 * 128 = 128
2
The base (radix) is 2
Position Number
Binary System
 Two voltage levels are easy to distinguish. These two
voltage levels produce a square wave or digital signal
with the voltage levels of the square wave being 0 VDC
or GND and +VDC.
 The voltage levels can be related to the binary digits
1 and 0.
The Binary Word (16-bit)
 A single binary digit is a bit (BOOL).
 Four bits is a nibble.
 Eight bits is a byte (Byte or SINT).
 Sixteen bits is a word (WORD or INT)
 Thirty-two bits is a double word (DWORD or DINT)
1 1 1 0 1 1 0 10 1 0 1 1 0 0 0
Byte
Word
Bits
MSB – Most Significant Bit LSB – Least Significant Bit
Binary System
 The binary system uses two
digits, 1 and 0. Each digit or bit
can only go through two
changes and then a 1 is carried
to the position immediately to
the left.
 Numbers expressed in the
binary system require many
more digits than in the decimal
system. Most PLCs use 16-
digits, better known as 16-bits
to represent decimal numbers.
Most PACs use 32-bits to
represent decimal numbers.
 The table shows the decimal
numbers along with the binary
equivalent for the first 10
decimal digits.
Decimal 4-Bit Binary
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
Octal Number System
 Octal is a Base-8 number system.
 Base-8 numbers can be written, as an example:
48 or 4o
 Some PLCs use the octal number system for I/O
addressing and inputting parameter information
to internal instruction. (Automation Direct is one of these
manufacturers)
 There are no number 8’s or number 9’s in the
octal number system.
 Base-8 means that there are eight valid
numbers. Starting with zero they are:
0, 1, 2, 3, 4, 5, 6, 7
Hexadecimal Number
System
 Hexadecimal, simply referred to as Hex, is a Base-16
number system.
 Base-16 numbers can be written, as an example: 416 or
4h
 Some PLCs/PACs use the hexadecimal number system
for inputting information to internal instructions.
 Base-16 means that there are 16-valid numbers. Starting
at zero they are:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Where:
A = 10, B = 11, C = 12, D = 13, E = 14,
F = 15
Why are letters used for the numbers 10-15?
Number Weighting
1 1 1 0 1 1 0 10 1 0 1 1 0 0 0
215 214 213 212 211 210 29 28 27 26 25 24 23 22 21 20
Binary Weighting
Octal Weighting Hexadecimal Weighting
54 3558
84 83 82 81 80
58ED16
163 162 161 160
Number Conversions
 Decimal to:
 Binary
 Octal
 Hexadecimal
 BCD
 Binary to:
 Decimal
 Octal
 Hexadecimal
 BCD
 Octal to:
 Decimal
 Binary
 Hexadecimal
 BCD
 Hexadecimal to:
 Decimal
 Binary
 Octal
 BCD
To be fluent in PLCs/PACs we need to learn how to
convert numbers from one system to another.
We will be learning to convert -
Mathematically Converting
from Decimal To Binary
 Convert 20010 to binary
 Divide the decimal number to be converted by the
base of the number system you wish to convert to.
After each division, write down the remainders until
the quotient (result of the division) is equal to zero
Mathematically Converting
from Decimal To Octal
Convert 20010
to octal
Divide the decimal
number to be converted
by the base of the
number system you wish
to convert to. After each
division, write down the
remainders. Keep
dividing the resultant
quotient by the base of
the system being
convert to until the
quotient (the result of
the division) is equal to
zero
3 1 0
Base
810 310200 
8
Base of number
system converting to
8
200
8
25
Decimal number
being converted
Quotients
Remainders
25
01
3
8
3
0
3
C 8
Base of number
system converting to
Base
1610 8200 C
16
200
16
12
Decimal number
being converted
Quotients
Remainders
12
812 = C
0
16
Mathematically Converting
from Decimal To Hex
Convert 20010
to hexadecimal
Divide the decimal number
to be converted by the base
of the number system you
wish to convert to. After each
division, write down the
remainders. Keep dividing
the resultant quotient by the
base of the system being
converted to until the
quotient (the result of the
division) is equal to zero
Binary Weighting
Conversion Helper
1 1 1 0 1 1 0 10 1 0 1 1 0 0 0
The mathematical method is fine, but is prone to math errors.
There is a much easier method that only requires addition
and subtraction. Simply convert all non-binary numbers to
binary. Once a number is in binary it is easy to convert to any
other number system.
The following conversion helper can then be used.
Convert Binary To Decimal
 Convert 1100 10002 to decimal
 To convert a binary
number to decimal:
 Write down the weight
of all the bit position
where there is a 1.
 Calculate the sum of
the products of the
weight values.
 The resultant sum is
equivalent to the
Decimal number.
To Decimal
1 1 0 0 1 0 0 0
20 * 0 = 0
21 * 0 = 0
22 * 0 = 0
23 * 1 = 8
24 * 0 = 0
25 * 0 = 0
26 * 1 = 64
27 * 1 = + 128
200
Convert Binary To Octal
 Convert 1100 10002 to Octal.
 Converting from binary to other number systems is very
simple.
 To convert to octal:
 How many bits of binary are required to represent an octal digit?
Remember, the octal numbers are 0 – 7.
 Answer → It take 3-bits to represent the numbers 0 – 7.
 Starting at the right side of the binary number and working to the
left, group the bits in groups of three. Then perform 3-bit binary
to decimal conversions on each group.
 The result is the octal equivalent. To Octal
0 1 1 0 0 1 0 0 0
3108
Octal Equivalent
Binary to Convert
Convert Binary To
Hexadecimal
 Convert 1100 10002 to Hexadecimal.
 Converting from binary to other number systems is very
simple.
 To convert to hexadecimal:
 How many bits of binary does it take to represent a hexadecimal
digit? Remember, the hexadecimal numbers are 0 – 9, A - F.
 Answer → It take 4-Bits to represent the numbers 0 – 9, A - F.
 Starting at the right side of the binary number and working to the
left, group the bits in groups of four. Then perform 4-bit binary to
decimal conversions on each group.
 The result is the hexadecimal equivalent.
To Hexadecimal
1 1 0 0 1 0 0 0
C816
Hexadecimal Equivalent
Binary to Convert
12 8
Convert Decimal to Binary
(non-mathematic method)
 Refer to the Binary Weighting Conversion Helper.
 Convert 12,578 to binary:
 Starting at the MSB of a binary word, look for a weight value that
is less than or equal to the decimal number being converted.
 If the weight value is greater than the decimal number being
converted place a zero in that position and than proceed to the
next bit to the right.
 If the weight value is less than or equal to the decimal number
being converted place a 1 in that position, then subtract the
weight value from the decimal number being converted.
 Using the difference, continue to the right in the binary word
placing 0’s in the positions that are greater than the decimal
number being converted and 1’s in the position that are less than
or equal to the binary number being converted, subtracting that
weight value and moving to the right using the difference.
 Continue until the difference is equal to zero, then place zero’s in
any remaining bit positions.
Convert Decimal to Binary
(non-mathematic method)
 Convert 12,578 to binary:
 Position 15 (Bit-15) (MSB): 32,768 > 12,578 – Place a zero in that position
 Position 14 (Bit-14): 16,384 > 12,578 – Place a zero in that position
 Position 13 (Bit-13): 8,192 < 12,578 – Subtract; 12,578 – 8,192 = 4,386; place a 1 in this position
 Position 12 (Bit-12): 4,096 < 4,386 – Subtract; 4,386 – 4,096 = 290; place a 1 in this position
 Positions 11, 10 & 9 (Bits-11, 10 & 9) are greater than 290; place 0’s in these positions
 Position 8 (Bit-8): 256 < 290 – Subtract; 290 – 256 = 34; place a 1 in this position
 Positions 7 & 6 (Bits-7 & 6) are greater than 34; place 0’s in these positions
 Position 5 (Bit-5): 32 < 34 – Subtract; 34 – 32 = 2; place a 1 in this position
 Positions 4, 3, & 2 (Bits-4, 3 & 2) are greater than 2; place 0’s in these positions
 Position 1 (Bit-1): 2 = 2 – Subtract; 2 – 2 = 0; place a 1 in this position. The difference is equal
to zero therefore the conversion is finished. Place 0’s in any remaining bit positions.
0 0 0 0 0 0 0 00 0 0 0 0 0 0 0
0 0 1 0 0 0 1 00 0 1 1 0 0 0 1
Converted Word
Convert Octal To:
 Convert 3108 to binary, decimal & hexadecimal
Convert the octal
number to binary by
assigning a 3 bit
binary number to
each digit of the
octal number.
0 1 1 0 0 1 0 0 0
3108
Then use the binary number
and convert to decimal as before.
1 1 0 0 1 0 0 0 = 20010
Convert the binary number to
hexadecimal by grouping the binary
word in groups of 4 bits.
1 1 0 0 1 0 0 0
C816
Convert Hexadecimal To:
 Convert C816 to binary, decimal & octal
Convert the hexadecimal
number to binary
by assigning a 4 bit
binary number to
each digit of the
hexadecimal number.
1 1 0 0 1 0 0 0
C816
Then use the binary number
and convert to decimal as before.
1 1 0 0 1 0 0 0 = 20010
Convert the binary number to
octal by grouping the binary
word in groups of 3 bits.
0 1 1 0 0 1 0 0 0
3108
12
Binary Representation of
Data
 Most PLCs use 16-bit binary words to represent
numbers, and most PACs use 32-bit binary words.
 PLCs/PACs can use unsigned or signed numbers. This
depends upon the manufacturer; however, most are
signed.
 If a PLC is using an unsigned number system there are
no negative numbers. Using a16-bit word, what is the
largest unsigned decimal number that can be
represented?
 Answer → The largest unsigned number would be 65,535; when
all 16-bits are set to a 1. The smallest number would be zero
when all 16-bits are set to a 0.
 But we live in a world that uses negative numbers.
These number must also be represented in binary using
1’s and 0’s.
Negative Numbers
 It is not possible to use positive and negative symbols to
represent the polarity of a number in binary.
 One method of representing a binary number as a
positive or negative value is to use the Most Significant
Bit (MSB) of the word, (bit-15), as the sign bit.
 If the sign bit is set to a zero the number is positive. If it
is set to a one the number is negative.
1 1 1 0 1 1 0 10 1 0 1 1 0 0 0
Sign Bit
Negative Numbers
 There are at least three methods for
representing negative decimal numbers in
binary.
 A sign bit with no complement
 A sign bit and one’s complement
 A sign bit and two’s complement
 Following are examples of each
 No complement
 +7 = 0111 -7 = 1111
 One’s complement
 +7 = 0111 -7 = 1000
 Two’s complement
 +7 = 0111 -7 = 1001
Most PLCs/PACs use:
Two’s Compliment
Signed Binary Conversion
using 2’s Complement
 If the sign bit is a zero, the binary to decimal
conversion is done as usual.
 If the sign bit is a one, the conversion takes
place by performing a 2’s Complement and then
a binary to decimal conversion as usual.
 When using a 16-bit signed binary number
system, the range of decimal values that can be
represented is:
-32,768 to 32,767
Performing a 2’s
Complement
 Converting a negative binary number to decimal
requires that a 2’s Complement be performed
first.
 To perform a 2’s complement:
 Invert all the bits in the negative binary number. (1’s
become 0’s, 0’s become 1’s).
 Binary add 1 to the inverted binary number. (We’ll need
to learn how to add in binary).
 Perform a 16-bit Binary to decimal conversion.
 Apply a minus sign to the decimal number. This
negative decimal number is equal to the original
negative binary number.
 But first we need to know how to add in binary.
Binary Addition
 In decimal, what is 1 + 1 = ?. This is not a
loaded or trick question.
 Yes…the answer is: 2 1 + 1 = 2
 What is 1 in binary?
 1 in binary is: 012
 What is 2 in binary?
 2 in binary is: 102
 When adding in binary there are four
conditions that can occur:
10110
1010
1100
ofcarryawith

2
2
2
10
01
01
1
:

Therefore
Carry 1
Binary Addition
 When adding larger binary numbers, the
resulting carry of 1 is carried into higher-order
columns.
111
10
101

5 + 2 = 7
= 7
1000
11
101
1
111

5 + 3 = 8
1’s get
carried
3-times
= 8
2’s Complement Example
Convert 1000 1100 0101 00102 to decimal
Signed number: 1 0 0 0 1 1 0 0 0 1 0 1 0 0 1 0
Invert all the bits: 0 1 1 1 0 0 1 1 1 0 1 0 1 1 0 1
Binary add 1: + 1
Total: 0 1 1 1 0 0 1 1 1 0 1 0 1 1 1 0
Now perform a 16-bit binary to decimal conversion
on the total
Decimal Equiv: -29,614
Negative Decimal to Binary
 Follow these steps to covert a negative decimal
number to binary:
 Change the sign of the decimal number from negative
to positive.
 Perform a decimal to 16-bit binary conversion on the
positive number.
 Invert all the bits in the binary number. (1’s become
0’s, 0’s become 1’s).
 Binary add 1 to the inverted binary number
 The resultant binary number is the binary equivalent
of the original negative decimal number.
Example – Negative
Decimal to Binary
Convert: -4,783 to binary
Change the sign: 4,783 and perform a decimal to binary conversion
4,783 = 0001 0010 1010 1111
Perform a 2’s compliment
Invert all the bits: 1110 1101 0101 0000
Add binary 1: +1
1110 1101 0101 0001
Therefore: -4,783 = 1110 1101 0101 00012
Something to Remember
 When converting numbers in a 16-bit
signed number system. If:
 The number is >32,767 it can not be
converted because the number is too large to
fit into 16-bits.
 The number < -32,768 it can not be converted
because the number is too small to fit into 16-
bits.
FYI - Number Ranges
 Number system value ranges (Signed):
 16-Bit system
 -32,768 to 32,767 (INT data type)
 32-Bit system
 -2,147,483,648 to 2,147,483,647 (DINT data type)
 64-Bit system (very small and very large numbers)
 -18,446,744,073,709,551,616 to
18,446,744,073,709,551,615
 128-Bit system (very small and very large numbers)
 -3.4028237e-38 to 3.4028236e38
Binary Coded Decimal
(BCD)
 The Binary Coded Decimal (BCD) number system
provides a convenient way for humans to input or output
data from a PLC.
 The conversion from binary to decimal and decimal to
binary is a time consuming task. The BCD number
system provides a means for easily converting decimal
(the system humans are comfortable with) to code that is
easily handled by computers and PLCs (binary).
 BCD uses 4-bits of binary to represent the decimal
numbers 0 – 9.
 There are no single digits greater than 9, therefore the
maximum decimal number that a 16-bit binary BCD word
can represent is: 9,999  1001 1001 1001 1001
Decimal to BCD and BCD
to Decimal
 Converting a decimal number to BCD is as simple as
merely converting each digit of the decimal number to a
4-bit binary number. Converting BCD to decimal is the
same as converting hexadecimal to decimal. Break up
the binary into groups of 4-bits and perform 4-bit binary
to decimal conversions on each group.
5 3 1 9
0 0 1 10 1 0 1 0 0 0 1 1 0 0 1
Decimal Number
BCD Number
4-bits for each
Decimal Number
BCD Thumbwheel Switch
Interface – BCD Input
 The output of
the thumbwheel
switch has one
connection for
each bit weight
plus a common.
 The thumbwheel
switch output is
the equivalent 4-
bit BCD code for
the decimal
value shown on
the switch.
1s Input = 0
2s Input = 0
4s Input = 0
8s Input = 1
BCD Display – BCD
Output
The PLC can output the number 9371 to display
on a BCD display.
1001 0011 0111 0001
Comparison of Numeric
Values Between Systems
 Chart comparing
some numeric values
in:
 Decimal
 Binary
 BCD
 Hexadecimal
Gray Code
 Gray code is a special type of binary code
that does not use position weighting.
 The code is setup such that as it
progresses from one number to the next
only one bit changes. Because of this the
Gray code is considered to be an error-
minimizing code.
 The speed of bit transition for Gray code is
much faster than that of codes like BCD
because only one bit changes at a time.
Gray Code
 Some position encoders use
Gray code for accurate control
of motion. Encoders are used
to report the position of a
robots joints, machine tool axis
and servomechanisms.
 An encoder disk is attached to
a rotating shaft. As the shaft
rotates the disk rotation
generates a digital Gray code
that can than be interpolated to
a shaft position.
Typical Encoder Disk
ASCII Code
 The American Standard Code for Information Interchange (ASCII),
phonetically pronounced “Ask-key” is an alphanumeric code used to
represent the upper and lower case letters of the alphabet, numbers,
punctuation marks and non-printable characters such as the
backspace, linefeed, carriage return, etc.
 Each keystroke on the keyboard of a computer is converted directly
to an ASCII code that is than processed by the computer.
ASCII Code
 The ASCII conversion
table shown is the first
128-characters with
the matching ASCII
code in decimal.
 ASCII codes are 6 or
7-bit codes. The
extended ASCII set
(128 – 255) is used for
special graphics
characters.
Decimal Character Decimal Character Decimal Character Decimal Character
0 NUL 33 ! 66 B 99 c
1 SOH 34 " 67 C 100 d
2 STX 35 # 68 D 101 e
3 ETX 36 $ 69 E 102 f
4 EOT 37 % 70 F 103 g
5 ENQ 38 & 71 G 104 h
6 ACK 39 ' 72 H 105 i
7 BEL 40 ( 73 I 106 j
8 BS 41 ) 74 J 107 k
9 HT 42 * 75 K 108 l
10 LF 43 + 76 L 109 m
11 VT 44 , 77 M 110 n
12 FF 45 - 78 N 111 o
13 CR 46 . 79 O 112 p
14 SO 47 / 80 P 113 q
15 SI 48 0 81 Q 114 r
16 DLE 49 1 82 R 115 s
17 DC1 50 2 83 S 116 t
18 DC2 51 3 84 T 117 u
19 DC3 52 4 85 U 118 v
20 DC4 53 5 86 V 119 w
21 NAK 54 6 87 W 120 x
22 SYN 55 7 88 X 121 y
23 ETB 56 8 89 Y 122 z
24 CAN 57 9 90 Z 123 {
25 EM 58 : 91 [ 124 |
26 SUB 59 ; 92  125 }
27 ESC 60 < 93 ] 126 ~
28 FS 61 = 94 ^ 127 DEL
29 GS 62 > 95 _
30 RS 63 ? 96 `
31 US 64 @ 97 a
32 SP 65 A 98 b
ASCII CONVERSION TABLE
Conversion Practice
 Convert 7,24610 to:
 Binary
 Octal
 Hex
 Answer 7,24610 :
 Binary = 0001 1100 0100 11102
 Octal = 16,1168
 Hex = 1C4E16
Conversion Practice
 Convert 124,2658 to:
 Binary
 Decimal
 Hex
 Answer 124,2658 :
 Binary = 1010 1000 1011 01012
 Decimal = -22,34710
 Hex = A8B516
Conversion Practice
 Convert ACE016 to:
 Binary
 Octal
 Decimal
 Answer ACE016 :
 Binary = 1010 1100 1110 00002
 Octal = 126,3408
 Decimal = -21,28010
Conversion Practice
 Convert 5932BCD to:
 Binary
 Octal
 Decimal
 Hex
 Answer 5932BCD :
 Binary = 0101 1001 0011 00102
 Octal = 54,4628
 Decimal = 22,83410
 Hex = 593216
Conversion Practice
 Convert 1111 0001 1011 01102 to:
 Decimal
 Octal
 Hex
 BCD
 Answer 1111 0001 1011 01102:
 Decimal = -3,65810
 Octal = 170,6668
 Hex = F1B616
 BCD = Invalid BCD number
More Practice
 Complete the homework worksheet

More Related Content

PPTX
12 chapter06 math_instructions_fa14
PPTX
10 chapter05 counters_fa14
PPTX
03 shift registers_and_more_data_manipulation_sp15
PPTX
00 chapter07 and_08_conversion_subroutines_force_sp13
PPTX
Math cl ccw_siemens_rev01_fa16
PPTX
11 chapter06 slc_int_float_mov_mvm_fa14
PPTX
03 analog control_sp17
PPT
Digital Logic Rcs
12 chapter06 math_instructions_fa14
10 chapter05 counters_fa14
03 shift registers_and_more_data_manipulation_sp15
00 chapter07 and_08_conversion_subroutines_force_sp13
Math cl ccw_siemens_rev01_fa16
11 chapter06 slc_int_float_mov_mvm_fa14
03 analog control_sp17
Digital Logic Rcs

What's hot (20)

PPTX
Computer Arithmetic
PPT
Counters ibrahem
DOCX
Computer organization and architecture lab manual
PDF
Computer Organization And Architecture lab manual
PDF
FYBSC IT Digital Electronics Unit V Chapter I Counters
PPT
Digital Logic Design
PDF
Ee 202 chapter 1 number and code system
PPTX
ControlLogix Counters FA16
PDF
Vhdl introduction
PDF
COMPUTER ORGANIZATION NOTES Unit 6
PDF
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic Circuits
PDF
Number system
PPT
Combinational circuit
PPTX
Chapter 4: Combinational Logic
PPT
Logic Fe Tcom
PDF
Bds lab 4
PPTX
Data Reprersentation
DOC
Digital Comprator
DOCX
8051 data type and directives
DOCX
Introduction to 8085 & it's description(includes basic lab experiments)
Computer Arithmetic
Counters ibrahem
Computer organization and architecture lab manual
Computer Organization And Architecture lab manual
FYBSC IT Digital Electronics Unit V Chapter I Counters
Digital Logic Design
Ee 202 chapter 1 number and code system
ControlLogix Counters FA16
Vhdl introduction
COMPUTER ORGANIZATION NOTES Unit 6
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic Circuits
Number system
Combinational circuit
Chapter 4: Combinational Logic
Logic Fe Tcom
Bds lab 4
Data Reprersentation
Digital Comprator
8051 data type and directives
Introduction to 8085 & it's description(includes basic lab experiments)
Ad

Similar to 04 chapter03 02_numbers_systems_student_version_fa16 (20)

PDF
Introduction to Computing - Basic Theories Of Information
PPTX
number system
PPT
ENG241-Week1-NumberSystemsaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
PPTX
Digital Logic Design.pptx
PPT
2. Computer_Organization_unit_ 1_win.ppt
PPTX
BEEE - Part B - Unit 3 - Digital Electronics PPT.pptx
PPTX
Intro to IT Skills Lec 5 - English Department.pptx
PPTX
LEC 1.pptx
PPT
Chapter 1 Digital Systems and Binary Numbers.ppt
PPTX
Number-Systems presentation of the mathematics
PPT
Number Systems.ppt
PDF
Module 1 number systems and code1
PPT
lect1.ppt
PPTX
1.Digital Electronics overview & Number Systems.pptx
PDF
Digital Electronics Notes.pdf
PPT
BEEE - Part B - Unit 3 PPT.ppt DL&CO - Unit 1 PPT.ppt
PPTX
Number systems and conversions
PDF
Lec 02
PPTX
Psychology presentation for students basic and easy
PPTX
Eln PPT module on electrical and electronics
Introduction to Computing - Basic Theories Of Information
number system
ENG241-Week1-NumberSystemsaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Digital Logic Design.pptx
2. Computer_Organization_unit_ 1_win.ppt
BEEE - Part B - Unit 3 - Digital Electronics PPT.pptx
Intro to IT Skills Lec 5 - English Department.pptx
LEC 1.pptx
Chapter 1 Digital Systems and Binary Numbers.ppt
Number-Systems presentation of the mathematics
Number Systems.ppt
Module 1 number systems and code1
lect1.ppt
1.Digital Electronics overview & Number Systems.pptx
Digital Electronics Notes.pdf
BEEE - Part B - Unit 3 PPT.ppt DL&CO - Unit 1 PPT.ppt
Number systems and conversions
Lec 02
Psychology presentation for students basic and easy
Eln PPT module on electrical and electronics
Ad

More from John Todora (20)

PPTX
04 scaling analog_datal_sp17
PPTX
01 control logix_arrays_sp17
PPTX
Comparison instructions, AB, Siemens and AB CCW
PPTX
Lab02 review
PPTX
Subroutines rev01 fa16
PPTX
Move mask moves_rev01_fa16
PPTX
Lab02 lead in
PPTX
ControlLogix Timers FA16
PPTX
02 chapter02 fa16
PPTX
01 introduction to_plc-pac_rev01_fa16
PPTX
07 chapter07 loop_diagrams
PPTX
06 chapter06 binary_logic_systems_Rev02
PPTX
04 chapter04 specification_forms
PPTX
03 chapter03 lists_indexes_databases
PPTX
02 chapter02 p&ids_and_symbols_split_animations
PPTX
01 chapter01 process_flow_diagram
PPTX
00 introduction
PPTX
EMEC130 P&ID Symbol Primer
PPTX
02 copy file_fill_sp16
PPTX
Control Systems Basics
04 scaling analog_datal_sp17
01 control logix_arrays_sp17
Comparison instructions, AB, Siemens and AB CCW
Lab02 review
Subroutines rev01 fa16
Move mask moves_rev01_fa16
Lab02 lead in
ControlLogix Timers FA16
02 chapter02 fa16
01 introduction to_plc-pac_rev01_fa16
07 chapter07 loop_diagrams
06 chapter06 binary_logic_systems_Rev02
04 chapter04 specification_forms
03 chapter03 lists_indexes_databases
02 chapter02 p&ids_and_symbols_split_animations
01 chapter01 process_flow_diagram
00 introduction
EMEC130 P&ID Symbol Primer
02 copy file_fill_sp16
Control Systems Basics

Recently uploaded (20)

PPTX
"Array and Linked List in Data Structures with Types, Operations, Implementat...
PPTX
Amdahl’s law is explained in the above power point presentations
PDF
Influence of Green Infrastructure on Residents’ Endorsement of the New Ecolog...
PPTX
Module 8- Technological and Communication Skills.pptx
PPTX
Chemical Technological Processes, Feasibility Study and Chemical Process Indu...
PPTX
CyberSecurity Mobile and Wireless Devices
PPTX
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PPTX
introduction to high performance computing
PDF
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PPT
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
PPTX
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
PDF
August -2025_Top10 Read_Articles_ijait.pdf
PDF
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
PDF
Abrasive, erosive and cavitation wear.pdf
PDF
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
"Array and Linked List in Data Structures with Types, Operations, Implementat...
Amdahl’s law is explained in the above power point presentations
Influence of Green Infrastructure on Residents’ Endorsement of the New Ecolog...
Module 8- Technological and Communication Skills.pptx
Chemical Technological Processes, Feasibility Study and Chemical Process Indu...
CyberSecurity Mobile and Wireless Devices
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
introduction to high performance computing
SMART SIGNAL TIMING FOR URBAN INTERSECTIONS USING REAL-TIME VEHICLE DETECTI...
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
August -2025_Top10 Read_Articles_ijait.pdf
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
Abrasive, erosive and cavitation wear.pdf
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf

04 chapter03 02_numbers_systems_student_version_fa16

  • 1. Chapter 03 Sect. 3-1 to 3-3 Supplement and Reinforcement of Number Systems
  • 2. Why Do I Have To Learn About Number Systems  If you are taking a trip to a foreign country you would probably want to learn some of the language that is spoken in that country. After all, it would be nice to be able to order a nice dinner or ask for the location of a restroom.  Working with computers and PLCs is like visiting a foreign country. The language spoken in these countries is numbers, therefore it is a good idea to learn some of the language.
  • 3. Number Systems  Decimal  Binary  Octal  Hexadecimal  These are the number systems we will be studying  Learn them well, because they WILL keep coming back to haunt you.
  • 4. Decimal System  The decimal number system is the most common numbering system. It’s the number system we use everyday.  Number systems have a base or radix. The radix determines the total number of different symbols, or digits used by the system.  Decimal is a Base-10 numbering system, therefore there are 10-digits starting with the number zero.  Valid numbers in the decimal system are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9  Base-10 numbers can be written; as an example: 410 or 4d
  • 5. Decimal System  Each digit in a number system has a weight value assigned to it.  Decimal is a Base-10 number system, therefore the weight of each digit of a number is 10 raised to the power of the digit position.  The first digit on the right is position zero, the next digit to the left is position one, to the left again is position two, etc.  The value of the decimal number is calculated by multiplying the digit value of each position by10 to the power of that position number and summing the products. What was just said???
  • 6. Decimal System 5 3 1 9 3 2 1 0 9 * 100  9 * 1 = 9 1 * 101  1 * 10 = 10 3 * 102  3 * 100 = 300 5 * 103  5 * 1000 = 5000 531910Sum of the products The base (radix) of the number system. For Base-10 it is normally not shown. It is shown here as an example. Position Number Base or Radix is 10 Decimal Number
  • 7. Binary System  The binary number system is used by computers, PLCs, PACs and any other digital and µP controlled device.  Bi means two, therefore the valid numbers in the binary system are: 0 and 1.  One digit of a binary number is called a Bit (BOOL data type).  A group of 4-Bits is called a Nibble (term is not often used).  A group of 8-Bits is called a Byte (SINT or BYTE data type).  A group of 16-Bits is called a Word (WORD or Integer (INT) data type).  A group of 32-Bits is called a Double Word or DWORD. (DWORD or DINT data type).  A group of 64-Bits is called a Quad Word or QWORD.  A group of 128-Bits is called a Double Quad Word or DQWORD  The binary number system is used in computers and PLCs because bits can be represented as voltage levels within the computer. A zero = 0VDC or GND, a one = +VDC.
  • 8. Binary System  Each bit in the binary system has a weight assigned to it.  Binary is a Base-2 number system, therefore the weight of each bit is a power of 2. (2 raised to the power of the bit position)  Base-2 numbers can be written, as and example: 01012 or 0101b  The bit on the right is position zero, the next bit to the left is position one, to the left again is position two, etc.  The weight value of the bit in each position is the base of the number system raised to the power of the position.  The value of the binary number is then calculated by calculating the sum of products of the bit position weight value(s).
  • 9. Binary System 1 0 0 1 3 2 1 0 1 * 20  1 * 1 = 1 0 * 21  0 * 2 = 0 0 * 22  0 * 4 = 0 1 * 23  1 * 8 = 8 20110 Sum of the products 1 0 0 6 5 4 1 7 0 * 24  0 * 16 = 0 0 * 25  0 * 32 = 0 1 * 26  1 * 64 = 64 1 * 27  1 * 128 = 128 2 The base (radix) is 2 Position Number
  • 10. Binary System  Two voltage levels are easy to distinguish. These two voltage levels produce a square wave or digital signal with the voltage levels of the square wave being 0 VDC or GND and +VDC.  The voltage levels can be related to the binary digits 1 and 0.
  • 11. The Binary Word (16-bit)  A single binary digit is a bit (BOOL).  Four bits is a nibble.  Eight bits is a byte (Byte or SINT).  Sixteen bits is a word (WORD or INT)  Thirty-two bits is a double word (DWORD or DINT) 1 1 1 0 1 1 0 10 1 0 1 1 0 0 0 Byte Word Bits MSB – Most Significant Bit LSB – Least Significant Bit
  • 12. Binary System  The binary system uses two digits, 1 and 0. Each digit or bit can only go through two changes and then a 1 is carried to the position immediately to the left.  Numbers expressed in the binary system require many more digits than in the decimal system. Most PLCs use 16- digits, better known as 16-bits to represent decimal numbers. Most PACs use 32-bits to represent decimal numbers.  The table shows the decimal numbers along with the binary equivalent for the first 10 decimal digits. Decimal 4-Bit Binary 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001
  • 13. Octal Number System  Octal is a Base-8 number system.  Base-8 numbers can be written, as an example: 48 or 4o  Some PLCs use the octal number system for I/O addressing and inputting parameter information to internal instruction. (Automation Direct is one of these manufacturers)  There are no number 8’s or number 9’s in the octal number system.  Base-8 means that there are eight valid numbers. Starting with zero they are: 0, 1, 2, 3, 4, 5, 6, 7
  • 14. Hexadecimal Number System  Hexadecimal, simply referred to as Hex, is a Base-16 number system.  Base-16 numbers can be written, as an example: 416 or 4h  Some PLCs/PACs use the hexadecimal number system for inputting information to internal instructions.  Base-16 means that there are 16-valid numbers. Starting at zero they are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F Where: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15 Why are letters used for the numbers 10-15?
  • 15. Number Weighting 1 1 1 0 1 1 0 10 1 0 1 1 0 0 0 215 214 213 212 211 210 29 28 27 26 25 24 23 22 21 20 Binary Weighting Octal Weighting Hexadecimal Weighting 54 3558 84 83 82 81 80 58ED16 163 162 161 160
  • 16. Number Conversions  Decimal to:  Binary  Octal  Hexadecimal  BCD  Binary to:  Decimal  Octal  Hexadecimal  BCD  Octal to:  Decimal  Binary  Hexadecimal  BCD  Hexadecimal to:  Decimal  Binary  Octal  BCD To be fluent in PLCs/PACs we need to learn how to convert numbers from one system to another. We will be learning to convert -
  • 17. Mathematically Converting from Decimal To Binary  Convert 20010 to binary  Divide the decimal number to be converted by the base of the number system you wish to convert to. After each division, write down the remainders until the quotient (result of the division) is equal to zero
  • 18. Mathematically Converting from Decimal To Octal Convert 20010 to octal Divide the decimal number to be converted by the base of the number system you wish to convert to. After each division, write down the remainders. Keep dividing the resultant quotient by the base of the system being convert to until the quotient (the result of the division) is equal to zero 3 1 0 Base 810 310200  8 Base of number system converting to 8 200 8 25 Decimal number being converted Quotients Remainders 25 01 3 8 3 0 3
  • 19. C 8 Base of number system converting to Base 1610 8200 C 16 200 16 12 Decimal number being converted Quotients Remainders 12 812 = C 0 16 Mathematically Converting from Decimal To Hex Convert 20010 to hexadecimal Divide the decimal number to be converted by the base of the number system you wish to convert to. After each division, write down the remainders. Keep dividing the resultant quotient by the base of the system being converted to until the quotient (the result of the division) is equal to zero
  • 20. Binary Weighting Conversion Helper 1 1 1 0 1 1 0 10 1 0 1 1 0 0 0 The mathematical method is fine, but is prone to math errors. There is a much easier method that only requires addition and subtraction. Simply convert all non-binary numbers to binary. Once a number is in binary it is easy to convert to any other number system. The following conversion helper can then be used.
  • 21. Convert Binary To Decimal  Convert 1100 10002 to decimal  To convert a binary number to decimal:  Write down the weight of all the bit position where there is a 1.  Calculate the sum of the products of the weight values.  The resultant sum is equivalent to the Decimal number. To Decimal 1 1 0 0 1 0 0 0 20 * 0 = 0 21 * 0 = 0 22 * 0 = 0 23 * 1 = 8 24 * 0 = 0 25 * 0 = 0 26 * 1 = 64 27 * 1 = + 128 200
  • 22. Convert Binary To Octal  Convert 1100 10002 to Octal.  Converting from binary to other number systems is very simple.  To convert to octal:  How many bits of binary are required to represent an octal digit? Remember, the octal numbers are 0 – 7.  Answer → It take 3-bits to represent the numbers 0 – 7.  Starting at the right side of the binary number and working to the left, group the bits in groups of three. Then perform 3-bit binary to decimal conversions on each group.  The result is the octal equivalent. To Octal 0 1 1 0 0 1 0 0 0 3108 Octal Equivalent Binary to Convert
  • 23. Convert Binary To Hexadecimal  Convert 1100 10002 to Hexadecimal.  Converting from binary to other number systems is very simple.  To convert to hexadecimal:  How many bits of binary does it take to represent a hexadecimal digit? Remember, the hexadecimal numbers are 0 – 9, A - F.  Answer → It take 4-Bits to represent the numbers 0 – 9, A - F.  Starting at the right side of the binary number and working to the left, group the bits in groups of four. Then perform 4-bit binary to decimal conversions on each group.  The result is the hexadecimal equivalent. To Hexadecimal 1 1 0 0 1 0 0 0 C816 Hexadecimal Equivalent Binary to Convert 12 8
  • 24. Convert Decimal to Binary (non-mathematic method)  Refer to the Binary Weighting Conversion Helper.  Convert 12,578 to binary:  Starting at the MSB of a binary word, look for a weight value that is less than or equal to the decimal number being converted.  If the weight value is greater than the decimal number being converted place a zero in that position and than proceed to the next bit to the right.  If the weight value is less than or equal to the decimal number being converted place a 1 in that position, then subtract the weight value from the decimal number being converted.  Using the difference, continue to the right in the binary word placing 0’s in the positions that are greater than the decimal number being converted and 1’s in the position that are less than or equal to the binary number being converted, subtracting that weight value and moving to the right using the difference.  Continue until the difference is equal to zero, then place zero’s in any remaining bit positions.
  • 25. Convert Decimal to Binary (non-mathematic method)  Convert 12,578 to binary:  Position 15 (Bit-15) (MSB): 32,768 > 12,578 – Place a zero in that position  Position 14 (Bit-14): 16,384 > 12,578 – Place a zero in that position  Position 13 (Bit-13): 8,192 < 12,578 – Subtract; 12,578 – 8,192 = 4,386; place a 1 in this position  Position 12 (Bit-12): 4,096 < 4,386 – Subtract; 4,386 – 4,096 = 290; place a 1 in this position  Positions 11, 10 & 9 (Bits-11, 10 & 9) are greater than 290; place 0’s in these positions  Position 8 (Bit-8): 256 < 290 – Subtract; 290 – 256 = 34; place a 1 in this position  Positions 7 & 6 (Bits-7 & 6) are greater than 34; place 0’s in these positions  Position 5 (Bit-5): 32 < 34 – Subtract; 34 – 32 = 2; place a 1 in this position  Positions 4, 3, & 2 (Bits-4, 3 & 2) are greater than 2; place 0’s in these positions  Position 1 (Bit-1): 2 = 2 – Subtract; 2 – 2 = 0; place a 1 in this position. The difference is equal to zero therefore the conversion is finished. Place 0’s in any remaining bit positions. 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 1 0 0 0 1 00 0 1 1 0 0 0 1 Converted Word
  • 26. Convert Octal To:  Convert 3108 to binary, decimal & hexadecimal Convert the octal number to binary by assigning a 3 bit binary number to each digit of the octal number. 0 1 1 0 0 1 0 0 0 3108 Then use the binary number and convert to decimal as before. 1 1 0 0 1 0 0 0 = 20010 Convert the binary number to hexadecimal by grouping the binary word in groups of 4 bits. 1 1 0 0 1 0 0 0 C816
  • 27. Convert Hexadecimal To:  Convert C816 to binary, decimal & octal Convert the hexadecimal number to binary by assigning a 4 bit binary number to each digit of the hexadecimal number. 1 1 0 0 1 0 0 0 C816 Then use the binary number and convert to decimal as before. 1 1 0 0 1 0 0 0 = 20010 Convert the binary number to octal by grouping the binary word in groups of 3 bits. 0 1 1 0 0 1 0 0 0 3108 12
  • 28. Binary Representation of Data  Most PLCs use 16-bit binary words to represent numbers, and most PACs use 32-bit binary words.  PLCs/PACs can use unsigned or signed numbers. This depends upon the manufacturer; however, most are signed.  If a PLC is using an unsigned number system there are no negative numbers. Using a16-bit word, what is the largest unsigned decimal number that can be represented?  Answer → The largest unsigned number would be 65,535; when all 16-bits are set to a 1. The smallest number would be zero when all 16-bits are set to a 0.  But we live in a world that uses negative numbers. These number must also be represented in binary using 1’s and 0’s.
  • 29. Negative Numbers  It is not possible to use positive and negative symbols to represent the polarity of a number in binary.  One method of representing a binary number as a positive or negative value is to use the Most Significant Bit (MSB) of the word, (bit-15), as the sign bit.  If the sign bit is set to a zero the number is positive. If it is set to a one the number is negative. 1 1 1 0 1 1 0 10 1 0 1 1 0 0 0 Sign Bit
  • 30. Negative Numbers  There are at least three methods for representing negative decimal numbers in binary.  A sign bit with no complement  A sign bit and one’s complement  A sign bit and two’s complement  Following are examples of each  No complement  +7 = 0111 -7 = 1111  One’s complement  +7 = 0111 -7 = 1000  Two’s complement  +7 = 0111 -7 = 1001 Most PLCs/PACs use: Two’s Compliment
  • 31. Signed Binary Conversion using 2’s Complement  If the sign bit is a zero, the binary to decimal conversion is done as usual.  If the sign bit is a one, the conversion takes place by performing a 2’s Complement and then a binary to decimal conversion as usual.  When using a 16-bit signed binary number system, the range of decimal values that can be represented is: -32,768 to 32,767
  • 32. Performing a 2’s Complement  Converting a negative binary number to decimal requires that a 2’s Complement be performed first.  To perform a 2’s complement:  Invert all the bits in the negative binary number. (1’s become 0’s, 0’s become 1’s).  Binary add 1 to the inverted binary number. (We’ll need to learn how to add in binary).  Perform a 16-bit Binary to decimal conversion.  Apply a minus sign to the decimal number. This negative decimal number is equal to the original negative binary number.  But first we need to know how to add in binary.
  • 33. Binary Addition  In decimal, what is 1 + 1 = ?. This is not a loaded or trick question.  Yes…the answer is: 2 1 + 1 = 2  What is 1 in binary?  1 in binary is: 012  What is 2 in binary?  2 in binary is: 102  When adding in binary there are four conditions that can occur: 10110 1010 1100 ofcarryawith  2 2 2 10 01 01 1 :  Therefore Carry 1
  • 34. Binary Addition  When adding larger binary numbers, the resulting carry of 1 is carried into higher-order columns. 111 10 101  5 + 2 = 7 = 7 1000 11 101 1 111  5 + 3 = 8 1’s get carried 3-times = 8
  • 35. 2’s Complement Example Convert 1000 1100 0101 00102 to decimal Signed number: 1 0 0 0 1 1 0 0 0 1 0 1 0 0 1 0 Invert all the bits: 0 1 1 1 0 0 1 1 1 0 1 0 1 1 0 1 Binary add 1: + 1 Total: 0 1 1 1 0 0 1 1 1 0 1 0 1 1 1 0 Now perform a 16-bit binary to decimal conversion on the total Decimal Equiv: -29,614
  • 36. Negative Decimal to Binary  Follow these steps to covert a negative decimal number to binary:  Change the sign of the decimal number from negative to positive.  Perform a decimal to 16-bit binary conversion on the positive number.  Invert all the bits in the binary number. (1’s become 0’s, 0’s become 1’s).  Binary add 1 to the inverted binary number  The resultant binary number is the binary equivalent of the original negative decimal number.
  • 37. Example – Negative Decimal to Binary Convert: -4,783 to binary Change the sign: 4,783 and perform a decimal to binary conversion 4,783 = 0001 0010 1010 1111 Perform a 2’s compliment Invert all the bits: 1110 1101 0101 0000 Add binary 1: +1 1110 1101 0101 0001 Therefore: -4,783 = 1110 1101 0101 00012
  • 38. Something to Remember  When converting numbers in a 16-bit signed number system. If:  The number is >32,767 it can not be converted because the number is too large to fit into 16-bits.  The number < -32,768 it can not be converted because the number is too small to fit into 16- bits.
  • 39. FYI - Number Ranges  Number system value ranges (Signed):  16-Bit system  -32,768 to 32,767 (INT data type)  32-Bit system  -2,147,483,648 to 2,147,483,647 (DINT data type)  64-Bit system (very small and very large numbers)  -18,446,744,073,709,551,616 to 18,446,744,073,709,551,615  128-Bit system (very small and very large numbers)  -3.4028237e-38 to 3.4028236e38
  • 40. Binary Coded Decimal (BCD)  The Binary Coded Decimal (BCD) number system provides a convenient way for humans to input or output data from a PLC.  The conversion from binary to decimal and decimal to binary is a time consuming task. The BCD number system provides a means for easily converting decimal (the system humans are comfortable with) to code that is easily handled by computers and PLCs (binary).  BCD uses 4-bits of binary to represent the decimal numbers 0 – 9.  There are no single digits greater than 9, therefore the maximum decimal number that a 16-bit binary BCD word can represent is: 9,999  1001 1001 1001 1001
  • 41. Decimal to BCD and BCD to Decimal  Converting a decimal number to BCD is as simple as merely converting each digit of the decimal number to a 4-bit binary number. Converting BCD to decimal is the same as converting hexadecimal to decimal. Break up the binary into groups of 4-bits and perform 4-bit binary to decimal conversions on each group. 5 3 1 9 0 0 1 10 1 0 1 0 0 0 1 1 0 0 1 Decimal Number BCD Number 4-bits for each Decimal Number
  • 42. BCD Thumbwheel Switch Interface – BCD Input  The output of the thumbwheel switch has one connection for each bit weight plus a common.  The thumbwheel switch output is the equivalent 4- bit BCD code for the decimal value shown on the switch. 1s Input = 0 2s Input = 0 4s Input = 0 8s Input = 1
  • 43. BCD Display – BCD Output The PLC can output the number 9371 to display on a BCD display. 1001 0011 0111 0001
  • 44. Comparison of Numeric Values Between Systems  Chart comparing some numeric values in:  Decimal  Binary  BCD  Hexadecimal
  • 45. Gray Code  Gray code is a special type of binary code that does not use position weighting.  The code is setup such that as it progresses from one number to the next only one bit changes. Because of this the Gray code is considered to be an error- minimizing code.  The speed of bit transition for Gray code is much faster than that of codes like BCD because only one bit changes at a time.
  • 46. Gray Code  Some position encoders use Gray code for accurate control of motion. Encoders are used to report the position of a robots joints, machine tool axis and servomechanisms.  An encoder disk is attached to a rotating shaft. As the shaft rotates the disk rotation generates a digital Gray code that can than be interpolated to a shaft position. Typical Encoder Disk
  • 47. ASCII Code  The American Standard Code for Information Interchange (ASCII), phonetically pronounced “Ask-key” is an alphanumeric code used to represent the upper and lower case letters of the alphabet, numbers, punctuation marks and non-printable characters such as the backspace, linefeed, carriage return, etc.  Each keystroke on the keyboard of a computer is converted directly to an ASCII code that is than processed by the computer.
  • 48. ASCII Code  The ASCII conversion table shown is the first 128-characters with the matching ASCII code in decimal.  ASCII codes are 6 or 7-bit codes. The extended ASCII set (128 – 255) is used for special graphics characters. Decimal Character Decimal Character Decimal Character Decimal Character 0 NUL 33 ! 66 B 99 c 1 SOH 34 " 67 C 100 d 2 STX 35 # 68 D 101 e 3 ETX 36 $ 69 E 102 f 4 EOT 37 % 70 F 103 g 5 ENQ 38 & 71 G 104 h 6 ACK 39 ' 72 H 105 i 7 BEL 40 ( 73 I 106 j 8 BS 41 ) 74 J 107 k 9 HT 42 * 75 K 108 l 10 LF 43 + 76 L 109 m 11 VT 44 , 77 M 110 n 12 FF 45 - 78 N 111 o 13 CR 46 . 79 O 112 p 14 SO 47 / 80 P 113 q 15 SI 48 0 81 Q 114 r 16 DLE 49 1 82 R 115 s 17 DC1 50 2 83 S 116 t 18 DC2 51 3 84 T 117 u 19 DC3 52 4 85 U 118 v 20 DC4 53 5 86 V 119 w 21 NAK 54 6 87 W 120 x 22 SYN 55 7 88 X 121 y 23 ETB 56 8 89 Y 122 z 24 CAN 57 9 90 Z 123 { 25 EM 58 : 91 [ 124 | 26 SUB 59 ; 92 125 } 27 ESC 60 < 93 ] 126 ~ 28 FS 61 = 94 ^ 127 DEL 29 GS 62 > 95 _ 30 RS 63 ? 96 ` 31 US 64 @ 97 a 32 SP 65 A 98 b ASCII CONVERSION TABLE
  • 49. Conversion Practice  Convert 7,24610 to:  Binary  Octal  Hex  Answer 7,24610 :  Binary = 0001 1100 0100 11102  Octal = 16,1168  Hex = 1C4E16
  • 50. Conversion Practice  Convert 124,2658 to:  Binary  Decimal  Hex  Answer 124,2658 :  Binary = 1010 1000 1011 01012  Decimal = -22,34710  Hex = A8B516
  • 51. Conversion Practice  Convert ACE016 to:  Binary  Octal  Decimal  Answer ACE016 :  Binary = 1010 1100 1110 00002  Octal = 126,3408  Decimal = -21,28010
  • 52. Conversion Practice  Convert 5932BCD to:  Binary  Octal  Decimal  Hex  Answer 5932BCD :  Binary = 0101 1001 0011 00102  Octal = 54,4628  Decimal = 22,83410  Hex = 593216
  • 53. Conversion Practice  Convert 1111 0001 1011 01102 to:  Decimal  Octal  Hex  BCD  Answer 1111 0001 1011 01102:  Decimal = -3,65810  Octal = 170,6668  Hex = F1B616  BCD = Invalid BCD number
  • 54. More Practice  Complete the homework worksheet