# 5 bit to 7 seg decoder

Discussion in 'General Electronics Chat' started by 2010ee179, Oct 19, 2011.

1. ### 2010ee179 Thread Starter New Member

Jul 1, 2011
12
1
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)

2. ### MrChips Moderator

Oct 2, 2009
12,624
3,451
The simple solution would be to use a look-up table in a ROM chip.
Or you could use a MCU with two ports.

3. ### colinb Active Member

Jun 15, 2011
351
35
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.

2010ee179 likes this.
4. ### elec_mech Senior Member

Nov 12, 2008
1,513
193
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?

2010ee179 likes this.
5. ### RiJoRI Well-Known Member

Aug 15, 2007
536
26
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.

Code ( (Unknown Language)):
1.
2. [FONT="Courier New"]
3.    Buf  aM  bM  cM  dM  eM  fM  gM   aL   bL  cL  dL  eL  fL  gL
4.  --->----+---+---+---+---+---+---+----+---+---+---+---+---+---+---+
5.         \|  \|  \|  \|   |   |  \|    |  \|  \|   |   |   |   |
6. [/FONT]
7.
->- 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: Oct 19, 2011
6. ### Georacer Moderator

Nov 25, 2009
5,151
1,266
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: Oct 19, 2011
7. ### Georacer Moderator

Nov 25, 2009
5,151
1,266
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.

8. ### crutschow Expert

Mar 14, 2008
13,481
3,368
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.

9. ### 2010ee179 Thread Starter New Member

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

10. ### Georacer Moderator

Nov 25, 2009
5,151
1,266
2010ee179 likes this.
11. ### colinb Active Member

Jun 15, 2011
351
35
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.

12. ### crutschow Expert

Mar 14, 2008
13,481
3,368
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.

13. ### colinb Active Member

Jun 15, 2011
351
35
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...

14. ### MrChips Moderator

Oct 2, 2009
12,624
3,451
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.)

Code ( (Unknown Language)):
1.
2. dec E D C B A = BCD 6 5 4 3 2 1
3.
4. 0    0 0 0 0 0 =    0 0 0 0 0 0
5. 1    0 0 0 0 1 =    0 0 0 0 0 1
6. 2    0 0 0 1 0 =    0 0 0 0 1 0
7. 3    0 0 0 1 1 =    0 0 0 0 1 1
8. 4    0 0 1 0 0 =    0 0 0 1 0 0
9. :
10. :
11. 28  1 1 1 0 0 =    1 0 1 0 0 0
12. 29  1 1 1 0 1 =    1 0 1 0 0 1
13. 30  1 1 1 1 0 =    1 1 0 0 0 0
14. 31  1 1 1 1 1 =    1 1 0 0 0 1
15.
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: Oct 20, 2011
Georacer likes this.
15. ### 2010ee179 Thread Starter New Member

Jul 1, 2011
12
1
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...

16. ### MrChips Moderator

Oct 2, 2009
12,624
3,451
Good grief! I guess you didn't use my post.

17. ### 2010ee179 Thread Starter New Member

Jul 1, 2011
12
1
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...

18. ### colinb Active Member

Jun 15, 2011
351
35
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!

19. ### 2010ee179 Thread Starter New Member

Jul 1, 2011
12
1
I didn't build it yet...because it requires more and more gates..Yeah but I built it on Proteus and am happy it simulated perfectly...

20. ### colinb Active Member

Jun 15, 2011
351
35
I bet the cost of (1) all the logic ICs and most importantly (2) the cost of the PCB space required for ICs and all the traces will be so high that you would actually save money by using a CPLD instead, PLUS you would have a more reliable, compact, and flexible design. Or, use an EEPROM, which is "programmable" but can be done without learning any new special language or concepts.