# 5 bit to 7 seg decoder

#### 2010ee179

Joined Jul 1, 2011
12
Hi everyone...

I've just started studying digital logic design a month ago...
I want to convert 5 bit binary number to 2 digit 7 segment display...

I searched over the web, i could only find BCD to 7seg decoder but no chip that could decode my 5 bit number to display on 2-digit 7 seg...
My teacher says you won't find such chip....you need to make your own such decoder...

Please suggest me an IC....or tell me how to make my own decoder???

(I don't want to use any programmable chip or stuff like that...because i know nothing about this)

#### MrChips

Joined Oct 2, 2009
22,090
The simple solution would be to use a look-up table in a ROM chip.
Or you could use a MCU with two ports.

#### colinb

Joined Jun 15, 2011
351
Yeah, a ROM chip or CPLD could be used. Or you could implement it in discrete logic, e.g., with NAND gate ICs.

Also, you say you don't know about programmable devices, but it would be a great opportunity to learn about microcontrollers! This is a simple task for a little microcontroller and there are plenty of experts here who would be glad to offer assistance in getting it working.

#### elec_mech

Joined Nov 12, 2008
1,500
Using a microcontroller would be easiest, look at the PICAXE or Parallax Basic Stamp II.

Now, if you still decide against learning to program, you have one, two, maybe even three options left.

As colinb mentioned, option one is to build a decoder from scratch using discrete logic. You'll have to design this. Start by creating a truth table of all possible combinations of inputs followed by the desired outputs. From there you can begin to determine what logic and thus which ICs you'll need to make this happen.

Option two is to find an obsolete IC, the 74185. If you can get your hands on one, this looks like it will do the job for you. This is a ROM like colinb referred to.

How do you plan to input the 5-bit binary number? Are you going to use a DIP switch for each bit or something like a counter IC?

#### RiJoRI

Joined Aug 15, 2007
536
This is a case of, "It's doable, but is it worth it?"

Using 2 4-bit decoders, 1 inverter, 2 8-bit buffer/drivers, and 315* diodes, it can be done.

Data line 5 is used in conjunction with the inverter to select one of the two 16-bit decoders. The drivers are used to give more power to the diode array and to drive the 7-segment display.

The diodes are used to connect the buffered decoder lines to the display lines.

Rich (BB code):
   Buf  aM  bM  cM  dM  eM  fM  gM   aL   bL  cL  dL  eL  fL  gL
--->----+---+---+---+---+---+---+----+---+---+---+---+---+---+---+
\|  \|  \|  \|   |   |  \|    |  \|  \|   |   |   |   |
->- is the driver, \ shows a diode between the output lines and the display lines. The number shown is 31 -- the output of the 15th line of the second decoder.

a..g are the display lines, and M and L show the LSD and MSD displays.

Given the time and effort, and frustration, you'd be better off getting something like a BASIC Stamp or Arduino board.

* 315 is a quick calculation, assuming the numbers 0..9 do not need a leading 0, and ALL the connections need a diode (they don't). (15 lines x 7 lines x 3 arrays = 315).

--Rich

(If I remember, the diode array for ROM was used by Steve Ciarcia.)

Last edited:

#### Georacer

Joined Nov 25, 2009
5,182
If you want to stick to discrete digital circuitry and avoid ROMs and uCs, you can always convert your binary to BCD with two 4-bit adders and then use two BCD-to-7seg drivers to power the displays.

Last edited:

#### Georacer

Joined Nov 25, 2009
5,182
Errata: It seems I have confused BCD conversion with BCD addition. In the previous post, I had in mind the addition of 6, which applies to BCD addition, not in the binary-to-BCD conversion.

The conversion is a bit more component-demanding. That said, the easier choice to do the conversion would be an IC like the 74185.

Apologies for the misdirection.

#### crutschow

Joined Mar 14, 2008
25,653
Binary to BCD conversion is not as easy as it might seem. One sequential technique uses a count-down binary counter (two 4-bit counters for 6 bits) and two count-up BCD to 7-segment display counters such as the CD40110. The clock is common to both counters.

The sequence is:
1) Parallel load the binary number into the binary counter
2) Clock the binary counter to count down to zero and stop the clock
3) Use the same clock to cause the BCD counter to count up form zero.
4) When the binary counter reaches zero and the clock stops, the desired number will be in the BCD counter, which is displayed on the 7-segment display.
5) Reset the BCD counter to zero for the next number.

#### 2010ee179

Joined Jul 1, 2011
12
Thanks all for help...
@colinb, I'd learn about programmable chips in my 4th semester when I'll be taught...

#### colinb

Joined Jun 15, 2011
351
Thanks all for help...
@colinb, I'd learn about programmable chips in my 4th semester when I'll be taught...
Yeah, it would be a shame to learn something too early, wouldn't it! If you learned something about them now, think how easy your 4th semester will be, though. And, you'll certainly learn more since you won't be trudging through the basics like most of your classmates.

Don't wait to be taught things! Learn to learn on your own. You'll be doing it the rest of your career.

#### crutschow

Joined Mar 14, 2008
25,653
Yeah, it would be a shame to learn something too early, wouldn't it! If you learned something about them now, think how easy your 4th semester will be, though. And, you'll certainly learn more since you won't be trudging through the basics like most of your classmates.

Don't wait to be taught things! Learn to learn on your own. You'll be doing it the rest of your career.
I think your sarcasm is misplaced. The OP is learning about logic circuits, which he should complete before he takes a shortcut and uses a programmable chip. If he doesn't learn logic then he will have a difficult time using the programmable devices.

#### colinb

Joined Jun 15, 2011
351
I think your sarcasm is misplaced. The OP is learning about logic circuits, which he should complete before he takes a shortcut and uses a programmable chip. If he doesn't learn logic then he will have a difficult time using the programmable devices.
OK, point taken. It is probably best to defer programmable devices until basic digital logic is understood. I just had been responding to some student homework questions right before this from people who apparently DIDN'T EVEN LOOK AT THE TEXTBOOK OR LECTURE NOTES and was in a bad mood... sorry 2010ee179 you don't need to learn microcontrollers first.

But my argument still stands that you shouldn't wait to be taught something. You should get ahead of the course schedule a bit if at all possible and at the very least preview some of what is ahead. It will just make your education many times more effective if you are prepared ahead of time.

Anyway, 2010ee179 I am glad you are actually trying to solve this problem and thinking it through. Do projects, solve problems, and ask a lot of questions. You'll be far ahead of the average student who just cruises along without asking deeper questions...

#### MrChips

Joined Oct 2, 2009
22,090
I will show you how to do a Karnaugh map for five bits.

You begin with writing out a table for all the possible 5-bit inputs and the desired 6-bit BCD results. I am only going to start the table for you. You have to finish it.
(The columns may not line up.)

Rich (BB code):
dec E D C B A = BCD 6 5 4 3 2 1

0    0 0 0 0 0 =    0 0 0 0 0 0
1    0 0 0 0 1 =    0 0 0 0 0 1
2    0 0 0 1 0 =    0 0 0 0 1 0
3    0 0 0 1 1 =    0 0 0 0 1 1
4    0 0 1 0 0 =    0 0 0 1 0 0
:
:
28  1 1 1 0 0 =    1 0 1 0 0 0
29  1 1 1 0 1 =    1 0 1 0 0 1
30  1 1 1 1 0 =    1 1 0 0 0 0
31  1 1 1 1 1 =    1 1 0 0 0 1
For each BCD bit 1 to 6, draw a 5-variable Karnaugh Map.
I have done BCD-6 for you.
Enter into each box the desired output for that BCD bit.
Next, you group all the 1's into the largest groups of 16, 8, 4 and 2s, overlapping if necessary.

The result in this example is:

BCD-6 = CE + DE = E(C + D)

So in all, you have to do this six times for each of the six bits for your 2-digit BCD decoder.

Look at a previous post if this is not clear.

Last edited:

#### 2010ee179

Joined Jul 1, 2011
12
Thanks everyone for guiding me and showing such encouraging attitude....
I learned a lot here and got able to design my DECODER...It takes 5 bit input and displays it as decimal....Though it got so much complicated...but worked well
Here is a pic, I'd like to share with you people...

#### MrChips

Joined Oct 2, 2009
22,090
Good grief! I guess you didn't use my post.

#### 2010ee179

Joined Jul 1, 2011
12
Your post helped me...Actually I was trying to make 5 bit to 7 segment decoder which was not available as a chip...whereas there any many binary to BCD converter out there.

My aim was to provide 5 bit input and directly feed output to 7 segment...

#### colinb

Joined Jun 15, 2011
351
Thanks everyone for guiding me and showing such encouraging attitude....
I learned a lot here and got able to design my DECODER...It takes 5 bit input and displays it as decimal....Though it got so much complicated...but worked well
Here is a pic, I'd like to share with you people...
Holy cow. Did you actually build that? If so, you must have a lot of patience and be either very lucky or very skilled that you were able to build it with no errors!