You are on page 1of 31

NUMBER

 SYSTEMS  AND  
CODES  
Juan Carlos Martinez Santos
Reminders  

•  Please  turn  off  cell  phones.  

•  No  food  or  so@  drinks  in  the  classroom.    

•  Stow  water  boFles  at  floor  level.  


Week  1  
 Number  Systems  and  Codes  

•  Read  Kleitz,  Chapter  1.  


•  Quiz  Friday.  
Analog  versus  Digital  

•  Analog  =  conRnuous  
•  Digital  =  discrete  
•  Example:  
•  An  analog  clock,  whose  hands  move  smoothly  and  conRnuously.  
•  A  digital  clock,  whose  digits  jump  from  one  value  to  the  next.  
Analog Quantities
Most natural quantities (such as temperature, pressure, light
intensity, …) are analog quantities that vary continuously.

Temperature
(°F)

100
95
90
85
80
75
70
Time of day
1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11 12
A .M . P.M .

Digital systems can process, store, and transmit data more


efficiently but can only assign discrete values to each point.

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
The  Digital  Revolu3on  

•  Recently,  many  types  of  devices  have  been  converted  from  


analog  to  digital.  
•  Examples:  

Analog Digital
Record albums CDs
VHS tapes DVDs
Analog television Digital TV

•  In  all  of  these  digital  devices,  info  is  stored  and  transmiFed  
as  long  strings  of  1s  and  0s.  
Analog and Digital Systems

Many systems use a mix of analog and digital electronics to


take advantage of each technology. A typical CD player
accepts digital data from the CD drive and converts it to an
analog signal for amplification.
CD drive

10110011101 Digital-to-analog Linear amplifier


Digital data converter Analog
reproduction
of music audio Speaker
signal
Sound
waves

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Voltage  

•  Voltage  is  a  basic  electrical  quanRty  that  is  important  in  all  
circuits  (analog  or  digital).  
•  You  can  think  of  a  circuit  as  being  like  a  plumbing  system,  
with  water  flowing  through  pipes.  
•  On  this  analogy,  voltage  is  like  the  water  pressure  in  the  
pipes.    Its  value  will  vary  at  different  points  in  the  circuit.  
A  Simple  Circuit  
A wire is like a water pipe. The amount of
electricity flowing through a wire is called
current, which is measured in amperes.
The voltage
(pressure)
at this point
is greater than
the voltage
at this point.
A voltage source is like
a water pump. Its
voltage rating (in volts)
tells you how strong it is.
Resistors are like partial blockages
in the pipe. They restrict the amount
of current that flows through the circuit.
Examples  of  Voltage  Sources  

•  Voltage  is  measured  in  volts  (V).  

•  Flashlight  baFery  ____  V  

•  Wall  outlet    ____  V  


Trainer  Power  Supplies  

Fixed +5 V supply:
In this course we’ll
always use this one.

No matter which one


of these you use, you
must also use the
GROUND connection.

Variable supplies,
controlled by the
knobs at left. You’ll
use these in
other courses.
Measuring  Exact  Voltage  

•  In  other  courses  you’ll  use  a  voltmeter  or  digital  


mulRmeter,  like  the  one  shown,  to  measure  the  exact  
voltage  at  a  point  in  a  circuit.  
Measuring  Digital  HIGHS  or  LOWS  

•  In  this  course  we  usually  don’t  


care  about  exact  voltage  
values.    We  just  care  whether  
the  voltage  at  a  point  is  “high”  
or  “low.”  

¡  To measure this, we


use a logic probe,
such as the one
shown.
Binary Digits and Logic Levels

Digital electronics uses circuits that have two states, which


are represented by two voltage ranges called HIGH and
LOW. We often represent a HIGH state by the number 1,
and a LOW state by the number 0.
VH(max)
HIGH
VH(min)

Invalid
VL(max)

LOW
VL(min)

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Ones  and  Zeros  

•  Digital  devices  (computers,  iPods,  cell  phones,  …)  store  


informaRon  (numbers,  text,  images,  music,  …)  as  strings  of  
1s  and  0s.  
•  Each  1  or  0  in  such  a  string  is  called  a  bit  (short  for  binary  
digit).  
•  Example  of  an  8-­‐bit  string:  01101100  
•  A  typical  song  in  an  MP3  file  might  contain  40  million  bits.  
Number  Systems  and  Codes  

•  This  week  we’ll  look  mainly  at  how  to  represent  numbers  
using  1s  and  0s,  and  also  (briefly)  how  to  represent  text  
using  1s  and  0s.  
Binary  Number  System  

•  When  we  represent  numbers  using  1s  and  0s,  we’re  using  
the  binary  number  system.    This  system  is  fundamental  to  
everything  in  digital  electronics,  so  you  must  learn  it  
thoroughly.  
•  First,  we’ll  briefly  review  the  decimal  number  system  that  
you’ve  used  for  most  of  your  life.  
Decimal Numbers

The position of each digit in a weighted number system is


assigned a weight based on the base or radix of the system.
The base of decimal numbers is ten, because only ten
symbols (0 through 9) are used to represent any number.
The column weights of decimal numbers are powers
of ten that increase from right to left beginning with 100 =1:
…105 104 103 102 101 100.

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Decimal Numbers

Decimal numbers can be expressed as the sum of the


products of each digit times the column value for that digit.
Thus, the number 9240 can be expressed as
(9 x 103) + (2 x 102) + (4 x 101) + (0 x 100)
or
9 x 1,000 + 2 x 100 + 4 x 10 + 0 x 1
Express the number 480 as the sum of values of each digit.

480 = (4 x 102) + (8 x 101) + (0 x 100)

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Binary Numbers

For digital systems, the binary number system is used.


Binary has a base of two and uses the digits 0 and 1 to
represent quantities.
The column weights of binary numbers are powers of
two that increase from right to left beginning with 20 =1:
…25 24 23 22 21 20.

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Decimal Binary
Number Number

Binary Numbers 0 0000


1 0001
A binary counting sequence for numbers 2 0010
from zero to fifteen is shown. 3 0011
4 0100
Notice the pattern of zeros and ones in 5 0101
each column. 6 0110
7 0111
8 1000
9 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Binary-to-Decimal Conversions

The decimal equivalent of a binary number can be


determined by adding the column values of all of the bits
that are 1 and discarding all of the bits that are 0.
Convert the binary number 100101 to decimal.
Start by writing the column weights; then add the
weights that correspond to each 1 in the number.

32 16 8 4 2 1
1 0 0 1 0 1
32 +4 +1 = 37

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Decimal-to-Binary Conversions (First Method)

You can convert a decimal whole number to binary by


reversing the procedure. Write the decimal weight of each
column and place 1’s in the columns that sum to the decimal
number.
Convert the decimal number 49 to binary.
The column weights double in each position to the
right. Write down column weights until the last
number is larger than the one you want to convert.

64 32 16 8 4 2 1.
0 1 1 0 0 0 1.

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Decimal-to-Binary Conversions (Second Method)

You can convert decimal to any other base by repeatedly


dividing by the base. For binary, repeatedly divide by 2:
Convert the decimal number 49 to binary by
repeatedly dividing by 2.
You can do this by “reverse division” and the
answer will read from left to right. Put quotients to
the left and remainders on top.
Answer: remainder
1 1 0 0 0 1
0 1 3 6 12 24 49 2
Continue until the Decimal number
Quotient base
last quotient is 0

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
The  Hexadecimal  and  Octal  Systems  

•  We’ve  looked  at  the  decimal  and  binary  systems.  


•  Hexadecimal  (o@en  called  “hex”)  and  octal  are  useful  as  
shorthand  systems  of  wriRng  large  binary  numbers.  
•  Hex  is  a  base-­‐16  system.  
•  Octal  is  a  base-­‐8  system.  
•  Hex  is  very  widely  used.  
•  Octal  was  popular  40  years  ago,  but  is  not  used  much  
today.  
Decimal Hexadecimal Binary
Hexadecimal Numbers 0 0 0000
1 1 0001
Hexadecimal uses sixteen characters to 2 2 0010
represent numbers: the numbers 0 3 3 0011
through 9 and the alphabetic characters 4 4 0100
A through F. 5 5 0101
6 6 0110
Large binary numbers can 7 7 0111
easily be converted to hexadecimal 8 8 1000
by grouping bits 4 at a time and 9 9 1001
writing the equivalent hex character. 10 A 1010
11 B 1011
Express 1001 0110 0000 11102 in 12 C 1100
hexadecimal: 13 D 1101
Group the binary number by 4-bits 14 E 1110
starting from the right. Thus, 960E 15 F 1111

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Decimal Hexadecimal Binary
Hexadecimal Numbers 0 0 0000
1 1 0001
Hexadecimal is a weighted number 2 2 0010
system. The column weights are 3 3 0011
powers of 16, which increase from 4 4 0100
5 5 0101
right to left. 6 6 0110
Column weights {4096
3 2
16 16 16 16 .
256 16 1
1 0 7
8
7
8
0111
1000
9 9 1001
Express 1A2F16 in decimal. 10 A 1010
11 B 1011
Start by writing the column weights:
12 C 1100
4096 256 16 1
13 D 1101
1 A 2 F16
14 E 1110
1(4096) + 10(256) +2(16) +15(1) = 670310 15 F 1111

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Decimal Binary BCD
BCD 0 0000 0000
1 0001 0001
Binary coded decimal (BCD) is a 2 0010 0010
weighted code that is commonly 3 0011 0011
used in digital systems when it is 4 0100 0100
5 0101 0101
necessary to show decimal 6 0110 0110
numbers such as in clock displays. 7 0111 0111
The table illustrates the 8 1000 1000
difference between straight binary and 9 1001 1001
BCD. BCD represents each decimal 10 1010 0001 0000
digit with a 4-bit code. Notice that the 11 1011 0001 0001
codes 1010 through 1111 are not used in 12 1100 0001 0010
BCD. 13 1101 0001 0011
14 1110 0001 0100
15 1111 0001 0101
© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
BCD

You can think of BCD in terms of column weights in


groups of four bits. For an 8-bit BCD number, the column
weights are: 80 40 20 10 8 4 2 1.
What are the column weights for the BCD number
1000 0011 0101 1001?

8000 4000 2000 1000 800 400 200 100 80 40 20 10 8 4 2 1


Note that you could add the column weights where there is
a 1 to obtain the decimal number. For this case:
8000 + 200 +100 + 40 + 10 + 8 +1 = 835910

© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
The  ASCII  Code  

• ASCII  (American  Standard  Code  for  InformaRon  


Interchange)  is  a  binary  code  for  alphanumeric  symbols.    
• ASCII  encodes  128  symbols  using  7-­‐bits.    
• See  Table  1-­‐5  on  page  19  (next  slide)  for  the  list  of  ASCII  
codes.    
• The  first  32  symbols  are  control  characters  (such  as  
Backspace,  Line  Feed,  Form  Feed),  based  on  teletype  
requirements.    Some  of  these  are  obsolete.  

You might also like