Sie sind auf Seite 1von 26

DEPARTMENT OF TECHNICAL EDUCATION

ANDHRA PRADESH
Name : P.Swarupa
Designation : Lecturer
Branch : ECE
Institute : Govt.Polytechnic, Masab Tank, Hyd.
Semester : III Semester
Subject : Digital Electronics
Subject Code : EC – 304
Topic : Basics of Digital Electronics
Duration : 50 Mts.
Sub-Topic : Digital Codes
Teaching Aids : PPT Animations
EC304.6 1
Objectives
• On the completion of this topic, you would be able to
Know

• Weighted codes.
• Unweighted codes.
• Comparison of weighted and unweighted codes
• Conversion of 8421, Excess-3 & Gray code to binary
and vice-versa.
• Alphanumeric codes
• Parity Bit.

EC304.6 2
Recap

• In Decimal System, what is the value of 6 in 657?

• What is the value of 6 in 567?

• What is the value of 6 in 576?

• What are the different types of codes used in


Electronics and Communications?

EC304.6 3
Binary Codes

• Digital Systems operate in a binary system.

• Coding is the process of converting numerals,


alphabets and special characters into binary
format.

• Combination of Binary digits is called as Digital


codes.

EC304.6 4
Weighted Codes
• Digital codes are classified as (i) weighted codes (ii)
unweighted codes.

• In weighted code each bit is given a weightage.

• Weighted codes ex.8421, Hexa decimal, octal, Binary


etc.,

• In unweighted codes there is no positional value for the


bits.

• Unweighted codes ex. Excess 3 code, gray code.


EC304.6 5
Comparison between weighted and
unweighted codes
Weighted Code Unweighted Code
• Each Position of the bit • Each Position of the bit is
represents a specific not assigned any specific
weight. weight.

• Ex.8421, Octal, Hexa • Ex.Excess-3 and gray


Decimal. code.

• Useful in digital circuits • Useful in digital


like digital calculators and computers, shift position
voltmeters encoders

EC304.6 6
BCD Code

• In this code decimal digits 0 to 9 are represented by


Binary equivalents

• Ex.23 is represented as 0010 0011

• Also known as 8421 code. 8, 4, 2 & 1 are the weights of


the four bits of the binary code

• Hence it is weighted code

EC304.6 7
Conversion of Binary Code to 8421 Code

• Ex.110001100 is the binary code.

• 110001100 is equivalent to 396 decimal number.

• (396)10 is equivalent to 0011 1001 0110 in the 8421


Code.

• (110001100)2 = (396)10 = 0011 1001 0110.

EC304.6 8
Conversion of 8421 Code to
Binary Code

• Ex.0010 0111 is the 8421 Code.

• 0010 0111 is equivalent to 27 decimal number.

• (27)10 is equivalent to 11011 Binary Code.

• 0010 0111 = (27)10 = (11011)2.

EC304.6 9
Excess-3 Code

• Is a 4 bit Code.

• In Excess-3 form, ‘3’ is added to each decimal digit.

• Then convert the sum to a BCD Number.

• BCD can be converted to Binary as in the previous


example.

EC304.6 10
To convert Binary number 1100 to Excess-3 code
1100 Binary code is equivalent to (12)10
Add 3 to each decimal digit
• 1 2
• +3 +3
• ------- -------
• 4 5
• ------- -------
45 is equivalent to 0100 0101
(1100)2 = (12)10 = 0100 0101 is the
• Excess-3 Code

EC304.6 11
Gray Code

• In this code two adjacent numbers differ in only one bit.

• Hence called as unit distance code.

• It has same bit length and MSB as Binary number.

EC304.6 12
Binary - Gray Code
• Write the MSB of the binary as it is
• 1 0 0 1

• 1
• Add the MSB to the next lower significant bit of Binary
number & note down the sum, ignore the carry
• 1001 1+0=1
• 0+0=0
• 1101 0+1=1
• Continue the same process till all the binary digits are
added.
• 1101 is the gray code of 1001 binary number.

EC304.6 13
To convert Gray Code 1110 number to
Binary Code number

• Write the MSB as it is


• Gray code number 1 1 1 0

• Binary number 1
• Add the MSB of the Binary to next LSB of gray code,
note down the sum, ignore the carry
• Gray code number 1 1 1 0

• Binary number 1 0 1 1
• 1011 is the binary number of 1110 gray code number

EC304.6 14
Alphanumeric codes

• The alphanumeric codes are used to represent decimal


digits, alphabets (Upper case and lower case) and
special characters. The two alphanumeric codes used
are:

• ASCII (American Standard Code for Information


Interchange)

• EBCDIC (Extended Binary Coded Decimal Interchange


Code)

EC304.6 15
ASCII

• This is a 8-bit code.


• The MSB is used for parity and remaining 7 bits are used
for coding
• This code can be extended to 8 bits by using the MSB
for coding
• This code is used by most of the computers in the world

EC304.6 16
EBCDIC

• This is also a 8-bit code

• This is used by some IBM computers

EC304.6 17
Parity Bit

• Digital information in binary form is transmitted from one


system to another system.

• Error may occur i.e., 0 may change to 1 or vice-versa.

• Errors can be detected by adding one additional bit


known as parity bit.

• Allows the detection of a single error in transmission.

EC304.6 18
• Parity means number of once in a digital data may be
even or odd.

• ASCII Code is a 7 bit code.

• For Ex. ASCII Code for ‘C’ is 1000011.

• There are three ones in this.

• Add extra bit as MSB. The total number of ones is odd


and extra bit added is ‘0’ called as odd parity.

• The total number of ones is even if extra bit added is ‘1’


and called as even parity.
EC304.6 19
Parity Bit (contd..)

• Ex. ASCII Code for ‘C’ is 1000011.

• Odd parity 01000011.

• Even parity 11000011.

EC304.6 20
Summary
• We have discussed about

• Weighted and unweighted codes.

• Differences
• Conversion of 8421, Excess-3 and Gray code to
binary and vice-versa.

• Use of Parity bit.

EC304.6 21
QUIZ

EC304.6 22
1. The code used for 9 in BCD ________

c) 1001

d) 1010

e) 1011

f) 1111

EC304.6 23
2. Example of unweighted code

c) Excess-3

d) Binary code

e) BCD Code

f) Decimal

EC304.6 24
3. Example of weighted code

• (i) Excess-3
• (ii) Gray code
• (iii) BCD Code
• (iv) none

EC304.6 25
Frequently Asked Questions
• Give the difference between weighted and unweighted
codes.

• What is the importance of parity bit?

• Express decimal equivalent 5280 in Excess-3 code.

• What is the gray code for decimal ‘8’?

• Convert gray code number 1110 to its BCD equivalent.


EC304.6 26

Das könnte Ihnen auch gefallen