One digit, many codes.
Systems that speak different codes need converters between them. Meet BCD, Gray and excess-3, and the chip that turns BCD into a lit digit.
Codes for a digit
| Decimal | BCD | Gray | Excess-3 |
|---|---|---|---|
| 0 | 0000 | 0000 | 0011 |
| 1 | 0001 | 0001 | 0100 |
| 2 | 0010 | 0011 | 0101 |
| 3 | 0011 | 0010 | 0110 |
| 4 | 0100 | 0110 | 0111 |
| 5 | 0101 | 0111 | 1000 |
| 6 | 0110 | 0101 | 1001 |
| 7 | 0111 | 0100 | 1010 |
| 8 | 1000 | 1100 | 1011 |
| 9 | 1001 | 1101 | 1100 |
BCD
Binary coded decimal writes each decimal digit in four bits with the weights 8 4 2 1. Only 0000 to 1001 are used; 1010 to 1111 never appear, which a designer can use as don't cares in a K-map.
Gray code
Only one bit changes between neighbouring numbers: a minimum change code.
Used for shaft and position encoders, where several bits changing at once would give false readings.
The rows and columns of a K-map are in Gray order for the same reason.
The seven segment display
Seven LEDs (a to g) shaped as an 8, plus a decimal point. In a common anode display all anodes are joined to pin 3 and pin 8, which go to +5 V; a segment lights when its own pin is pulled LOW. Each segment needs a series resistor (180 ohm) to limit the current, or it burns.
The 7447 driver
The 7447 has its own shapes for 6 and 9: it draws 6 without the top bar (segments c, d, e, f, g, so it looks like a small b) and 9 without the bottom bar (a, b, c, f, g). This is how the real chip is made, so the trainer in the lab room shows the same. Later chips such as the 74LS247 add the bars (a tailed 6 and 9). Try 6 and 9 below.
| a | b | c | d | e | f | g |
|---|---|---|---|---|---|---|
| 0 | 1 | 0 | 0 | 1 | 0 | 0 |
Input 5 (0101). The 7447 pulls a segment pin LOW (0) to light it; the common anode sits at +5 V, so current flows through the segment and its resistor into the pin.
Hold the chip with its notch on the left. Pin 1 is at the bottom left, the pins count up to the right, then continue along the top from right to left. Most 14 pin chips have VCC on pin 14 and GND on pin 7, but not all: check every new chip.
Gray from XOR gates
From the K-maps: W = A, X = A ⊕ B, Y = B ⊕ C, Z = C ⊕ D. Back from Gray to binary each bit is the XOR of the binary bit above it and the Gray bit: W = A, X = W ⊕ B, Y = X ⊕ C, Z = Y ⊕ D.
Check yourself
Q1Which pins of the common anode display go to +5 V?
Pin 3 and pin 8 (the common anode). Either one is enough; they are joined inside.
Q2Why is a 180 ohm resistor needed in every segment line?
To limit the LED current; without it the segment (or the driver) burns.
Q3What Gray code is 7?
0100.
Q4On the 7447 is a lit segment a 0 or a 1 at its output pin?
A 0: the outputs are active LOW.