Skip to main content

Subsection 10.3.3 Part 3: How the Display Is Actually Built

You already know the segment names and the bit order they map to (Figure 10.1.22), because you wrote a digit’s byte with them yesterday. Now we’ll look at the wiring behind them: how the 34 LEDs of the display are reached with the 14 backpack pins, and why the display needs a chip of its own. We’ll get to communicating with the chip via the 2 I2C wires later today.
The 34 LEDs are wired up in a grid which you can see in Figure 10.3.5 (from the HT16K33 datasheet). It is a common cathode arrangement: within one digit, all eight LEDs have their cathodes tied together and brought out on a single pin (the ones marked (COM), for common) while across digits, all four a anodes are tied together, all four b anodes are tied together, and so on.
Figure 10.3.5. The internal wiring of the four-digit display, from its datasheet. Every segment of the display is an LED. Reading down: the eight LEDs of each digit share one cathode, brought out on the pin marked (COM) above that digit, pins 14, 11, 10 and 6, with pin 7 serving the colon’s two LEDs. Reading across: all four a anodes are connected together and brought out on one pin, and likewise for b through g and DP (the eight pins along the bottom, 13, 9, 4, 2, 1, 12, 5 and 3), with pin 8 for the colon. Five cathode pins and nine anode pins is 14 wires for 34 LEDs. The datasheet prints the segments as capitals; we write them lowercase, as Figure 10.1.22 does.
We’ll work out what that wiring makes possible and what it rules out. To light the a segment of digit 2, drive the shared a anode high and pull digit 2’s common cathode low: current has a path through exactly one LED, because that is the only place where an energized anode meets an energized cathode. To light a of digit 2 and b of digit 3 at the same time, you would have to energize both anodes and both cathodes, which also lights b of digit 2 and a of digit 3. A grid cannot light an arbitrary set of segments at one instant; it can light one digit at a time. To show four digits, the display shows them in sequence, sweeping through them fast enough that the eye does not notice.
Everything the backpack does (sweeping the four digits, holding each one on for its share of the time, keeping the display lit while your program does something else) is that grid, driven continuously.
We can watch that happen. The display in front of you looks steady, but at every instant most of it is dark, and there are two ways to see it. Wave it. Pick the breadboard up and move the lit display briskly from side to side, and watch what the trail does: a light that is genuinely on all the time smears into a continuous band, and one that is being switched leaves separate images with gaps between them. Or film it. Put your phone’s camera into its slow-motion mode and point it at the display, then play the clip back and step through it. A camera exposing for a short enough slice of time catches the display part-way through a sweep rather than averaged over one.
Either way, what you are seeing is the sweep, and, as the reading put it, that job never stops. Every other thing you might want the processor to do would have to be fitted around a refresh loop. This is why the display is wired to a backpack: the HT16K33 chip on the backpack does the multiplexing and the decoding, and it continuously sweeps through the four digits to make them all appear lit up at the same time. The chip also talks to the processor over I2C.
Figure 10.3.6 shows the HT16K33’s block diagram (from the chip’s datasheet). The I2C interface is on the left; the display RAM in the middle holds which LEDs are on; the row and common drivers on the right are eight COM outputs (of which the display is only wired to five) and sixteen ROW outputs (of which the display uses eight); and the internal RC (resistor-capacitor) oscillator with the timing generator is what runs the sweep. That oscillator is off when the chip powers up, and so the first thing our driver has to do is turn it on.
Figure 10.3.6. The HT16K33’s block diagram, from its datasheet. SDA and SCL enter the I2C controller on the left, which is the only way your program reaches it. The display RAM is where the individual bit patterns are stored for the segments you are currently lighting up. Each digit is stored as a 16-bit number (2 8-bit numbers); in the case of the 7-segment display we only use the first of these two bytes for each digit. We still need to send both bytes though (so we send a ’0’ after each ’real’ piece of data). The controller can also control dot-matrix displays, keypads and more. That’s why it has more capabilities than we need and in particular more storage in the display memory than we need. The common-scan and row-driver outputs on the right are the pins that go to the display’s grid. The internal RC (resistor-capacitor) oscillator and timing generator sweep that grid from the RAM, continuously and without any further instruction. The key-scan and key-data blocks belong to the chip’s other features, reading a keypad matrix, which we do not use. The annotations name four groups. In blue on the left, the two I2C pins. In magenta, the display RAM, the data registers, two bytes of eight bits for each COM line. In orange, the control registers, which are what the command table configures: display or keypad, digits or LED matrix, brightness and blinking. And in dark red on the right, the pins our display actually uses: five COM outputs, four for the digits and one for the colon, and eight ROW outputs, seven digit segments and the decimal point.