5
\$\begingroup\$

I'm trying to display a 4-bit binary number on a 7 segment LED as a hexadecimal number (0-F). I have an assortment of 7400 series ICs including the 7447. But that one only works for BCD (0-9). The 7400 series doesn't seem to have a hex to 7-segment decoder and I don't have one on hand.

So I figure I'd have to build my own. The datasheet for a 7447 comes with the internal circuitry but I couldn't find a similar circuit for hex to 7-segment. I did K-diagrams for each LED segment by hand but the terms are rather large, much larger than for BCD.

Does anyone have a finished circuit for this that I can check my work against?

Does anyone have an optimized circuit for this that takes advantage of common subterms? There aren't many duplicate terms (like A0 & ~A1 & A2) but maybe using (A0 & A2) & ~A1 would allow sharing the (A0 & A2) subterm and overall reduce the gate count.

Or maybe some tricks to use NAND, NOR or XOR gates for some parts?

I don't care about different path length or races in the circuit as it's only going to drive LEDs and should be far too quick to see any of that.

\$\endgroup\$
  • 10
    \$\begingroup\$ I know it's not the right solution you're looking for but I'd recommend using an EEPROM such as AT28C16 or similar to convert the binary to hex. You'll just need to program the first 16 bytes. Connect the four binary numbers to be converted to the hex to the first 4 address lines and the data lines to the 7-seg pins. Program each byte of the first 16 bytes so that for address 0000 it lights up 0 on 7-seg display, for address 0001 it lights up 1 on the 7-seg display, and .... . Repeat this until you've programmed all the first 16 bytes. This can be done with a uC as well. \$\endgroup\$ – dirac16 Jan 23 '18 at 13:04
  • \$\begingroup\$ @dirac16, wouldn't you program the last 16 bytes, and pull up the unused address lines? \$\endgroup\$ – Solomon Slow Jan 23 '18 at 15:02
  • \$\begingroup\$ @jameslarge Yes, you can. But I would program the first 16 bytes and pull down the other unused address lines. \$\endgroup\$ – dirac16 Jan 23 '18 at 15:43
  • \$\begingroup\$ I confess, my thinking still is shaped by the TTL era when all unused inputs were pulled high. \$\endgroup\$ – Solomon Slow Jan 23 '18 at 16:07
  • 3
    \$\begingroup\$ @Baldrickk Hexadecimal on a 7-segment display uses lower-case for "b" and "d". You do then have a problem with "b" and "6" being similar, but "6" has the top segment filled in and "b" does not. (Based on the Casio FX-100D calculator which is on my desk in front of me right now.) \$\endgroup\$ – Graham Jan 23 '18 at 16:35

10 Answers 10

15
\$\begingroup\$

Find what museum is missing their 74xx logic ICs and return them. Then get a small microcontroller and do all this in a single chip. As a bonus, you'll be ready for other advanced projects from the late 1980s and beyond.

\$\endgroup\$
  • 4
    \$\begingroup\$ Until today my old university still requires students to use LS74 IC's. I guess it helps us in our foundations? \$\endgroup\$ – hungrykoala Jan 24 '18 at 4:41
  • 3
    \$\begingroup\$ I could use my At-Mega and e-paper hat. But that isn't what I asked for. \$\endgroup\$ – Goswin von Brederlow Jan 25 '18 at 8:11
9
\$\begingroup\$

Maybe, if you feel particularly adventurous, you could even use a diode ROM, with perhaps two 74'138 3-to-8 line decoders to decode/drive the stuff. :)

A crude schematic Here's a crude schematic of the whole contraption; If you happen to use some highish efficiency LED displays, you may even be able to drive a common anode one directly.

The '!EN' pin can be either of the gate pins of the '138. You can also connect both of the other gate pins together, letting you turn the display output on or off as you please.

This also has the benefit over the suggested ROM solution that it's inexpensive to build/prototype if you have the parts on hand, or can't be particularly bothered to program ROMs.

Besides, one could even call this fun to make :)

\$\endgroup\$
  • 1
    \$\begingroup\$ A 22V10 costs about $2 and can do this in one chip, but I admire your intrepidity. \$\endgroup\$ – stark Jan 23 '18 at 15:45
  • 2
    \$\begingroup\$ If you're even more adventuresome, it might be fun to work out a more "economical" approach if you're willing to put two diodes in series. For example, if one used two diodes for each "corner" to light up a top or bottom segment along with the adjoining edge (eight diodes), that would save two diodes from each of 0, 2, 3, 5, 8, one from 7, and one or two from 6 and 9 (depending upon the font). A simple diode ROM layout is probably easier to build, but working out a cheaper solution might be a nice puzzle. \$\endgroup\$ – supercat Jan 23 '18 at 17:30
  • 1
    \$\begingroup\$ The trick to use here is to program the dark segments, since there are fewer of them. Also use the '154 4-line to 16-line decoder. :) \$\endgroup\$ – Lurker Larry Jan 24 '18 at 6:07
  • 1
    \$\begingroup\$ 1n4148 diodes cost 40 UK pence per hundred at Farnell. I remember making just this circuit. In 1975. \$\endgroup\$ – emrys57 Jan 24 '18 at 14:41
  • 1
    \$\begingroup\$ I like this. I would probably connect the outputs of the "ROM" to NOT gates to actually drive the LEDs. Otherwise for 8 you have to drive all 7 segments with a single output pin of an 74138. That would make it 4 ICs + lots of diodes. \$\endgroup\$ – Goswin von Brederlow Jan 25 '18 at 8:59
9
\$\begingroup\$

If you want to fiddle with gates, another possibility is to use a small FPGA or CPLD. You can get started with a flash-based FPGA for a few tens of dollars.

Reprogram it as many times as necessary to get it right, and you generally get a lot of I/O pins per dollar.

Example VHDL code here

For example, (shaky and not quite a complete loop, but you get the idea):

enter image description here

\$\endgroup\$
6
\$\begingroup\$

But that one only works for BCD (0-9).

Actually 7447 physically can accept hex values of A-F, but they display wrong images for them, see here page 3.

In my opinion, making hex-to-seven-segment decoder might be a good for education and visualization of how digital electronics work, but it is really bad idea from practical point of view - it is unnecessary complex and consumes much power in comparison to other solutions.

I recall having a PC diagnostic board back in ~1995 which was displaying error/status codes in hex (something like this), and this board used GAL chips - predecessors of CPLD.

If you have searched over internet for the solution, you might have seen a lot of similar projects using programmable logic or MCU-based devices like Arduino.

@dirac16 suggested another way - using parallel ROM chip, a kind of lookup table with bytes in it representing segments being on/off for respective address (input value).

\$\endgroup\$
  • \$\begingroup\$ It's not supposed to be practical but instructional. \$\endgroup\$ – Goswin von Brederlow Jan 25 '18 at 9:00
5
\$\begingroup\$

MC14495, DM8880/9368, V40511, D345, D346, 4311, 4368 or 74C915

All of these are hard to get your hands on nowadays.

\$\endgroup\$
  • \$\begingroup\$ I saw a reference to the MC14493 doing hex to 7-segment, but I got frustrated while looking for a datasheet. But it was available for 8.75 EUR in single quantities. I am scared that it is only bcd though, so I would find that datasheet first. \$\endgroup\$ – Lurker Larry Jan 25 '18 at 18:12
  • 1
    \$\begingroup\$ 74C915 is a 7-segment to BCD converter. So wrong way and only BCD not hex. Strange chip to make. \$\endgroup\$ – Goswin von Brederlow Jan 29 '18 at 11:34
  • 1
    \$\begingroup\$ Ah yes, you are right. But I know a use case for such a chip: stamped scales. They require the customer sees the correct weight, so law may require you to convert the visible output back to BCD if you ever wanted to connect a printer. \$\endgroup\$ – Janka Jan 29 '18 at 12:57
  • \$\begingroup\$ @LurkerLarry MC14495 is still available on eBay, $1.50, and here is the datasheet. I've bought a couple recently, no problem experienced. \$\endgroup\$ – Greenonline Jul 7 '18 at 20:16
2
\$\begingroup\$

If you want to design the functions by hand an check them for correctness before (or instead of) implementing them in hardware, you can use an online calculator like this one.

There are also tools which can minimize multiple logic functions sharing common inputs. One is expresso, which has free implementations in Windows and Linux.

\$\endgroup\$
  • 2
    \$\begingroup\$ This really sounds like a comment offering supporting advice, not an answer. \$\endgroup\$ – Chris Stratton Jan 23 '18 at 19:08
  • 1
    \$\begingroup\$ @ChrisStratton Frankly I don't see the benefit of posting the actual solutions here. \$\endgroup\$ – Dmitry Grigoryev Jan 23 '18 at 20:22
  • 1
    \$\begingroup\$ That calculator only solves one output at a time and shows only one solution even if there are multiple. That means it can give solutions that have less terms in common between the outputs. I.e. use more gates than necessary. \$\endgroup\$ – Goswin von Brederlow Jan 25 '18 at 9:06
  • \$\begingroup\$ @GoswinvonBrederlow Good point, but it's a matter of search to find a logic optimizer which does what you want. \$\endgroup\$ – Dmitry Grigoryev Jan 25 '18 at 10:08
  • \$\begingroup\$ @DmitryGrigoryev I've searched before and I have never found a free logic optimizer yet that does more than just transform the POS or SOP to use different gate types. Nothing that actually optimizes. It's a NP hard problem I believe and quickly takes to long to find the optimal solution. So people don't try. It quickly becomes simpler to use a rom as lookup table (as suggested above). \$\endgroup\$ – Goswin von Brederlow Jan 25 '18 at 15:09
2
\$\begingroup\$

I think I have managed to find the optimal solution (one of them) now. It uses all 24 gates of 6 ICs:

  • 2x 7486 (quad XOR)
  • 1x 7408 (quad AND)
  • 2x 7402 (quad NOR)
  • 1x 7432 (quad OR)

I've managed to find different solutions using only 23 gates but more ICs. I have a feeling there isn't a solution with just 5 ICs.

Note: The circuit outputs LOW when the LED should be on since my 7 segment LED has a common VCC.

schematic

simulate this circuit – Schematic created using CircuitLab

D3-D0 are the inputs with D3 being the MSB. A-G are the outputs with A being the top LED, then going clockwise around and last G being the center LED.

\$\endgroup\$
  • \$\begingroup\$ Have you considered something like the 74HC157 [2-channel 4:1 multiplexer] or possibly an inverting variant thereof? It might have been nicer if there were a variant which traded off the enable outputs for separate left/right selection inputs, but such chips can be really handy sometimes. \$\endgroup\$ – supercat Apr 20 '18 at 20:58
  • \$\begingroup\$ Only as an alternative to a diode rom but you need too many of them. You could use them as programmable gates but each multiplexer would have to replace 2 gates to draw even. \$\endgroup\$ – Goswin von Brederlow Apr 21 '18 at 14:52
1
\$\begingroup\$

It's been said you can try the ICM7218 or some other chips.

You may also try to build your own combination circuit. This is a great video tutorial on how to do it and its mechanics. If you want to optimize it, there are some datasheets (1, 2) with the BCD (0-9) part.

As a follow-up, this guy also made a follow-up video on how to do the same with an EEPROM. Granted, you still have to program it, but it may be worth it.

And talking about programming, you may also do it all with a microcontroller. It is usually easier to program than a CPLD (which you may also use), and there are both code and tabular implementations. I'd use this option, since I'm familiar with microcontrollers (you're not limited to the Arduino) and for just the chip it might even be your cheapest option.

\$\endgroup\$
1
\$\begingroup\$

Use Google to find "hex 7-segment" items, including http://en.wikipedia.org/wiki/Seven-segment_display which has a hex truth table (in hex!). Other items include diagrams and video demonstrations.

I was actually looking for four-digit, seven-segment displays that do the hex decoding for you, but they are considered to be "ancient" (sniff) and modern ones use i2c rather than parallel interfaces.

\$\endgroup\$
  • \$\begingroup\$ And 95% of the results actually talk about BCD to 7 segment, 4% have no circuit but just truth tables and such and 1% are videos where you can't make out what is supposed to be an and gate or or gate. \$\endgroup\$ – Goswin von Brederlow Jan 25 '18 at 8:47
  • \$\begingroup\$ Perhaps then I should have just posted this link youtu.be/7zffjsXqATg and said that the circuit you requested is at 12 minutes in and his TTL implementation is shown 30 seconds later. His part list is in the description. I sincerely apologize for not taking into account that search engine results are not predictable. \$\endgroup\$ – Lurker Larry Jan 25 '18 at 17:42
  • \$\begingroup\$ Yeah, that's the 1% in the search that actually applies, the "videos where you can't make out what is supposed to be an and gate or or gate". I looked at the circuit again and it uses 49 AND and OR gates. codegolf.stackexchange.com/questions/37648/… on the other hand has a solution with 37 NAND gates. So far that's the winner. \$\endgroup\$ – Goswin von Brederlow Jan 29 '18 at 11:55
0
\$\begingroup\$

I've been using the DM9368N for that purpose for years now, and it's reasonably easy to get (15$ for a 10-pack on ebay or Aliexpress).

\$\endgroup\$
  • \$\begingroup\$ This device has exactly the logic required for the job, but look out for the supply current! \$\endgroup\$ – henros Jan 25 '18 at 11:03
  • \$\begingroup\$ @henros Of course, this chip is designed for driving an LED display directly.. you can not use it just as a decoder to forward into further logic. \$\endgroup\$ – WooShell Jan 25 '18 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.