ลอจิกเกต (Logic Gates)
Logic Gates
ดิจิทัล 0/1 • AND OR NOT NAND NOR XOR XNOR • ตารางความจริง • IC 74xx + ซิมโต้ตอบ
Digital 0/1 • AND OR NOT NAND NOR XOR XNOR • Truth tables • 74xx ICs + live sim
- อธิบายสัญญาณดิจิทัล (ลอจิก 0/1, LOW/HIGH) และต่างจากสัญญาณอนาล็อกอย่างไร
- บอกหน้าที่และเขียนตารางความจริงของเกต 7 ชนิดได้
- อ่านสัญลักษณ์ของแต่ละเกตได้
- เข้าใจว่า NAND/NOR เป็น "เกตสากล (universal)" สร้างเกตอื่นได้ทั้งหมด
- รู้จัก IC ลอจิกตระกูล 74xx / CMOS 4000 และข้อควรระวัง
- Explain digital signals (logic 0/1, LOW/HIGH) and how they differ from analog
- State the function and write the truth table of the 7 gates
- Read each gate's symbol
- Understand that NAND/NOR are "universal" gates — any gate can be built from them
- Recognise 74xx / CMOS 4000 logic ICs and their cautions
- สัญญาณดิจิทัลมีแค่ 2 สถานะ: 0 (LOW, ~0 V) และ 1 (HIGH, ~Vcc)
- ต่างจากอนาล็อกที่แรงดันค่อยๆ เปลี่ยนได้ทุกค่า
- ลอจิกเกต คือวงจรที่รับอินพุต 0/1 แล้วให้เอาต์พุต 0/1 ตามกฎตรรกะ
- นำเกตมาต่อกันเป็นวงจรคำนวณ → เป็นพื้นฐานของ คอมพิวเตอร์และดิจิทัลทั้งหมด
- A digital signal has only two states: 0 (LOW, ~0 V) and 1 (HIGH, ~Vcc)
- Unlike analog, whose voltage can take any value
- A logic gate takes 0/1 inputs and gives a 0/1 output by a logic rule
- Connect gates together to compute → the basis of all computers and digital systems
ลอจิกเกตเหมือน "สวิตช์ไฟที่มีกฎ" — เช่นเกต AND คือ "ไฟติดก็ต่อเมื่อกดสวิตช์ทั้งสองพร้อมกัน" ส่วน OR คือ "กดอันใดอันหนึ่งไฟก็ติด"
A gate is like a "light switch with a rule" — AND means "the light turns on only if both switches are pressed", OR means "press either one and it turns on".
| เกตGate | นิพจน์Boolean | กฎRule |
|---|---|---|
| AND | Y = A·B | เป็น 1 เมื่อ ทุกอินพุต เป็น 11 only if all inputs are 1 |
| OR | Y = A+B | เป็น 1 เมื่อ อย่างน้อยหนึ่ง อินพุตเป็น 11 if any input is 1 |
| NOT | Y = Ā | กลับค่า (อินเวอร์เตอร์)Inverts the input |
| NAND | Y = A·B̅ | AND แล้วกลับค่าAND then inverted |
| NOR | Y = A+B̅ | OR แล้วกลับค่าOR then inverted |
| XOR | Y = A⊕B | เป็น 1 เมื่ออินพุต ต่างกัน1 when inputs differ |
| XNOR | Y = A⊕B̅ | เป็น 1 เมื่ออินพุต เหมือนกัน1 when inputs are the same |
ตารางความจริงรวม (2 อินพุต)Combined truth table (2 inputs)
| A | B | AND | OR | NAND | NOR | XOR | XNOR |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 |
NOT
| A | Y |
|---|---|
| 0 | 1 |
| 1 | 0 |
เลือกชนิดเกต แล้วกดปุ่ม A / B เพื่อสลับค่า 0↔1 ดูว่าเอาต์พุต Y (LED) ติดหรือดับ และแถวที่ตรงกันในตารางความจริงจะถูกไฮไลต์
Pick a gate, then click A / B to toggle 0↔1 and watch the output Y (LED) turn on/off — the matching truth-table row is highlighted.
สายสีเขียว = ลอจิก 1, สีเทา = ลอจิก 0 • LED เขียว = เอาต์พุต 1 Green wire = logic 1, grey = logic 0 • green LED = output 1
กดเพื่อสลับ 0/1 (NOT ใช้แค่ A)Click to toggle 0/1 (NOT uses A only)
- NAND และ NOR เรียกว่า "เกตสากล"
- ใช้ NAND อย่างเดียว (หรือ NOR อย่างเดียว) สร้างเกตอื่นได้ ครบทุกชนิด
- เช่น NAND ที่ต่ออินพุตเข้าด้วยกัน = NOT, ฯลฯ
- ทำให้โรงงานผลิต IC ชนิดเดียวก็พอ → ประหยัด
- NAND and NOR are the "universal" gates
- Using only NAND (or only NOR) you can build every other gate
- e.g. a NAND with its inputs tied together = NOT, and so on
- So a factory can make just one gate type → cheaper
การลดรูปวงจรลอจิกใช้กฎพีชคณิตบูลีน เช่น กฎเดอมอร์แกน: A·B̅ = Ā + B̄ และ A+B̅ = Ā · B̄ — ช่วยแปลงระหว่าง AND/OR/NOT ได้
Logic circuits are simplified with Boolean algebra, e.g. De Morgan's laws: A·B̅ = Ā + B̄ and A+B̅ = Ā · B̄ — handy for converting between AND/OR/NOT.
| IC | เกตGate |
|---|---|
| 7408 | AND ×4 |
| 7432 | OR ×4 |
| 7404 | NOT ×6 |
| 7400 | NAND ×4 |
| 7486 | XOR ×4 |
ตระกูล 74xx = TTL, 74HCxx = CMOS เร็ว, 4000 = CMOS ดั้งเดิม
74xx = TTL, 74HCxx = fast CMOS, 4000 = classic CMOS
- ระดับลอจิก: ดูจาก datasheet ว่าช่วงไหนคือ 0 และ 1 (ขึ้นกับ Vcc/ตระกูล)
- ห้ามปล่อยอินพุตลอย โดยเฉพาะ CMOS — ต่อลง 0 หรือ 1 ให้แน่นอน
- ใส่ ตัวเก็บประจุ decoupling 0.1 µF ใกล้ขาไฟทุกตัว
- เอาต์พุตขับ LED ต้องมี ตัวต้านทานจำกัดกระแส
- Logic levels: check the datasheet for the 0 and 1 ranges (depend on Vcc/family)
- Never leave inputs floating, especially CMOS — tie them to a fixed 0 or 1
- Add a 0.1 µF decoupling capacitor near every supply pin
- Driving an LED from an output needs a current-limiting resistor