Lesson 3. A counter in a package: 74HC390 and a stopwatch
In picturesAfter this lesson the library has the 74HC86 (four XORs) and the 74HC390 — two decade counters in one package — and the canvas has a stopwatch: a start/stop switch, a Reset button and two digits, 00–99.
3.1. The idea: ÷2 and ÷5 make ÷10
The decade counter in the 74HC390 is cut into two parts:
- the ÷2 stage — one flip-flop (
Q0), clockCP0; - the ÷5 stage — three flip-flops (
Q1 Q2 Q3), clockCP1, counting 0, 1, 2, 3, 4, 0.
Connect Q0 to CP1 and you get 0–9 in binary (Q3 Q2 Q1 Q0). The parts are separate on purpose: the same chip can make ÷2, ÷5 or ÷10 depending on how you connect it.
3.2. The idea: clocking on the fall
The 74HC390 flip-flops act when the clock falls from 1 to 0 (in the datasheet CP0 and CP1 have a bar). That is handy for a chain: the top bit Q3 falls exactly when the counter goes 9 → 0 — and this fall clocks the next counter, the tens. Inside we make the fall from an edge: a 74HC04 inverts the clock, and then it is an edge for the 74HC74.
In fact everything inside the 74HC390 is chips from lessons 1–2: two 74HC74 per counter, one 74HC04 for six inversions, 74HC02, 74HC08 and the new 74HC86 (four XORs) for the ÷5 stage. We build from packages, as on a real board.
3.3. The idea: reset on a one
The 74HC74 reset acted on a zero; the 74HC390 MR acts on a one. That happens: every chip follows its own datasheet. So here the reset button is connected directly, without an inverter.
3.4. Building
The same project as in lesson 2: the library has the gates, 74HC00–74HC32 and 74HC74.
Step 1. Chip 74HC86 — 4 × exclusive OR (XOR)
Package pins from the datasheet: 1 1A, 2 1B, 3 1Y, 4 2A, 5 2B, 6 2Y, 8 3Y, 9 3A, 10 3B, 11 4Y, 12 4A, 13 4B; 7 — GND, 14 — VCC. Like the 74HC00, only with four XORs inside: the output is 1 when the inputs differ. It is needed inside the 74HC390.
| Part | Pin | Label |
|---|---|---|
| Input port | output | 1A |
| Input port | output | 1B |
| Input port | output | 2A |
| Input port | output | 2B |
| Input port | output | 3A |
| Input port | output | 3B |
| Input port | output | 4A |
| Input port | output | 4B |
| Output port | input | 1Y |
| Output port | input | 2Y |
| Output port | input | 3Y |
| Output port | input | 4Y |
| XOR | I0 I1 O0 | 1A 1B 1Y |
| XOR | I0 I1 O0 | 2A 2B 2Y |
| XOR | I0 I1 O0 | 3A 3B 3Y |
| XOR | I0 I1 O0 | 4A 4B 4Y |
Ctrl+G → name 74HC86. Legs: inputs 1A, 1B, 2A, 2B, 3A, 3B, 4A, 4B; outputs 1Y, 2Y, 3Y, 4Y.
Step 2. Chip 74HC390 — 2 × decade counter (÷2 and ÷5)
Package pins from the datasheet: 1 1CP0, 2 1MR, 3 1Q0, 4 1CP1, 5 1Q1, 6 1Q2, 7 1Q3, 9 2Q3, 10 2Q2, 11 2Q1, 12 2CP1, 13 2Q0, 14 2MR, 15 2CP0; 8 — GND, 16 — VCC. CP0, CP1 — clock on the fall (in the datasheet they have a bar), MR — reset, active 1. Inside each counter: a ÷2 stage (Q0) and a ÷5 stage (Q1 Q2 Q3, counting 0–4). Everything inside is chips from lessons 1–2: flip-flops — 74HC74 (two per counter); six inverters — one 74HC04 (a falling clock = a rising inverted clock, reset 1 → 0 for the 74HC74); NOR — 74HC02, AND — 74HC08, exclusive OR — 74HC86 (one gate per counter, the free ones to GND).
| Part | Pin | Label |
|---|---|---|
| Input port | output | 1CP0 |
| Input port | output | 1MR |
| Input port | output | 1CP1 |
| Input port | output | 2CP1 |
| Input port | output | 2MR |
| Input port | output | 2CP0 |
| Output port | input | 1Q0 |
| Output port | input | 1Q1 |
| Output port | input | 1Q2 |
| Output port | input | 1Q3 |
| Output port | input | 2Q3 |
| Output port | input | 2Q2 |
| Output port | input | 2Q1 |
| Output port | input | 2Q0 |
| 74HC04 | 1A 1Y 2A 2Y 3A 3Y 4Y 4A 5Y 5A 6Y 6A | 1CP0 1c0 1CP1 1c1 1MR 1nMR 2c0 2CP0 2c1 2CP1 2nMR 2MR |
| 74HC02 | 1Y 1A 1B 2Y 2A 2B 3A 3B 4A 4B | 1d1 1Q1 1Q3 2d1 2Q1 2Q3 GND GND GND GND |
| 74HC08 | 1A 1B 1Y 2A 2B 2Y 3A 3B 4A 4B | 1Q1 1Q2 1d3 2Q1 2Q2 2d3 GND GND GND GND |
| 74HC86 | 1A 1B 1Y 2A 2B 2Y 3A 3B 4A 4B | 1Q1 1Q2 1d2 2Q1 2Q2 2d2 GND GND GND GND |
| 74HC74 | 1RD 1D 1CP 1SD 1Q 1QN 2QN 2Q 2SD 2CP 2D 2RD | 1nMR 1Q0N 1c0 VCC 1Q0 1Q0N 1Q1N 1Q1 VCC 1c1 1d1 1nMR |
| 74HC74 | 1RD 1D 1CP 1SD 1Q 1QN 2QN 2Q 2SD 2CP 2D 2RD | 1nMR 1d2 1c1 VCC 1Q2 1Q2N 1Q3N 1Q3 VCC 1c1 1d3 1nMR |
| 74HC74 | 1RD 1D 1CP 1SD 1Q 1QN 2QN 2Q 2SD 2CP 2D 2RD | 2nMR 2Q0N 2c0 VCC 2Q0 2Q0N 2Q1N 2Q1 VCC 2c1 2d1 2nMR |
| 74HC74 | 1RD 1D 1CP 1SD 1Q 1QN 2QN 2Q 2SD 2CP 2D 2RD | 2nMR 2d2 2c1 VCC 2Q2 2Q2N 2Q3N 2Q3 VCC 2c1 2d3 2nMR |
Ctrl+G → name 74HC390. Legs: inputs 1CP0, 1MR, 1CP1, 2CP1, 2MR, 2CP0; outputs 1Q0, 1Q1, 1Q2, 1Q3, 2Q3, 2Q2, 2Q1, 2Q0.
Step 3. Clock, switch and button
Clock — 1Hz: the stopwatch counts seconds. Switch RUN — start/stop, the Reset button is RST.
| Part | Pin | Label |
|---|---|---|
| Clock | output | CLK |
| Input (switch) | output | RUN |
| Button «Reset» | output | RST |
Step 4. Start / stop — 74HC08
TICK = CLK AND RUN: while RUN = 0, the clock does not reach the counter.
| Part | Pin | Label |
|---|---|---|
| 74HC08 | 1A 1B 1Y 2A 2B 3A 3B 4A 4B | CLK RUN TICK GND GND GND GND GND GND |
Step 5. Units and tens — one 74HC390
The first counter is the units: the clock goes to 1CP0 (÷2), its 1Q0 to 1CP1 (÷5): together 0–9. The second is the tens: its clock is the units 1Q3, which falls from 1 to 0 exactly when the units go 9 → 0. MR of both is the reset button, directly: the 74HC390 reset acts on a one.
| Part | Pin | Label |
|---|---|---|
| 74HC390 | 1CP0 1MR 1Q0 1CP1 1Q1 1Q2 1Q3 2Q3 2Q2 2Q1 2CP1 2Q0 2MR 2CP0 | TICK RST U0 U0 U1 U2 U3 T3 T2 T1 T0 T0 RST U3 |
Step 6. Display
Two Display (bus) ⚙: width 4, DEC, buses T (tens) and U (units). The TICK lamp blinks with every cycle.
| Part | Pin | Label |
|---|---|---|
| Display | ⚙ | width 4, DEC, bus T |
| Display | ⚙ | width 4, DEC, bus U |
| LED | input | TICK |
3.5. Check
Clock—1Hz. Press Reset: the display shows 00.RUN= 1: the stopwatch counts 01, 02 … 09, 10, 11 … — one per second. Want it faster?Clock10Hz.- At 99 → 00 the tens and units go to zero together.
RUN= 0 — counting stops, theTICKlamp goes out.RUN= 1 — it continues from the same place.- Reset in the middle of counting — at once 00.
| What you see | What it is |
|---|---|
| units | first 74HC390 counter: ÷2 and ÷5 = 0–9 |
| tens | second counter: clocked by the units Q3 fall |
| TICK blinks | the clock passes the 74HC08: RUN = 1 |
Lesson 3 paste (Cmd+I)
On top of lesson 2.
# Lesson 3 — 74HC390: two decade counters in a package; a stopwatch 00–99.# Paste: Cmd+I on top of lesson 2. chip 74HC86 { portIn(1A) portIn(1B) portIn(2A) portIn(2B) portIn(3A) portIn(3B) portIn(4A) portIn(4B) portOut(1Y) portOut(2Y) portOut(3Y) portOut(4Y) XOR(1A, 1B, 1Y) XOR(2A, 2B, 2Y) XOR(3A, 3B, 3Y) XOR(4A, 4B, 4Y)} chip 74HC390 { portIn(1CP0) portIn(1MR) portIn(1CP1) portIn(2CP1) portIn(2MR) portIn(2CP0) portOut(1Q0) portOut(1Q1) portOut(1Q2) portOut(1Q3) portOut(2Q3) portOut(2Q2) portOut(2Q1) portOut(2Q0) 74HC04(1A=1CP0, 1Y=1c0, 2A=1C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