LED · Volume 5
Decoders & Seven-Segment Drive
How two ranks of diode logic turn a counter's four-bit binary count into a lit numeral, statically driven, one segment at a time
By the time a signal reaches this volume the hard counting is already done. A counter (Vol 4) holds the current count as a four-bit binary number on four flip-flop outputs — Q0, Q1, Q2, Q3 — and, because each flip-flop is a cross-coupled pair, it hands you the inverses /Q0, /Q1, /Q2, /Q3 for free on the opposite collectors. That is the whole input to this volume: eight wires per digit carrying a count and its complement. The job of the decoder is to turn that binary number into a lit numeral on a seven-segment LED — and the KABtronics clock does it the way it does everything else, with no chips: two ranks of plain diode logic in series, the first selecting which numeral, the second lighting the segments that draw it.1
This is the same job a 1970s BCD-to-seven-segment decoder chip (a 7447, a 4511) does in one package — the same binary-in, segments-out function (Vol 1, §1.7). Here it is spread across two visible diode matrices you can probe with a meter, and that visibility is the entire point: you can put a finger on the one diode that makes the “2” light its top bar.
5.1 The decode, in two stages
The decode is a strict two-step pipeline, and it helps to name the wires between the steps before drawing either matrix:
counter (Q0–Q3 + /Q0–/Q3) → one-of-N decoder → N “select” lines (exactly one active) → seven-segment decoder → seven “segment” lines (a–g) → LED digit.
- The one-of-N decoder reads the binary count and its inverse and lights exactly one of N output lines — call them select lines. For a decade (÷10) counter there are ten of them, one per count 0–9; for the ÷6 stages there are six; for the ÷12 hours stage, twelve. Only one is ever active at a time, because only one count value is present at a time.
- The seven-segment decoder takes that single active select line and, through a second diode field, drives the segments (a–g) that draw the corresponding numeral. Selecting “2” must light five segments; selecting “1” must light only two.
The two stages are independent diode matrices in series. The first answers which number; the second answers which segments make that number look right. Keeping them separate is what lets the same seven-segment decoder serve every digit while each counter type (÷10, ÷6, ÷12) gets its own appropriately-sized first stage.
5.2 The one-of-N decoder — a field of diode AND gates
The first rank is the more abstract of the two, so it rewards a slow read. A four-bit counter has sixteen possible states, but a decade counter only ever visits ten of them (0–9), and at any instant it is in exactly one. The one-of-ten decoder’s task is to take the four-wire binary representation of that state and assert a single dedicated line for it — to demultiplex the count from a packed binary code onto ten one-hot wires.
The manual describes the mechanism plainly: “These diodes form a four-input AND gate that decodes a counter value and pulls low a line for each count.”1 Each of the ten output lines is its own little AND gate, and the trick is which four signals it ANDs.
5.2.1 Why both Q and /Q are needed
A binary number is only fully specified when you know which bits are 0 as well as
which are 1. Count “2” is binary 0010: Q1 high, and Q0, Q2, Q3 all low. To detect
“2” uniquely you must test all four conditions — Q1 high and Q0 low and Q2 low
and Q3 low — because testing “Q1 high” alone would also fire on 3 (0011), 6
(0110), 7 (0111), and every other count with that bit set. The “low” conditions are
read off the inverse outputs: Q0 low is the same as /Q0 high. So each line’s AND gate
takes its four inputs from the right combination of the eight rails — for a given
count, the four rails (one per bit, Q or /Q) that are all simultaneously high.
The table makes the pattern concrete. For each count, list the four rails the AND gate watches (the ones that are high for that value):
Table 1 — watches (the ones that are high for that value)
| Count | Q3 Q2 Q1 Q0 | The four rails ANDed (all high for this count) |
|---|---|---|
| 0 | 0 0 0 0 | /Q3 · /Q2 · /Q1 · /Q0 |
| 1 | 0 0 0 1 | /Q3 · /Q2 · /Q1 · Q0 |
| 2 | 0 0 1 0 | /Q3 · /Q2 · Q1 · /Q0 |
| 3 | 0 0 1 1 | /Q3 · /Q2 · Q1 · Q0 |
| 4 | 0 1 0 0 | /Q3 · Q2 · /Q1 · /Q0 |
| 5 | 0 1 0 1 | /Q3 · Q2 · /Q1 · Q0 |
| 6 | 0 1 1 0 | /Q3 · Q2 · Q1 · /Q0 |
| 7 | 0 1 1 1 | /Q3 · Q2 · Q1 · Q0 |
| 8 | 1 0 0 0 | Q3 · /Q2 · /Q1 · /Q0 |
| 9 | 1 0 0 1 | Q3 · /Q2 · /Q1 · Q0 |
Read down the right-hand column and you can see the matrix: every line uses exactly four of the eight rails, and no two lines use the same set, so for any counter value precisely one AND gate has all four of its inputs high and fires.
5.2.2 How the diode AND gate pulls a line low
The physical realization is the diode AND gate of Vol 3, turned upside down for active-low output. Each select line sits at a pull-up resistor to the supply, so it wants to be high. Hanging off it are the four diodes of its AND gate, each pointing from the select line toward one of the eight rails. If any one of those four rails is low, its diode conducts and clamps the select line down near that rail — the line is held low (or rather, the manual’s convention is that an unselected line is dragged about, and the active line is the one that goes/stays low). Only when all four of a line’s diodes face high rails does no diode conduct, and that line is free to follow its pull-up.
The manual states the result rather than the rail-by-rail bookkeeping, and we follow it: each four-input diode AND gate “pulls low a line for each count,” so that across the whole matrix exactly one select line is the active (low) one for the present count, and the other nine are not.1 The precise diode count per gate is the four implied by a four-input AND, but the manual does not tabulate the exact total number of diodes in the matrix, and we do not invent one (§5.7).
5.2.3 The ÷6 and ÷12 variants — same idea, fewer (or more) lines
Not every digit counts to ten. The tens-of-seconds and tens-of-minutes positions are ÷6 counters (0–5), and hours is a ÷12 counter. The decoder scales with them without changing in kind:
- A ÷6 counter feeds a one-of-six decoder — six AND-gate lines for counts 0–5, built from the same Q/notQ rails. Counts 6–9 simply have no line, because the counter never reaches them.
- The ÷12 hours counter feeds a one-of-twelve decode. The manual’s block diagram labels the hours path as a 0–11 decode feeding a downstream segment decode, which is the same one-hot idea widened to twelve lines (§5.5).
In every case the principle is identical: a diode AND gate per valid count, reading the correct combination of the counter outputs and their inverses, asserting one line.
5.3 The seven-segment decoder — the second diode matrix
The second rank is easier to picture because its output is something you can see. A seven-segment digit has seven bars, labelled a (top) through g (centre), in the standard arrangement:
aaa
f b
f b
ggg
e c
e c
ddd
The seven-segment decoder is a second diode matrix whose inputs are the N select lines from the first stage and whose outputs are the seven segment lines a–g. On each select line, diodes connect out to exactly the segments that draw that numeral. When a select line goes active, it reaches through its diodes and drives those segments — and only those — toward their lit state. Selecting “2” reaches segments a, b, g, e, d; selecting “4” reaches f, g, b, c (the manual illustrates both as “Displaying 2” and “Displaying 4”).1
5.3.1 The full numeral-to-segment map
This is the heart of the volume: which segments each numeral lights. The map is the universal seven-segment convention, and the KABtronics decoder wires its diodes to match it.
Table 2 — 5.3.1 The full numeral-to-segment map
| Numeral | a | b | c | d | e | f | g | Segments lit |
|---|---|---|---|---|---|---|---|---|
| 0 | ● | ● | ● | ● | ● | ● | · | a b c d e f |
| 1 | · | ● | ● | · | · | · | · | b c |
| 2 | ● | ● | · | ● | ● | · | ● | a b g e d |
| 3 | ● | ● | ● | ● | · | · | ● | a b c d g |
| 4 | · | ● | ● | · | · | ● | ● | f g b c |
| 5 | ● | · | ● | ● | · | ● | ● | a f g c d |
| 6 | ● | · | ● | ● | ● | ● | ● | a f g e d c |
| 7 | ● | ● | ● | · | · | · | · | a b c |
| 8 | ● | ● | ● | ● | ● | ● | ● | a b c d e f g |
| 9 | ● | ● | ● | ● | · | ● | ● | a b c d f g |
(● = segment lit; · = segment dark.) Note “8” lights all seven — it is the all-diodes row — while “1” lights only two, and that two-segment minimum becomes important for the hours tens digit in §5.5. The exact number of diodes in the segment matrix is therefore the sum of the lit cells in this table for whatever numerals a given digit can show, but again the manual does not print a diode count and neither do we (§5.7).
5.3.2 Worked example — “2”
The counter for that digit reaches binary 0010. In the one-of-ten decoder, the “2” line
is the AND of /Q3 · /Q2 · Q1 · /Q0 — all four high — so the “2” select line goes active
while the other nine do not. That single line enters the seven-segment matrix and, through
the five diodes wired on it, drives segments a, b, g, e, d. The result is the familiar
“2” glyph: top bar, upper-right, middle, lower-left, bottom — a stroke that snakes from
top-right down to bottom-left. Segments c and f are left dark.
5.3.3 Worked example — “4”
Now the counter holds 0100. The one-of-ten decoder fires the “4” line (the AND of
/Q3 · Q2 · /Q1 · /Q0). It enters the segment matrix and drives f, g, b, c — upper-left,
middle, upper-right, lower-right — drawing the “4” as the little flag-and-stem shape with
no top, bottom, or lower-left bar. Five segments dark, two of the four lit ones (b, c)
shared with the “1” of §5.3.1; that overlap is just two rows of the matrix happening to
share columns, nothing more.
5.4 How a segment actually lights — tying it to the display
It is worth being concrete about the electricity, because “the decoder lights the segment” hides the mechanism. Each LED segment in the display is wired to the positive supply through its own 680 Ω current-limiting resistor (Vol 2 — the display is statically driven, every lit segment continuously on, never scanned). Left alone, a segment’s drive line sits pulled up and the LED is dark, because there is no complete path for current to flow.
The seven-segment decoder completes that path by pulling the chosen segment lines low. When a select line is active, current flows from it, through the decode diode for that segment, and out the segment line — and from the segment’s point of view, the far end of its 680 Ω-fed LED has just been connected toward ground. Current now runs from the supply, through the 680 Ω resistor, through the LED segment, through the decode diode, and the segment lights. The resistor sets the segment current (and therefore the brightness); the diode matrix decides which segments get that low-side connection and which stay pulled up and dark.
So the decode is fundamentally active-low: high rails and pull-ups are the resting state, and “selected” means “pulled low.” The one-of-N stage pulls one select line low; that low select line, through the segment matrix, pulls the right handful of segment lines low; and each of those segments lights through its 680 Ω resistor. The whole chain is static — once the count settles, the lit segments stay on continuously until the count changes, with no multiplexing or refresh anywhere in the clock.
5.5 The hours digit — a partial display and a 0–11 decode
Hours is the one place the tidy “ten lines, full numeral” picture bends, for two reasons, and the manual’s own block diagram flags both.
The counter is a ÷12. The hours position counts 1–12 (or, in the decode’s terms, runs through twelve states), so its first-rank decoder is a 0–11 decode — twelve select lines rather than ten — exactly as the block diagram labels it. The diagram then shows those lines feeding what it calls a “9-segment decode” for the hours; functionally this is the same second-rank segment matrix, sized for the hours’ two-digit display.1
The tens-of-hours digit is partial. A twelve-hour clock’s tens-of-hours position only ever shows blank (for hours 1–9) or “1” (for hours 10, 11, 12). It never needs a 2, a 5, an 8 — never any numeral but “1.” And from the segment table (§5.3.1) a “1” lights only segments b and c. So that digit does not get a full seven-segment decoder at all; it needs only the two segments for a “1,” b and c, driven on the counts where the tens digit should be “1” and left blank otherwise. It is a deliberately reduced / partial display — the most economical decode in the clock, because the numeral set it must draw has exactly one member.
The units-of-hours digit, by contrast, shows the full 0–9 range like any other digit and gets the ordinary seven-segment decode. The manual labels the combined hours decode “9- segment” in its block diagram; we report that label as given and read it functionally as “the hours’ segment-decode stage” rather than asserting an exact diode-or-segment count the manual does not enumerate (§5.7).
5.6 When a decoder goes wrong — a pointer forward
A decoder fault does not always stay politely downstream, and the distinction matters enough to a troubleshooter that it belongs here even though the full method lives in Vol 9.
- A seven-segment-decode fault corrupts only the glyph. A missing or shorted diode in the second matrix lights the wrong segments for some numeral — an “8” that’s missing its tail, a “6” that looks like a “5” — but the count underneath is still correct and still advancing. The error is purely cosmetic, confined to one displayed digit, and often confined to one or two of the ten numerals (the ones whose row touches the bad diode).
- A one-of-N decode fault can feed back into the counter. Because the first-rank decode lines are tied to the same counter-output rails the flip-flops drive — and in a decade counter the steering/reset logic (Vol 4) and the decode can share nodes — a fault in the decode region can load or disturb a counter output and make the counter skip states: it miscounts, not just mis-displays. A digit that jumps 0,1,2,4 (never showing 3) is miscounting; a digit that shows a garbled “3” but keeps proper time is mis-decoding.
That symptom split — miscounting vs. wrong glyph — is the single most useful first question when a digit misbehaves, and it is exactly where Vol 9’s “use your brain” troubleshooting method starts. The decode is the natural suspect for the second symptom and a possible accomplice in the first.
5.7 What the manual does not specify
In keeping with the rest of this series, two things are deliberately not asserted here because the KABtronics manual does not state them, and inventing them would be worse than leaving them open:
- The exact diode count in either matrix. The one-of-N matrix is “four-input AND gates, one per count” and the segment matrix is “one diode per lit-segment intersection,” so the totals are derivable from the count tables above — but the manual prints no diode tally, so we give none as fact.
- The precise common-anode vs. common-cathode wiring of the LED digits and the exact
polarity of every decode node. We describe the behaviour functionally — each segment
sits at +supply through a 680 Ω resistor, and the decoder pulls the selected lines
low to light them — which is what the manual supports, without claiming a specific
anode/cathode topology it does not spell out. Vol 2 covers the display side; the full
schematic (held in
02-inputs/LED_Transistor_Clock/Schematics/) is the authority on the literal node-by-node wiring for anyone tracing it.
5.8 Where this sits in the chain
This volume is the middle link of the per-digit chain. Upstream, Vol 4 builds the counters whose Q0–Q3 and inverses are this volume’s only input, and explains the ÷10/÷6/÷12 steering that decides how many counts — and therefore how many select lines — each digit needs. Downstream, Vol 2 is the LED display the segment lines drive, with the 680 Ω resistors and the static (un-scanned) drive that §5.4 leans on. The diode AND/OR gates the decoder is built from are the Vol 3 building blocks. And when a built board shows the wrong digit, Vol 9 is the troubleshooting method that uses the miscount-vs-misglyph distinction of §5.6 to localize the fault. Read together: counter → decode → display.
5.9 References (Vol 5)
- KABtronics Transistor Wall Clock Kit — assembly manual (theory of operation, circuit
description) and 15-page schematic, in
02-inputs/LED_Transistor_Clock/. Vendor: http://www.transistorclock.com. - Cross-references: Vol 2 (the LED display and its 680 Ω static drive), Vol 3 (the diode AND/OR gate building blocks), Vol 4 (the counters and the ÷10/÷6/÷12 divide that feeds this decode), and Vol 9 (troubleshooting — the miscount-vs-wrong-glyph method).
Footnotes
-
Transistor Clock Assembly Manual, KABtronics (transistorclock.com), document version 1.4 for PC board version 4, copyright 2011 — “Theory of Operation” and “Circuit Description” sections. Source of the diode-decode description (“These diodes form a four- input AND gate that decodes a counter value and pulls low a line for each count”), the “Displaying 2” / “Displaying 4” segment illustrations, and the block-diagram labels for the hours path (a 0–11 decode feeding a “9-segment decode,” with the tens-of-hours digit reduced to the “1”-only segments b and c). The manual does not tabulate the exact diode count in either matrix or spell out the literal common-anode/-cathode wiring; those are described functionally here and left to the schematic. Full manual + 15-page schematic in
02-inputs/LED_Transistor_Clock/(trans-clock-manual.pdf,Schematics/). ↩ ↩2 ↩3 ↩4 ↩5