Chapter 6 · Book pp. 95–112
Getting Started with Digital Circuits
ก้าวสู่การเรียนรู้วงจรดิจิทัลเบื้องต้น
Digital circuits are a must for anyone learning electronics. From the late 20th century into the 21st, digital technology grew fast and replaced many analogue devices. This chapter gives you the basics, in theory and practice: digital signals, the binary number system, and the basic logic gates.
6.1 Signal levels ระดับสัญญาณ
- A digital signal has only two levels, high and low, called logic levels. A level near the supply voltage is logic “1” (high); a level near ground is logic “0”.
- There are two big families: TTL and CMOS. They use different supplies.
- TTL runs from 5 V ±5%. Below 0.8 V is “0”; 2 V and above is “1”.
- CMOS runs from 3 to 18 V, so its levels are fractions of the supply: up to 1/3 Vcc is “0”, and 2/3 Vcc and above is “1”.
- Between 0.8 and 2 V (TTL), or 1/3 and 2/3 Vcc (CMOS), the level is uncertain — it cannot be called “0” or “1”.
- To cover both families, the experiments in this chapter use a 4.5 V supply.
6.2 Truth table ตารางความจริง
A truth table shows how a digital circuit behaves. It has two parts: the inputs on the left and the output on the right. Every digital design starts with its truth table.
| Inputs | Output | |
|---|---|---|
| A | B | X |
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
6.3 The binary number system ระบบตัวเลขฐานสอง
Digital electronics is built on number systems. The basic one is binary (base 2); octal (base 8), decimal (base 10) and hexadecimal (base 16) were added for bigger calculations.
6.3.1 How many states?
Binary has only two digits, “0” and “1”: low–high, off–on. With more digits you get more states. Two lamps can be off-off, off-on, on-off and on-on: 4 states.
number of states = 2number of digits
2 digits → 2² = 4 · 3 digits → 2³ = 8 · 4 digits → 2⁴ = 16
6.3.2 Counting in binary
| Binary | Decimal |
|---|---|
| 0 | 0 |
| 1 | 1 |
| 10 | 2 |
| 11 | 3 |
| Binary | Decimal |
|---|---|
| 100 | 4 |
| 101 | 5 |
| 110 | 6 |
| 111 | 7 |
| Binary | Decimal |
|---|---|
| 1000 | 8 |
| 1001 | 9 |
| 1010 | 10 |
| 1011 | 11 |
| Binary | Decimal |
|---|---|
| 1100 | 12 |
| 1101 | 13 |
| 1110 | 14 |
| 1111 | 15 |
6.3.3 Binary words
- Bit — one binary digit, 0 or 1.
- Byte — 8 bits. A computer handles data at least one byte (8 bits) at a time.
- LSB (Least Significant Bit) — the rightmost bit, with the lowest place value, 2⁰. If it is “1” it is worth 1 × 2⁰ = 1; if “0”, 0 × 2⁰ = 0.
- Naming the bits — the rightmost is bit 0 (b0, the LSB), then bit 1 (b1), and so on: b7 b6 b5 b4 b3 b2 b1 b0.
- MSB (Most Significant Bit) — the leftmost bit. In 8 bits it is bit 7, worth 2⁷ = 128. With 6, 5 or 4 bits its place value is 2⁵, 2⁴ or 2³.
6.3.4 Place values
In decimal, place values are powers of ten: units 10⁰ = 1, tens 10¹ = 10, hundreds 10² = 100. Binary works the same with powers of two: bit 0 is 2⁰ = 1, bit 1 is 2¹ = 2, bit 2 is 2² = 4, and so on.
| Bit | Place value | Decimal | Bit | Place value | Decimal |
|---|---|---|---|---|---|
| 0 | 20 | 1 | 4 | 24 | 16 |
| 1 | 21 | 2 | 5 | 25 | 32 |
| 2 | 22 | 4 | 6 | 26 | 64 |
| 3 | 23 | 8 | 7 | 27 | 128 |
6.3.5 Binary to decimal
Example 6-1 · Convert 1011 to decimal
- Write the place values: b3 = 2³, b2 = 2², b1 = 2¹, b0 = 2⁰, over the digits 1 0 1 1.
- Multiply each digit by its place value and add: (1 × 2³) + (0 × 2²) + (1 × 2¹) + (1 × 2⁰) = 8 + 0 + 2 + 1 = 11.
6.3.6 Decimal to binary
Divide by 2 again and again and keep the remainders. The first remainder is the LSB (b0); the last is the MSB.
Example 6-2 · Convert 13 to binary
- 13 ÷ 2 = 6 remainder 1 → b0 (LSB) = 1
- 6 ÷ 2 = 3 remainder 0 → b1 = 0
- 3 ÷ 2 = 1 remainder 1 → b2 = 1
- 1 ÷ 2 = 0 remainder 1 → b3 (MSB) = 1
So 13 = 1101.
6.4 The NOT gate นอตเกต
6.4.1 What it does
A NOT gate inverts its input: “0” becomes “1” and “1” becomes “0”.
6.4.2 Testing the NOT gate IC
- The NOT gate IC is the 74HC04, with six NOT gates inside. The test uses just one.
- Input pin 1 has a 10 kΩ resistor to ground — a pull-down — so it is “0” whenever nothing else drives it. Then the output (pin 2) is “1” and LED1 lights.
- A 4-position DIP switch (SW1) sets the input. Switch 4 ON connects pin 1 to the supply: “1” in, “0” out, LED1 off.
- Switch it OFF and the pull-down gives “0” again, so the output is “1” and LED1 lights.
🛠️ Lab 6.1 · Test the 74HC04 NOT gate
- Build Fig 6-7 in Tinkercad. Slide switch 4 ON and OFF and watch the LED.
Switch 4 OFF → LED on. Switch 4 ON → LED off. - Build it with real parts (Fig 6-8) and repeat step 1.
6.5 The NAND gate แนนด์เกต
6.5.1 What it does
A NAND gate multiplies (ANDs) its inputs and then inverts the result. If pins 1 and 2 are both “1”, 1 × 1 = 1, inverted to “0”. X = A·B.
6.5.2 Testing the NAND gate IC
- The NAND IC is the 74HC00, with four NAND gates. The test uses one.
- Inputs 1 and 2 have 10 kΩ pull-up resistors (R1, R2), so they are “1” unless a pushbutton connects them to ground.
- The output, pin 3, drives LED1 through a 220 Ω resistor.
🛠️ Lab 6.2 · Test the 74HC00 NAND gate
- Build Fig 6-11 in Tinkercad. Press S1 and S2 and watch the LED.
- No button pressed: A = 1, B = 1 → LED off.
- Hold S1 only: A = 0, B = 1 → LED on.
- Hold S2 only: A = 1, B = 0 → LED on.
- Hold both: A = 0, B = 0 → LED on.
- Build it with real parts (Fig 6-12) and repeat step 1.
6.5.3 A note on logic ICs
These tests use one gate and leave the other three inputs floating — fine for a short experiment. In a real design, connect every unused input to ground or to the supply. Unused outputs can be left unconnected.
6.6 The NOR gate นอร์เกต
6.6.1 What it does
A NOR gate gives “1” only when every input is “0”. X = A+B.
6.6.2 Testing the NOR gate IC
- The NOR IC is the 74HC02, with four gates. Here the inputs are pins 2 and 3 and the output is pin 1, driving LED1 through 220 Ω.
- Both inputs start at “0”, held by pull-down resistors. Sliding a DIP switch ON makes that input “1”.
🛠️ Lab 6.3 · Test the 74HC02 NOR gate
- Build Fig 6-15 in Tinkercad. Switch DIP positions 1 and 4 step by step.
- Neither on: inputs “00” → LED on.
- Position 1 only: “10” → LED off.
- Position 4 only: “01” → LED off.
- Both on: “11” → LED off.
- Build it with real parts (Fig 6-16) and repeat step 1.
6.7 The AND gate แอนด์เกต
6.7.1 What it does
An AND gate gives “1” only when every input is “1” — it multiplies the inputs. X = A·B.
6.7.2 Testing it
- The AND IC is the 74HC08, with four independent gates. Inputs pins 1 and 2, output pin 3.
- LED off means the output is “0”; LED on means “1”.
- Pull-down resistors hold the inputs at “0”; a DIP switch ON connects that input to “1”.
🛠️ Lab 6.4 · Test the 74HC08 AND gate
- Build Fig 6-19 in Tinkercad and switch DIP positions 1 and 4 step by step.
- Neither on: “00” → LED off.
- Position 1 only: “10” → LED off.
- Position 4 only: “01” → LED off.
- Both on: “11” → LED on.
- Build it with real parts (Fig 6-20) and repeat step 1.
6.8 The OR gate ออร์เกต
6.8.1 What it does
An OR gate gives “1” when any input is “1” — it adds the inputs. X = A+B.
6.8.2 Testing it
The OR IC is the 74HC32, with four independent gates. Inputs are pins 1 and 2, output pin 3, with pull-down resistors on the inputs and an LED on the output.
🛠️ Lab 6.5 · Test the 74HC32 OR gate
- Build Fig 6-23 in Tinkercad and switch DIP positions 1 and 4 step by step.
- Neither on: “00” → LED off.
- Position 1 only: “10” → LED on.
- Position 4 only: “01” → LED on.
- Both on: “11” → LED on.
- Build it with real parts (Fig 6-24) and repeat step 1.
All five gates
| A | B | NOT A | NAND | NOR | AND | OR |
|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 | 0 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 | 0 | 1 |
| 1 | 1 | 0 | 0 | 0 | 1 | 1 |
| IC | 74HC04 | 74HC00 | 74HC02 | 74HC08 | 74HC32 | |
🛠️ Activity · Practise conversions and gates
- Convert to decimal: 0110, 1001, 1111, 10000000.
- Convert to binary: 5, 10, 25, 100.
- How many states can 6 bits show? What is the place value of the MSB of a 6-bit number?
- Before testing each gate in Tinkercad, fill in its truth table on paper, then check every row with the DIP switch.
- Change the NAND test (Fig 6-11) to use pull-down resistors and switches to the supply, like the AND test. Does the truth table change?
Check yourself
Chapter 6 has two worked examples and the gate tests but no exercises, so these questions are my own, based on its pages.