Lesson 1. Logic in packages: 74HC00, 02, 04, 08, 32
In picturesAfter this lesson the library has five real chips — with the same pin names as in the datasheet — and an alarm runs on them: open the door while the alarm is armed — the alarm lights up and the buzzer sounds, and the alarm stays on until someone presses Reset.
1.1. The idea: a chip is a package with gates
Wozniak built the Apple I not from separate gates but from 74-series chips: one package holds four or six identical gates. The package has 14 pins, each with a number and a name:
1A,1Bare the inputs of the first gate,1Yis its output; then2A,2B,2Yand so on up to the fourth;- pin 7 is
GND, pin 14 isVCC: power. Our power is shared by all chips, so these pins are not there.
The letters in the name are the family: HC are modern CMOS chips. Inside they have exactly what we build from transistors: P and N pairs. The digits say what is inside: 00 — NAND, 02 — NOR, 04 — NOT, 08 — AND, 32 — OR.
1.2. The idea: free inputs go to ground
On a board often only one gate of four is used. The inputs of the others must not be left in the air: a CMOS input has no level of its own, it "floats", and the gate output jitters. The rule from every datasheet: unused inputs go to GND (or to VCC). The same in the simulator: a hanging input gives an undefined value.
1.3. The idea: a latch from one chip
Two NANDs from one 74HC00 connected crosswise make an SR latch: a zero on one input lights the output, a zero on the other clears it, and when both are ones the latch remembers the last state. That is how the alarm remembers.
1.4. Building
A new project. You need the gates NOT, NAND, NOR, AND, OR — from any kit of the series or lesson 0.
Step 1. Chip 74HC00 — 4 × NAND
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 (our power is shared, so these pins are not there). Port name = pin name: double-click a port → 1A and so on.
| 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 |
| NAND | I0 I1 O0 | 1A 1B 1Y |
| NAND | I0 I1 O0 | 2A 2B 2Y |
| NAND | I0 I1 O0 | 3A 3B 3Y |
| NAND | I0 I1 O0 | 4A 4B 4Y |
Ctrl+G → name 74HC00. Legs: inputs 1A, 1B, 2A, 2B, 3A, 3B, 4A, 4B; outputs 1Y, 2Y, 3Y, 4Y.
Step 2. Chip 74HC02 — 4 × NOR
Package pins from the datasheet: 1 1Y, 2 1A, 3 1B, 4 2Y, 5 2A, 6 2B, 8 3A, 9 3B, 10 3Y, 11 4A, 12 4B, 13 4Y; 7 — GND, 14 — VCC (our power is shared, so these pins are not there). Port name = pin name: double-click a port → 1A and so on.
| 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 |
| NOR | I0 I1 O0 | 1A 1B 1Y |
| NOR | I0 I1 O0 | 2A 2B 2Y |
| NOR | I0 I1 O0 | 3A 3B 3Y |
| NOR | I0 I1 O0 | 4A 4B 4Y |
Ctrl+G → name 74HC02. Legs: inputs 1A, 1B, 2A, 2B, 3A, 3B, 4A, 4B; outputs 1Y, 2Y, 3Y, 4Y.
Step 3. Chip 74HC04 — 6 × NOT
Package pins from the datasheet: 1 1A, 2 1Y, 3 2A, 4 2Y, 5 3A, 6 3Y, 8 4Y, 9 4A, 10 5Y, 11 5A, 12 6Y, 13 6A; 7 — GND, 14 — VCC (our power is shared, so these pins are not there). Port name = pin name: double-click a port → 1A and so on.
| Part | Pin | Label |
|---|---|---|
| Input port | output | 1A |
| Input port | output | 2A |
| Input port | output | 3A |
| Input port | output | 4A |
| Input port | output | 5A |
| Input port | output | 6A |
| Output port | input | 1Y |
| Output port | input | 2Y |
| Output port | input | 3Y |
| Output port | input | 4Y |
| Output port | input | 5Y |
| Output port | input | 6Y |
| NOT | I0 O0 | 1A 1Y |
| NOT | I0 O0 | 2A 2Y |
| NOT | I0 O0 | 3A 3Y |
| NOT | I0 O0 | 4A 4Y |
| NOT | I0 O0 | 5A 5Y |
| NOT | I0 O0 | 6A 6Y |
Ctrl+G → name 74HC04. Legs: inputs 1A, 2A, 3A, 4A, 5A, 6A; outputs 1Y, 2Y, 3Y, 4Y, 5Y, 6Y.
Step 4. Chip 74HC08 — 4 × AND
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 (our power is shared, so these pins are not there). Port name = pin name: double-click a port → 1A and so on.
| 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 |
| AND | I0 I1 O0 | 1A 1B 1Y |
| AND | I0 I1 O0 | 2A 2B 2Y |
| AND | I0 I1 O0 | 3A 3B 3Y |
| AND | I0 I1 O0 | 4A 4B 4Y |
Ctrl+G → name 74HC08. Legs: inputs 1A, 1B, 2A, 2B, 3A, 3B, 4A, 4B; outputs 1Y, 2Y, 3Y, 4Y.
Step 5. Chip 74HC32 — 4 × OR
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 (our power is shared, so these pins are not there). Port name = pin name: double-click a port → 1A and so on.
| 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 |
| OR | I0 I1 O0 | 1A 1B 1Y |
| OR | I0 I1 O0 | 2A 2B 2Y |
| OR | I0 I1 O0 | 3A 3B 3Y |
| OR | I0 I1 O0 | 4A 4B 4Y |
Ctrl+G → name 74HC32. Legs: inputs 1A, 1B, 2A, 2B, 3A, 3B, 4A, 4B; outputs 1Y, 2Y, 3Y, 4Y.
Step 6. Alarm: power and inputs
Switches ARM — the alarm is on, DOOR — the door is open, WIN — the window is open; the Reset button is RESET.
| Part | Pin | Label |
|---|---|---|
| Power | output | VCC |
| Ground | output | GND |
| Input (switch) | output | ARM |
| Input (switch) | output | DOOR |
| Input (switch) | output | WIN |
| Button «Reset» | output | RESET |
Step 7. Open: 74HC32
OPEN = door OR window. One gate of four works; the inputs of the other three go to GND: a CMOS chip input must not hang in the air, otherwise the output "floats". The same on a real board.
| Part | Pin | Label |
|---|---|---|
| 74HC32 | 1A 1B 1Y 2A 2B 3A 3B 4A 4B | DOOR WIN OPEN GND GND GND GND GND GND |
Step 8. The alarm starts: 74HC08
TRIP = open AND the alarm is on.
| Part | Pin | Label |
|---|---|---|
| 74HC08 | 1A 1B 1Y 2A 2B 3A 3B 4A 4B | OPEN ARM TRIP GND GND GND GND GND GND |
Step 9. Inversion: 74HC04
A NAND latch is triggered by a zero, so TRIP and the RESET button are inverted: nTRIP, nRESET.
| Part | Pin | Label |
|---|---|---|
| 74HC04 | 1A 1Y 2A 2Y 3A 4A 5A 6A | TRIP nTRIP RESET nRESET GND GND GND GND |
Step 10. Alarm latch: 74HC00
Two NANDs crossed — a latch: nTRIP = 0 lights ALARM, nRESET = 0 clears it. The alarm stays on even after the door is closed — until Reset is pressed.
| Part | Pin | Label |
|---|---|---|
| 74HC00 | 1A 1B 1Y 2A 2B 2Y 3A 3B 4A 4B | nTRIP ALQN ALARM nRESET ALARM ALQN GND GND GND GND |
Step 11. Ready: 74HC02
READY = NOR(open, alarm): lit when everything is closed and there is no alarm.
| Part | Pin | Label |
|---|---|---|
| 74HC02 | 1Y 1A 1B 2A 2B 3A 3B 4A 4B | READY OPEN ALARM GND GND GND GND GND GND |
| LED | input | ALARM |
| LED | input | READY |
| Speaker (buzzer, 880) | SPKR | ALARM |
Step 12. Lamps and chime
Speaker — buzzer mode, tone 880: it buzzes while ALARM = 1.
| Part | Pin | Label |
|---|---|---|
| LED | input | ALARM |
| LED | input | READY |
| Speaker (buzzer, 880) | SPKR | ALARM |
1.5. Check
- Press Reset:
ALARMis off,READYis lit — everything is closed, no alarm. DOOR= 1 (the alarm is off):READYgoes out — the door is open, but there is no alarm.DOOR= 0 —READYis lit again.ARM= 1 — the alarm is on.WIN= 1:ALARMlights up, the buzzer sounds,READYgoes out.WIN= 0 — the window is closed, butALARMstays lit: the latch remembers the alarm.- Reset —
ALARMgoes out,READYis lit. DOOR= 1 and Reset: the alarm does not go out — while the door is open,nTRIPholds the latch.
| What you see | What it is |
|---|---|
| ALARM lit | something opened while the alarm was on |
| ALARM lit, all closed | the 74HC00 latch remembers — press Reset |
| READY lit | everything closed, no alarm |
Lesson 1 paste (Cmd+I)
You need the gates NOT, NAND, NOR, AND, OR (lesson 0 or its paste). The paste is five chips and the alarm; set the Speaker by hand — buzzer mode, tone 880.
# Lesson 1 — logic in packages: 74HC00, 74HC02, 74HC04, 74HC08, 74HC32 and an alarm built from them.# Paste: Cmd+I into a project with the gates NOT, NAND, NOR, AND, OR (lesson 0). chip 74HC00 { portIn(1A) portIn(1B) portIn(2A) portIn(2B) portIn(3A) portIn(3B) portIn(4A) portIn(4B) portOut(1Y) portOut(2Y) portOut(3Y) portOut(4Y) NAND(1A, 1B, 1Y) NAND(2A, 2B, 2Y) NAND(3A, 3B, 3Y) NAND(4A, 4B, 4Y)} chip 74HC02 { portIn(1A) portIn(1B) portIn(2A) portIn(2B) portIn(3A) portIn(3B) portIn(4A) portIn(4B) portOut(1Y) portOut(2Y) portOut(3Y) portOut(4Y) NOR(1A, 1B, 1Y) NOR(2A, 2B, 2Y) NOR(3A, 3B, 3Y) NOR(4A, 4B, 4Y)} chip 74HC04 { portIn(1A) portIn(2A) portIn(3A) portIn(4A) portIn(5A) portIn(6A) portOut(1Y) portOut(2Y) portOut(3Y) portOut(4Y) portOut(5Y) portOut(6Y) NOT(1A, 1Y) NOT(2A, 2Y) NOT(3A, 3Y) NOT(4A, 4Y) NOT(5A, 5Y) NOT(6A, 6Y)} chip 74HC08 { portIn(1A) portIn(1B) portIn(2A) portIn(2B) portIn(3A) portIn(3B) portIn(4A) portIn(4B) portOut(1Y) portOut(2Y) portOut(3Y) portOut(4Y) AND(1A, 1B, 1Y) AND(2A, 2B, 2Y) AND(3A, 3B, 3Y) AND(4A, 4B, 4Y)} chip 74HC32 { portIn(1A) portIn(1B) portIn(2A) portIn(2B) portIn(3A) portIn(3B) portIn(4A) portIn(4B) portOut(1Y) portOut(2Y) portOut(3Y) portOut(4Y) OR(1A, 1B, 1Y) OR(2A, 2B, 2Y) OR(3A, 3B, 3Y) OR(4A, 4B, 4Y)} power(VCC)ground(GND)input(ARM)input(DOOR)input(WIN)button{label="Reset"}(RESET)74HC32(1A=DOOR, 1B=WIN, 1Y=OPEN, 2A=GND, 2B=GND, 3A=GND, 3B=GND, 4A=GND, 4B=GND)74HC08(1A=OPEN, 1B=ARM, 1Y=TRIP, 2A=GND, 2B=GND, 3A=GND, 3B=GND, 4A=GND, 4B=GND)74HC04(1A=TRIP, 1Y=nTRIP, 2A=RESET, 2Y=nRESET, 3A=GND, 4A=GND, 5A=GND, 6A=GND)74HC00(1A=nTRIP, 1B=ALQN, 1Y=ALARM, 2A=nRESET, 2B=ALARM, 2Y=ALQN, 3A=GND, 3B=GND, 4A=GND, 4B=GND)74HC02(1Y=READY, 1A=OPEN, 1B=ALARM, 2A=GND, 2B=GND, 3A=GND, 3B=GND, 4A=GND, 4B=GND)led(ALARM)led(READY)speaker{mode="buzz", tone=880}(ALARM)Stuck? Something doesn't work →