You are on page 1of 33

There are two way of representing the numerical value of quantities :

Analog Representation

Digital Representation

In analog representation a quantity is represented by a voltage, current or meter movement that is proportional to the value of that quantity

Example :

Automobile Speedometer

• Analog Voltmeter or Ammeter

Analog

quantities can

range of values

vary over a continuous

In digital representation the quantities are represented not by proportional quantities but by symbols called digits.

Example : A Digital Watch

It provides

the

time

of

day

in

the

form

of

decimal digits which represent hours and

minutes (and sometimes seconds).

This digital representation of the time of day changes in discrete steps.

Advantages of Digital Techniques

1. Digital systems are easier to design as circuits used are only switching circuits with only HIGH and LOW range

  • 2. Information storage is easy in digital form

  • 3. Accuracy and precision are greater

  • 4. Operation can be programmed

  • 5. Digital circuits are less affected by noise. The spurious fluctuation in voltage (noise) are not as critical in digital systems because the exact value of a voltage is not important. Noise does not have an effect unless it is high enough to make a HIGH become LOW or vice versa.

    • 6. More digital circuitry can be fabricated on IC chips

Limitation of Digital Techniques

The real world is mainly analog. The quantities we sense or use tend to be mostly continuous analog variables. In order to process these digitally, we need to use analog-to-digital converters to get digital representations of the analog signal. We may also need digital-to- analog converters to convert digital quantities to analog ones which we can output to the outside world.

Number Systems and Codes

Numbering System

Decimal

Base 10, using 0,1,….,8,9

Binary

Base 2, using only 0 & 1

Octal

Base 8, using 0,1,….,6,7

Hexadecimal

Base 16

used in computers and digital systems

Any base can be used and numbers changed from one base to another to change representation. The Mayans used a Base 20 system, the Babylonians used Base 60!!!

Decimal Number System – Base 10

This uses ten numerals or symbols, i.e. 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9

A positional value system is used with these symbols to represent any number.

Example:

a N ,a N-1 ,…….,a 1 ,a 0 . a -1 ,a -2 ,…

..

,a

-K

represents the following number

a 0 10 0 +a 1 10 1 + ………+a N-1 10 N-1 +a N 10 N + a -1 10 -1 + …….+a -K 10 -K

Binary Number System

The binary system uses only two symbols, 0 and 1

It is also a positional value system where each binary digit has its own value or weight expressed as a power of 2

• Places to the left of the binary point are positive powers of 2

•

Places to the the right of the binary point are negative powers of 2

This is exactly what we did in the decimal system except that there we used powers of 10 instead of powers of 2!

Example : The Number 1011.101 2

   
     
 

2 3

2 2

2 1

2 0

2 -1

2 -2

2 -3

 

1

0

1

1

1

0

1

Most Significant Bit (MSB)

.

Binary Point

Least Significant Bit (LSB)

BINARY TO DECIMAL CONVERSION

Example : Convert the number 1011.101 2 to its decimal equivalent

1011.101 2 = 1 x 2 3 + 0 x 2 2 + 1 x 2 1 + 1 x 2 0

+1 x

2 -1 + 0 x 2 -2 + 1 x 2 -3

= 8 + 0 + 2 + 1+ 0.5 + 0+ 0.125

=11.625 10

DECIMAL TO BINARY CONVERSION

Done by repeated divisions (see next slide)

Example - Convert 456 10 into binary

Answer = 111001000 2

2

 

456

 

2

 

2

114-----0

 
 

2

57----0

 

2

28--1

2

= 111001000 2

2 456 2 2 114----- 0 2 57---- 0 2 28-- 1 2 = 111001000 Write

Write the remainder from bottom to top

228-------0 remainder

14---0

 

2

7----0

 

2

3----1

 
 

2

 

1---1

0---1

Convert 42.9375 10 to binary

2 42 2 21----0 2 10----1 2 5----0 2 2----1 21----0 0---1
2
42
2 21----0
2
10----1
2
5----0
2
2----1
21----0
0---1

0.9375

 
 

x 2

1.8750

---1

0.8750

 

x 2

1.7500

--- 1

0.75

 

x

2

1.50------- 1

0.5

x 2

1.0

-------1

Continue till 0 is obtained in fraction part

42.9375 10 =101010.1111 2

Example : Convert 25.012 10 into binary

2 25 0.192 2 12------1 2 6------0 0.012 x 2 x 2 0.384----0 2 3------0 0.024----0
2 25
0.192
2 12------1
2 6------0
0.012
x 2
x 2
0.384----0
2
3------0
0.024----0
x 2
21------1
x 2
0.768--- 0
0-----1
0.048----0
x 2
x 2
1.536----1
0.096----0
0.536
x2
x 2
0.192--------0
1.072----1
0.072
x 2
0.144---- 0
x
2

25.012 10 =11001.0000001100 2

(approximately)

0.288----0

Octal Number System

It has a base of 8 and 8 possible digits : 0,1,2,3,4,5,6,7

Octal to decimal conversion 24.6 8 =2 x 8 1 + 4 x 8 0 + 6x 8 -1 =

16 + 4 + 0.75 = 20.75 10

Decimal to octal conversion

Example : Convert 49.21875 10 into octal

8

49

 

0.21875

8

6---1

x 8

   

0---6

1.75000----1

.75

x 8

6.00-------6

Octal to Binary Conversion

Conversion from octal to binary is performed by converting each octal digit to its 3-bit binary equivalent

Ex :

472 8 =100 111 010 2

Ex :

642.71 8 = 110 100 010.111 001 2

Binary to Octal Conversion

The bits of the binary number are grouped into groups of three bits starting at the LSB. Then each group is converted into its octal equivalent

Ex. 101100011001 2 = 101 100 011 001=5431 8

5

4

3

1

Ex. 100.101 2 = 4.5 8

Hexadecimal Number System

It uses base 16 and 16 possible digit symbols 0 to 9 plus the letters A,B,C,D,E ,F

A=10 D , B=11 D , C=12 D , D=13 D , E=14 D , F=15 D

Hex to Decimal Conversion

Example:

356 16

= 3 x 16 2 + 5 x 16 1 + 6 x 16 0 = 854 10

Decimal to Hex Conversion

Example: 567.1875 10

= 237.3 16

16

567

   

16

35----7

0.1875

16

2----3

x 16

0----2

3.000---3

Hex to Binary Conversion

Groups of 4 digits are taken

Example:

Example:

F9 16 = 1111 1001 2 20E.CA 16 = 0010 0000 1110.1100 1010 2

Binary to Hex Comversion

Grouped into groups of four bits, and each group is converted to its equivalent hex digit

Example: 1110100110 2 = 0011 1010 0110 = 3A6 16 Example: 1101 . 0011 1100 = D.3C 16

Example : Convert B2F 16 to octal

First convert hex to binary, then convert the resultant binary to octal

B2F 16 = 1011 0010 1111 2 = 101 100 101 111= 5457 8

CODES

When numbers, letters or words are represented by a special group of symbols, we say that they are being encoded and the group of symbols is called code.

Binary- Coded- Decimal Code (BCD)

If each digit of a decimal number is represented by its binary equivalent, the result is a code called binary-coded- decimal or BCD. Since a decimal digit can be as large as 9, 4 bits are required to code each digit.

Example: 874 D = 1000 0111 0100 (BCD)

Gray Code

This belongs to a class of codes called minimum-change codes, in which only one bit in the code groups changes when going from one stage to the next. The Gray code is an un-weighted code.

This code is not suited for arithmetic operation but finds application in input/output devices and some types of Analog to Digital Converters (ADCs).

The attractive feature of this code is that it minimizes the effect of any error made in converting from digital to analog!

Binary Equivalent

Gray Code

  • 0 0 0 0

 

0 0 0 0

  • 0 0 0 1

0 0 0 1

  • 0 0 1 0

0 0 1 1

  • 0 0 1 1

0 0 1 0

  • 0 1 0 0

0 1 1 0

  • 0 1 0 1

0 1 1

1

  • 0 1 1 0

0 1 0 1

  • 0 1

1 1

0 1 0 0

  • 1 0 0 0

1 1 0 0

  • 1 0 0 1

1 1 0 1

  • 1 0 1 0

1

1 1

1

  • 1 0 1 1

1

1 1

0

  • 1 1 0 0

1 0 1 0

  • 1 1 0 1

1 0 1 1

  • 1 1 1 0

1 0 0 1

  • 1 1 1

1

1 0 0 0

0

White

3-bit Gray Code

000

001

011

010

110

111

101

100

  • 1 Black

0 White 3-bit Gray Code 000 001 011 010 110 111 101 100 1 Black 3-bit

3-bit Positional Encoder Disk

Binary to Gray Code Conversion

(BC)

1

+

(BC) 1 + 1 + 0 + 0

1

+

(BC) 1 + 1 + 0 + 0

0

+

(BC) 1 + 1 + 0 + 0

0

(GC)

1

0

1

0

• MSB does not change as a result of conversion

• Start with MSB of binary number and add it to neighboring binary bit to get the next Gray code bit

• Repeat for subsequent Gray coded bits

Gray to Binary Code Conversion

(GC)

1

(GC) 1 0 1 0

0

(GC) 1 0 1 0

1

(GC) 1 0 1 0

0

+

+

+

(BC)

1

(BC) 1 1 0 0

1

(BC) 1 1 0 0

0

(BC) 1 1 0 0

0

• MSB does not change as a result of conversion

• Start with MSB of binary number and add it to the second MSB of the Gray code to get the next binary bit

• Repeat for subsequent binary coded bits

Alphanumeric Codes

An alphanumeric code represents all of the various characters and functions that are found in a standard typewriter (or computer) keyboard.

ASCII Code:

The most widely used alphanumeric code, the American Standard Code for Information Interchange used in computers.

The original ASCII code is a 7 bit code and so it has =128 possible code groups.

2 7

The extended ASCII code has 8 bits and can represent 256 characters.

UNICODE can represent upto 1,114,112 characters and is now available for most scripts.

Character

7- Bit ASCII

Hex

A

1000001

41

B

1000010

42

C

1000011

43

.

….

Z

1011010

5A

0

0110000

30

9

0111001

39

a, b, …

blank,

etc.