Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Ministry of Higher Education and Scientific Research

Technology University

Department of Control Engineering and Systems

2019
Binary codes

An n - bit binary code is a group of n - bits that assume up to 2n distinct combinations


1's and 0's with each combination representing one element of the set that is being
coded .

1- BCD code (Binary coded decimal)


The code most commonly used for decimal digits . It uses the first 10 binary numbers
to represent the 10 decimal digits . Each decimal digit is represented by 4 - bits , and
thus a 2 - digit decimal number requires 8 bits .

Ex / write the equivalent BCD for (185)10


sol /
(185)10 = (0001 1000 0101)BCD
(185)10 = (1011 1001)2

2 - Gray code (unweighted)


The advantage of the Gray code over the straight binary number sequence is that only
one bit in the code group changes when going from one number to the next .

Ex / convert Binary number Gray

1 1 0 0 Binary

1 0 1 0

Ex / convert Gray code to Binary number

1 0 1 1 1 0 1 0 1

1 1 0 1 0 0 1 1 0
38
3 - Excess - 3 - code (unweighted)
Excess - 3 - code , is a modified form of BCD . Each coded character in the excess - 3 -
code is three large in BCD .

4 - Other decimal code


The 7421 and 2421 is a weighted decimal code table (1) some weight 4 - bit BCD
coded .

decimal 2421 7421


0 0000 0000
1 0001 0001
2 0010 0010
3 0011 0011
4 0100 0100
5 1011 0101
6 1100 0110
7 1101 1000
8 1110 1001
9 1111 1010

39
Ex / Convert Excess - 3 - code to BCD .

A B C D x y z w
0 0 1 1 0 0 0 0
0 1 0 0 0 0 0 1
0 1 0 1 0 0 1 0
0 1 1 0 0 0 1 1
0 1 1 1 0 1 0 0
1 0 0 0 0 1 0 1
1 0 0 1 0 1 1 0
1 0 1 0 0 1 1 1
1 0 1 1 1 0 0 0
1 1 0 0 1 0 0 1
1 1 0 1
1 1 1 0
1 1 1 1
AB
AB
00 01 11 10 CD 00 01 11 10
CD

00 d0 1 00 d 1
01 d1 d13 01 d d 1
11 d15 1 11 1 d

10 10 d 1
d2 d14 d

x=AB+ACD y = BC + BCD+BD
AB AB
00 01 11 10 CD 00 01 11 10
CD
d d 1 1 1
00 00

01 d 1 d 1 01 d d

d 11 d
11
d d 10 1 1
10 1 1 d d

z = C D + C D=C D w=D

40
A B C D

41
Ex / Convert BCD code to an excess - 3 - code

A B C D x y z w
0 0 0 0 0 0 1 1
0 0 0 1 0 1 0 0
0 0 1 0 0 1 0 1
0 0 1 1 0 1 1 0
0 1 0 0 0 1 1 1
0 1 0 1 1 0 0 0
0 1 1 0 1 0 1 0
0 1 1 1 1 0 1 1
1 0 0 0 1 1 0 0
1 0 0 1 d d d d
1 0 1 0 d d d d
1 0 1 1 d d d d
1 1 0 0 d d d d
1 1 0 1 d d d d
1 1 1 0 d d d d
1 1 1 1 d d d d

AB A B C D

CD 00 01 11 10

00 d 1
01 1 d 1
11 1 d d X
10 1 d 1

x = A + BD + BC

42
AB

CD 00 01 11 10 B C D
00 1 d
01 1 1
d
11 1 d d
10
1 d d y

y = BCD + BD + BC

AB

CD 00 01 11 10
C D
00 1 1 d 1
01 d

11 1 1 d d Z

10 d d

z = CD + CD = C D

AB
00 01 11 10
CD
00 1 1 d 1 D
01 d

11 d d w
10 1 1 d d

w=D

43

You might also like