Shedding light on seven-segment displays -

Shedding light on seven-segment displays

Learn how to build a seven-segment display—the hard way. Getting there is half the fun.

We've been talking about symbolic logic and ways to use it. Last month, I gave my readers an assignment to generate the equations for driving a seven-segment display.

Anyone who has ever owned a digital watch or clock should recognize seven-segment displays. They're the ubiquitous, squared-off displays like the one in Figure 1. As you know, this display is capable of showing all 10 decimal digits (and the other six hex digits) by lighting up two or more segments.

I'll give you my solution in a moment. But first, it's time for one of my famous stories of my adventures in the land of digital logic.

Jack in Logic-land
Ever since Fairchild came out with those cheap logic parts circa 1966, I wanted to build my own computer. I had the glimmerings of a design worked out. It was going to use a serial accumulator, one bit wide, like my old friend, the Royal-McBee LGP-30, and it would have dynamic shift register memory, with all the bits whirling around like an electronic disk. My real hangup was not the logic but the displays.

You see, before then, logic chips weren't the only things whose costs were dear; so were digital displays. Some of you old-timers may remember Nixie tubes; neon-filled displays in which the ten digits were represented by ten electrodes of bent wire. Every now and then you'll see an old movie with Nixie tubes counting down the seconds before The End Of The World. Nixie tubes were widely used in scientific instruments, but they were never cheap. The prospect of using, say, 12 of them on a grad student's salary didn't exactly thrill me.

Seven-segment displays were already around; they were available for the same kinds of military and space applications as the $500 logic gates. But they also had similar prices.

I decided to build my own seven-segment displays, using incandescent light bulbs. I had a bunch of fairly cheap bulbs, grain-of-wheat bulbs with pigtails rather than sockets. I figured I could wire up enough of them to get at least a few digits.

I came up with what I thought was a rather clever design. The idea was to encapsulate each light bulb into its own compartment, so it could only light a single segment. The design is shown in Figure 2.

Figure 1: Seven-segment display Figure 2: The homebrew display

The idea was that each square compartment would be isolated from the others and the light would shine through the mask, so each bulb illuminated one segment. Neat idea, eh?

Well, the idea was neater in concept than execution. My first model used boxes made of white cardboard stock and a mask of similar material. The lights shone through the cardboard, flooding both the adjacent boxes and the mask itself. Even so, I saw enough to convince me that the idea was sound. I only needed more opaque materials.

I knew I was going to need more than one digit. I wanted at least 10 per register, and hopefully more than one register. My mind raced ahead to count the number of individual little boxes I was going to need. It was a big number.

At some point, I realized that what I needed was an egg-crate sort of structure. My eye roved towards my refrigerator, and the mini-cube ice trays in there. Aha! That's what I'd use for my displays.

I spent some time cutting up ice trays, much to my wife's displeasure. Yes, I know, the ice trays were translucent plastic, but I'd cross that bridge later. I started drilling holes for the light bulbs, and making the preliminary attachments.

That's when I realized the awful truth. The ice trays were made of Teflon. Easy to get ice out; not easy to paint, or glue together. Nothing, but nothing, would stick to them. Bah!

In retrospect, I know I should have trashed the ice tray idea and looked for other egg-crate structures. But I didn't. Instead, I started reading chemistry books describing chemicals that would bond things to Teflon. Bottom line: I never produced production-quality displays. In the end, technology overtook me, and cheaper, LED-based seven-segment displays began to appear.

Around 1969, I came across another idea. Hewlett-Packard came out with their HP-9100A desk calculator—the first of their products using reverse polish notation and the grandaddy of their stellar line of handheld calculators. Instead of LED displays, the 9100A had a CRT, with the registers shown in three rows of (I believe) 10 digits each. Each character was drawn cursively, with the electron beam blanked as needed to light or not light each segment.

Hmm, sez I. I have a scope, too. If I use the same approach, I can draw as many characters as my scope has bandwidth.

Think about it. To draw one seven-segment digit, you need only drive the x- and y-axes of the scope with the right waveforms, as shown in Figure 3.

Figure 3: The driving waveforms Figure 4: Inputs to integrators

One can generate slopes like the ones on these curves by integrating constant voltages. Differentiating the curves in Figure 3 gives the next set of curves, as shown in Figure 4. These I could generate by adding waveforms from a scale-of-eight counter.

Figure 5: Drive to integrators

Want to see the logic? I hadn't planned to go this deep, but heck, I might as well show you the truth table and Karnaugh maps. The truth table is in Table 1, the Karnaugh maps in Figure 5, and here are the logic equations:


Table 1: Truth table—Cursive display

State (ABC) x+ x- y+ y+
Decimal Binary
0 000 1
1 001 1
2 010 1
3 011 1
4 100 1
5 101 1
6 110 1
7 111 1

The beauty of the cursive seven-segment approach is that once you have a circuit to generate a single digit, you can always generate more without much extra logic. Just add a staircase voltage to move the x-coordinate by a little more than the width of a single digit. Stack displays with a staircase on y as well.

I built a circuit to supply the oscillator, three-bit counter, and the logic of Equation 1. Then I set out to sum and integrate the voltages. For my first try, I hoped to get by with passive resistor capacitor (RC) summers and integrators. I actually did get the long-sought seven-segment pattern. It looked like this:

What went wrong? Simply that my scope didn't have enough gain in the x-direction. Most oscilloscopes are designed to display voltages in the y-direction, and they have plenty of gain there. But not in x. By using a very conservative time constant in my RC integrator, I had reduced the gain too far to be usable.

No problem, I reasoned. I'll just shorten the time constant to get more drive voltage.

This time, the figure looked something like this:

Bah! Now the time constant was too short. Where the voltages were supposed to be constant over a given segment time, they were showing exponential decay.

It wasn't long before I realized that I was going to need op amps with lots of gain, instead of simple passive integrators. At that time, op amps were available, made by—wait for it—Fairchild. After all, they invented the integrated circuit op amp, with the µA-709. I could have and should have bought some of those and gotten my display working. Or I could have simply added some transistor gain.

Instead, I did something completely inexplicable. I decided to make the problem harder by introducing this completely unnecessary constraint: any active circuits should be made up of those RTL gates, of which I had a ton. I suppose the reason was so I wouldn't need another power supply.

Was this a bad decision? You bet. The transistors in the RTL gates, while still transistors, were optimized to be digital switches, not linear amplifiers. They could be made to work in linear mode, but not very well and only with a lot of tinkering. When last seen, our hero was bending over his workbench, soldering iron in one hand and scope probe in the other, trying to make a logic gate work like an op amp. Bad idea. If there are any lessons to be learned, they are:

  • beware of gratuitous constraints—especially your own
  • doing things on the cheap is always nice, but don't get carried away

The seven-segment decoder
Regular readers will recall that I challenged you to develop the logic equations for a binary-to-seven-segment decoder. At this writing, no one has submitted their solutions, so I guess I'd better show you my own. The truth table is shown in Table 2.

Table 2: Seven-segment decoder

A B C D a b c d e f g
0 0 0 0 1 1 1 1 1 1 0
0 0 0 1 0 1 1 0 0 0 0
0 0 1 0 1 1 0 1 1 0 1
0 0 1 1 1 1 1 1 0 0 1
0 1 0 0 0 1 1 0 0 1 1
0 1 0 1 1 0 1 1 0 1 1
0 1 1 0 1 0 1 1 1 1 1
0 1 1 1 1 1 1 0 0 0 0
1 0 0 0 1 1 1 1 1 1 1
1 0 0 1 1 1 1 1 0 1 1

Figure 6A-G: Karnaugh maps for seven segments

My Karnaugh maps are shown in Figures 6A through 6G. Notice the heavy use of don't-care states to minimize the equations. Any time we can let the selected regions overlap the don't-care regions, we simplify the equations. None of the equations are trivially simple; when the Arabs invented the symbols for our decimal digits, they didn't plan ahead to computer implementations, so we have to use the symbols we're given. Even so, some patterns emerge, and we do spot certain terms, such as , which recur in multiple segments. My best attempt at implementing the equations goes like this:


How does that compare with your own solutions?

Jack Crenshaw is a senior software engineer at Spectrum-Astro and the author of Math Toolkit for Real-Time Programming , from CMP Books. He holds a PhD in physics from Auburn University. E-mail him at .

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.