← Circuits with Tinkercad

Chapter 8 · Book pp. 119–126

Applied Digital Circuits 2: the Counter IC

เรียน-เล่น-รู้ กับวงจรดิจิทัลขั้นประยุกต์ 2 - ไอซีวงจรนับ

A counter circuit counts pulses or events coming into it. It usually works in binary and shows the result as binary, or in another form such as decimal or hexadecimal, depending on the design.

8.1 Binary counters วงจรนับเลขฐานสอง

A binary counter is a basic digital circuit with three main parts:

  1. Flip-flops — the core. Each stores the state of one bit. Common types are the D flip-flop and the JK flip-flop.
  2. A clock signal — makes the counter change state at set times.
  3. Logic gates — control the counter and set conditions, such as resetting or changing state.

There are four basic types of counter:

TypeWhat it doesExample
Up counterCounts upwards0 → 1 → 2 → 3
Down counterCounts downwards3 → 2 → 1 → 0
Up-down counterCan count up or down—
Modulo counterHas a set end value, then starts againModulo 4: 0 → 1 → 2 → 3 → 0 (or 0 → 3 → 2 → 1 → 0 counting down)

Counters are used in timers, rev counters (tachometers), clock and timer circuits, waveform generators — and they are a foundation of digital systems and microcontrollers.

Next: the JK flip-flop →

8.2 Starting with the JK flip-flop JK ฟลิปฟลอป

A flip-flop is a digital circuit with two outputs that are always opposite. The key to a counter is the T (toggle) flip-flop, made from a JK flip-flop.

The JK flip-flop grew from the RS flip-flop, which uses two NOR gates. A “1” on S sets it; a “1” on R resets it. But if R and S are both “1”, the state cannot be decided — so it was improved into the JK flip-flop.

Fig 8-1The RS flip-flop: (a) logic diagram, (b) truth table — R = S = 1 is not allowed (NA), (c) symbol

The JK flip-flop fixes the problem: when both inputs are “1”, it toggles. So it can be used as a T flip-flop, the basic building block of a binary counter.

Fig 8-2The JK flip-flop: (a) symbol, (b) truth table — 00 hold (Qn), 01 → 0, 10 → 1, 11 toggle; (c) with “1” on J and K and a clock signal, Q and Q̄ change on every clock, working as a T flip-flop

Next: how digital counters work →

8.3 How digital counters work แนวทางการทำงานของวงจรนับ

8.3.1 Asynchronous counters

Join JK flip-flops wired as T flip-flops and you get a binary counter (Fig 8-3). In this 4-bit asynchronous counter, each flip-flop is clocked by the output of the one before. The first flip-flop’s output is the LSB. Four flip-flops count 16 states: 0–15 in decimal, 0000–1111 in binary, 0–F in hexadecimal.

It is simple, but each flip-flop waits for the one before, so the delays add up. If each takes 50 ns, four take 4 × 50 = 200 ns, so the highest frequency is 1 ÷ (200 × 10⁻⁹) = 5 MHz.

Fig 8-3A 4-bit asynchronous binary counter built from JK flip-flops working as T flip-flops. Outputs A, B, C, D are worth 2⁰, 2¹, 2², 2³

8.3.2 Synchronous counters

In a synchronous counter (Fig 8-4, 3 bits) the clock goes to every flip-flop at once, so they all change together.

Fig 8-4A 3-bit synchronous binary counter built from JK flip-flops working as T flip-flops, with AND gates A1 and A2. A “1” enables counting
  • Pulse 1: FF1 changes from “0” to “1” → 001.
  • Pulse 2: FF1 goes back to “0”, but Q1 was “1” just before, so FF2 changes and Q2 becomes “1” → 010.
  • Pulse 3: FF1 changes → 011.
  • Pulse 4: FF3 changes, because A2’s output, FF1 and FF2 were all “1” → 100. And so on up to 111, then back to 000 (Fig 8-5).
Fig 8-5Timing diagram of a 3-bit synchronous binary counter: the clock, and outputs A, B and C over 8 pulses

There is no build-up of delay, so it works at higher frequencies — but the circuit is more complex.

8.4 Controlling the count การควบคุมการนับ

A 4-bit counter normally counts 0000 to 1111 (0 to F). To make it stop at 9 (1001) — a decimal or BCD counter — check bits 2¹ (B) and 2³ (D). When the counter reaches ten, the binary is 1010, so B and D are both “1”. AND them together and send the result to every flip-flop’s reset. Now the circuit counts only 0 to 9.

Fig 8-6An example decimal (BCD) counter, counting 0 to 9: an AND gate on QB and QD resets every flip-flop

⏱️ Try it: clock a 4-bit counter

QDQCQBQA

Next: the 74HC93 →

8.5 The 74HC93 counter IC ไอซีวงจรนับ 74HC93

Designers usually use a counter IC rather than flip-flops and gates, because it needs far fewer parts. There are many: decimal counters and 4-bit binary counters, counting up or down. This chapter uses the 74HC93, a 4-bit asynchronous binary counter that is easy to use.

Fig 8-7Pinout and function table of the 74HC93 4-bit binary counter: with MR1 = MR2 = 1 nothing counts (all 0); otherwise each clock on CP0 counts up 0000 to 1111 (with CP1 joined to QA)
PinNameJob
14CP0Clock input; counts on the falling edge of the clock
1CP1Clock input for the second stage — connect it to QA
2, 3MR1, MR2Master reset (see the table below)
4, 6, 7, 13NCNo connection
5VccSupply, 2 to 6 V
10GNDGround
12QA (Q0)Output bit 0 — the LSB
9QB (Q1)Output bit 1
8QC (Q2)Output bit 2
11QD (Q3)Output bit 3 — the MSB
MR1MR2QD QC QB QA
110 0 0 0 (reset)
10Counts
01
00

The IC counts unless MR1 and MR2 are both “1”. When they are, it stops and QA–QD all read “0”.

Basic connections

  1. Connect MR1 (pin 2) and MR2 (pin 3) to ground.
  2. Connect Vcc (pin 5) to a 2–6 V supply.
  3. Connect GND (pin 10) to ground.
  4. Connect CP1 (pin 1) to QA / Q0 (pin 12).
  5. Feed the clock into CP0 (pin 14).
  6. Watch the outputs QA (pin 12), QB (pin 9), QC (pin 8) and QD (pin 11).

Next: testing the 74HC93 →

8.6 Testing the 74HC93 ทดลองใช้งานไอซีวงจรนับ 74HC93

In Fig 8-8, pushbutton S1 makes the clock pulses for CP0 (pin 14). The IC counts on every falling edge, and the count shows on four LEDs: QA is the LSB and QD the MSB. Each press adds one, up to 1111 (15) with all four LEDs on; the next pulse goes back to 0. It keeps going until the power is removed or MR1 and MR2 are both “1”.

Fig 8-8A 4-bit binary counter using the 74HC93: R1 10k pull-up, S1 CLOCK, and LEDs on QD, QC, QB and QA through 220 Ω resistors

🛠️ Lab 8.1 · Count with the 74HC93

  1. Build the circuit in Tinkercad (Fig 8-9).
  2. Click switch S1 and watch the four LEDs.
  3. Build it with real parts (Fig 8-10) and repeat step 2.
  4. You may find one press sometimes adds more than one. That is switch bounce: the contacts make the clock signal several times — too fast for you to see, but the IC counts them all. The fix is to put a 1–10 µF capacitor across S1 to remove the noise. This is called debouncing.
Fig 8-9Testing the 74HC93 on Tinkercad by simulation (10k, S1, 4 × 220 Ω, four LEDs, 4.5 V)
Fig 8-10Testing the 74HC93 with real parts on a breadboard. Scan the QR code for the demo video

Next: review →

Key ideas

IdeaRemember
RS flip-flopS sets, R resets; R = S = 1 is not allowed
JK flip-flopJ = K = 1 toggles → T flip-flop
Asynchronous counterSimple; delays add up (4 × 50 ns → 5 MHz max)
Synchronous counterShared clock, faster, more complex
BCD counterReset at 1010 using B AND D → counts 0–9
74HC934-bit async counter; CP1 to QA; MR1 = MR2 = 1 resets
Switch bounceDebounce with 1–10 µF across the switch

🛠️ Activity · Extend the counter

  1. In Tinkercad, press S1 eight times. Write the LED pattern after each press as binary and decimal.
  2. Add a 10 µF capacitor across S1 and check that each press now adds exactly one.
  3. Make it a BCD counter: connect QB (pin 9) to MR1 (pin 2) and QD (pin 11) to MR2 (pin 3) instead of grounding them. Does it now count 0–9?
  4. Replace S1 with the 555 astable from Chapter 5 (Project 7) as the clock. What happens?

Check yourself

Chapter 8 has worked explanations but no exercises, so these questions are my own, based on its pages.

1. A modulo-4 up counter counts…
2. In an RS flip-flop built from NOR gates, which input combination is not allowed?
3. What does a JK flip-flop do when J = 1 and K = 1 and a clock pulse arrives?
4. How far can a 4-flip-flop binary counter count?
5. Four flip-flops each take 50 ns in an asynchronous counter. What is its highest counting frequency?
6. What is the advantage of a synchronous counter?
7. How is a 4-bit counter turned into a BCD (0–9) counter?
8. On the 74HC93, what makes the outputs all go to 0 and stop counting?
9. To use the 74HC93 as a 4-bit counter, what must CP1 (pin 1) be connected to?
10. One press of the clock button sometimes adds 2 or 3 to the count. Why, and what is the fix?