0% found this document useful (0 votes)
45 views

Unit 4

1. The document discusses binary coded decimal (BCD) codes and methods for converting between binary, decimal, and BCD formats. 2. Key conversion methods covered include binary to BCD, BCD to binary, BCD to seven-segment display codes, and BCD addition. 3. Examples are provided to demonstrate how to perform conversions step-by-step and how to handle invalid results in BCD addition.

Uploaded by

kaavya shruthi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Unit 4

1. The document discusses binary coded decimal (BCD) codes and methods for converting between binary, decimal, and BCD formats. 2. Key conversion methods covered include binary to BCD, BCD to binary, BCD to seven-segment display codes, and BCD addition. 3. Examples are provided to demonstrate how to perform conversions step-by-step and how to handle invalid results in BCD addition.

Uploaded by

kaavya shruthi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Codes Conversion

The BCD stands for Binary Coded Decimal Number. In BCD code, each digit of
the decimal number is represented as its equivalent binary number. So, the LSB
and MSB of the decimal numbers are represented as its binary numbers.

There are many methods or techniques which can be used to convert code from
one format to another. We'll demonstrate here the following

 Binary to BCD Conversion


 BCD to Binary Conversion

Binary to BCD Conversion


Steps

 Step 1 -- Convert the binary number to decimal.


 Step 2 -- Convert decimal number to BCD.

Example − convert (11101)2 to BCD.

Step 1 − Convert to Decimal

Binary Number − 111012

Calculating Decimal Equivalent −

Step Binary Number Decimal Number

Step 1 111012 ((1 × 24) + (1 × 23) + (1 × 22) + (0 × 21) + (1 × 20))10

Step 2 111012 (16 + 8 + 4 + 0 + 1)10

Step 3 111012 2910

Binary Number − 111012 = Decimal Number − 2910

Step 2 − Convert to BCD

Decimal Number − 2910

Calculating BCD Equivalent. Convert each digit into groups of four binary digits
equivalent.

Step Decimal Number Conversion

Step 1 2910 00102 10012

Step 2 2910 00101001BCD

Result
(11101)2 = (00101001)BCD

Questions:
Convert 10110110 to BCD format
(1 * 2^7) + (0 * 2^6) + (1 * 2^5) + (1 * 2^4) + (0 * 2^3) + (1 * 2^2) + (1 * 2^1) + (0 * 2^0)
= (128) + (0) + (32) + (16) + (0) + (4) + (2) + (0) = 182
BCD: 0001 1000 0010

1. (10110)2 = ( ? )BCD
Solution:
(10110)2 = (_______)BCD

1. Convert binary to decimal


(10110)2 = (_______)10
10110
=1×24+0×23+1×22+1×21+0×20
=1×16+0×8+1×4+1×2+0×1
=22

∴ (10110)2 = (22)10

2. Convert decimal to BCD


(22)10 = (_______)BCD

2 2
0010 0010

∴ (22)10 = (00100010)BCD
∴ (10110)2 = (00100010)BCD

2. (10011)2 = ( ? )BCD
Solution:
(10011)2 = (_______)BCD

1. Convert binary to decimal


(10011)2 = (_______)10
10011
=1×24+0×23+0×22+1×21+1×20
=1×16+0×8+0×4+1×2+1×1
=19
∴ (10011)2 = (19)10

2. Convert decimal to BCD


(19)10 = (_______)BCD

1 9
0001 1001

∴ (19)10 = (00011001)BCD
∴ (10011)2 = (00011001)BCD
BCD to Binary Conversion
he process of converting BCD code into Binary is opposite to the process of
converting Binary code into BCD. There are the following steps to convert the BCD
code into Binary:

In the first step, we will convert the BCD number into a decimal by making the
four-bit groups and finding the equivalent decimal number for each group.

In the last step, we will convert a decimal number into Binary using the process of
converting decimal to binary number.

Steps

 Step 1 -- Convert the BCD number to decimal.


 Step 2 -- Convert decimal to binary.

Example − convert (00101001)BCD to Binary.

Step 1 - Convert to BCD

BCD Number − (00101001)BCD

Calculating Decimal Equivalent. Convert each four digit into a group and get
decimal equivalent for each group.

Step BCD Number Conversion

Step 1 (00101001)BCD 00102 10012

Step 2 (00101001)BCD 210 910

Step 3 (00101001)BCD 2910

BCD Number − (00101001)BCD = Decimal Number − 2910

Step 2 - Convert to Binary

Used long division method for decimal to binary conversion.

Decimal Number − 2910

Calculating Binary Equivalent −

Step Operation Result Remainder

Step 1 29 / 2 14 1

Step 2 14 / 2 7 0

Step 3 7/2 3 1
Step 4 3/2 1 1

Step 5 1/2 0 1

As mentioned in Steps 2 and 4, the remainders have to be arranged in the


reverse order so that the first remainder becomes the least significant digit
(LSD) and the last remainder becomes the most significant digit (MSD).

Decimal Number − 2910 = Binary Number − 111012

Result

(00101001)BCD = (11101)2
BCD to seven-segment LED code conversion

The Binary Coded Decimal (BCD) encoding method uses binary patterns to
encode each decimal value (from 0 to 9), generally of 4-bits.

In contrast, a seven-segment display is an electrical device that displays Hexadecimal


digits using seven Light Emitting Diodes (LEDs) arranged in a specific pattern
(common cathode or common anode type) (in this case, decimal numbers, as input,
are BCD, i.e., 0-9).

7-Segment LED displays are of two types:

1. Common Cathode Type (CCT) - This form of the display works by connecting
all seven of the LEDs' cathodes to ground or -Vcc (thus, common cathode),
which causes the LEDs to display numbers when a "HIGH" signal is applied to
each anode.
2. Common Anode Type (CAT) - The seven LEDs in this display have all seven
of their anodes linked to a battery or +Vcc, and when a 'LOW' signal is applied
to each individual cathode, the LEDs display numbers.

The separate LED segments of a seven-segment display are not directly powered.
However, for it to function, we first convert our decimal number to its BCD equivalent
signal, and then a BCD to seven-segment decoder converts that signal into the form
supplied to the seven-segment display.

The seven-segment decoder, which has four input lines and seven output lines
(a, b, c, d, e, f, and g), receives this BCD (A, B, C, and D) input. The output is
provided to a seven-segment LED display that shows the decimal number depending
on the inputs.
The truth table of Common Cathode Type BCD to the seven-segment decoder is
given below:

Decimal Number INPUT Lines OUTPUT Lines

A B C D A b C d e f G

0 0 0 0 0 1 1 1 1 1 1 0

1 0 0 0 1 0 1 1 0 0 0 0

2 0 0 1 0 1 1 0 1 1 0 1

3 0 0 1 1 1 1 1 1 0 0 1

4 0 1 0 0 0 1 1 0 0 1 1

5 0 1 0 1 1 0 1 1 0 1 1

6 0 1 1 0 1 0 1 1 1 1 1

7 0 1 1 1 1 1 1 0 0 0 0

8 1 0 0 0 1 1 1 1 1 1 1

9 1 0 0 1 1 1 1 1 0 1 1

Important points:

1. For a seven-segment LED display of the Common Anode type, all we need to
do is swap all of the '0's and '1's on the output side, i.e., for a, b, c, d, e, f, and
g, swap all of the '1's for '0's, and use k-map to solve.
2. In the above truth table, the combinations of inputs represent the digits from
0 to 1.
3. The range of BCD numbers is 0 to 9, and the rest of the inputs are invalid.

Let us now understand the few inputs:

For Decimal Number = 0

The input lines for Zero are A = 0, B = 0, C = 0, and D = 0 and in the output lines, a
to f are 1 and only g = 0. So, the g LED display will not glow, and the rest of the LEDs
will glow, and we get zero on display.
For Decimal Number = 2

The input lines for two are A = 0, B = 0, C = 1, and D = 0; in the output lines, a, b, d,
e, and g are 1 and c and f are zero. So, only a, b, d, e, and g will glow, and we get two
on display.
Karnaugh Maps Simplification

For other combinations of input, the output is “don’t care X” as there are no more
digits to display. We will derive the expression for each output using Karnaugh map
(K-MAP).
For output a:

For output b:
For output c:

For output d:
For output e:

For output f:
For output g:

BCD Addition
Steps of BCD Addition

 Step 1: Add the two BCD numbers using the rules for binary addition.
 Step 2: If a 4-bit sum is equal to or less than 9, it is a valid BCD number.
 Step 3: If a 4-bit sum is greater than 9 or if a carry-out of the 4-bit group is
generated, it is an invalid result. Add 6 (0110) to the 4-bit sum in order to skip the
six invalid BCD code words and return the code to 8421. If a carry results when
6 is added, simply add the carry to the next 4-bit group.
Example 1: Find the sum of the BCD numbers 01000011 + 00110101

Solution:

Decimal number of the given BCD numbers are as below:

01000011BCD = 4310 and 00110101BCD = 3510

Example of BCD Addition

In the above example, all the 4-bit BCD additions generate valid BCD numbers, which means
less than 9. So, the final correct result is 7810 = 01111000BCD.

Let’s take an example where the addition generates an invalid BCD number.

In BCD (Binary Coded Decimal) addition, 6 is added to the result of an addition when the result is
larger than 9. This is because the maximum value that can be counted in a BCD nibble (4 bits) is
16, while the maximum value in BCD is 9. The difference between 15 and 9 is 6.

Example 2: Find the sum of the BCD numbers 01110101 + 00110101

Solution:

The decimal number of the given BCD numbers are as below:

01110101BCD = 7510 and 00110101BCD = 3510

Another Example of BCD Addition

In the above example, both the BCD code addition generated result larger than 9, so invalid. To
get the correct result, we added 6 (0110 2) to both the invalid sum. Notice that the carry generated
from the left group is forwarded to the right group. The final correct result is 110 10 =
000100010000BCD.
Solve

1. Consider adding (+255)10 and (+63)10 in BCD


2. Add 35)10 and 26)10 in BCD
3. Perform in BCD (57)10 + (26)10
4. Perform in BCD (83)10 + (34)10
5. Perform in BCD (421)10 + (975)10

BCD Subtraction

You might also like