您将学到什么

  • Recognise OR as the gate of choice for "any of these" trigger logic.
  • Read the 3-input OR truth table — only the all-zeros row produces 0.
  • Compare OR-based and AND-based security systems and pick the right one for the use case.
  • See OR gates aggregating multiple sensor or alarm signals in real systems.
  • Understand why adding another sensor to an OR-based alarm is just one more input.

工作原理

Real alarm systems work on a simple rule: if any sensor detects something, sound the alarm. This circuit wires three sensor switches — Window, Motion, Glass-break — into an OR gate that drives an alarm output. The output is high whenever at least one sensor is active.

With three inputs, OR has 2³ = 8 possible input combinations. Of these, exactly one (all zeros) keeps the alarm silent; the other seven trigger it. This is the inverse pattern from AND, which fires only on the all-ones row.

The educational insight: OR encodes the security policy "trigger if any of these conditions are met," while AND encodes "trigger only when all conditions are met." The same three sensor switches feeding an AND gate would mean "alarm only when all three sensors agree something is wrong" — useful in some applications (false-alarm reduction by requiring corroboration) but the wrong choice for an intrusion alarm where missing one sensor due to a single trigger event would be catastrophic.

Notice that OR is commutative and associative — sensor order doesn't matter, and a 3-input OR is equivalent to chaining two 2-input ORs.

真值表

Three sensors feeding an OR gate: 8 combinations, 7 of which trigger the alarm. Only the all-quiet state (0,0,0) keeps the alarm silent.

输入 输出
WindowMotionGlass Alarm
000 0 All quiet — alarm silent
001 1 Glass-break alone fires alarm
010 1
011 1
100 1
101 1
110 1
111 1 All sensors firing — alarm active

布尔表达式

Y=A+B+CY = A + B + C

OR with three inputs — output is 1 if any of A, B, C is 1.

Y=ABCY = A \lor B \lor C

Same expression in formal-logic notation.

Y=ABCY = \overline{\overline{A} \cdot \overline{B} \cdot \overline{C}}

De Morgan equivalent — OR of the inputs equals NOT of the AND of inverted inputs.

逐步尝试

在上方嵌入式电路中设置输入,然后阅读预期结果并验证。

  1. 1
    Window = 0 Motion = 0 Glass = 0
    预期: Alarm = 0
    您将看到: All sensors quiet — alarm light is dark. This is the only combination that keeps the alarm silent.
  2. 2
    Window = 1 Motion = 0 Glass = 0
    预期: Alarm = 1
    您将看到: Single sensor activates and the alarm fires immediately. OR doesn't wait for corroboration.
  3. 3
    Window = 0 Motion = 1 Glass = 1
    预期: Alarm = 1
    您将看到: Two sensors both active — alarm stays on. Once on, additional sensors don't change the output.
  4. 4
    Window = 1 Motion = 1 Glass = 1
    预期: Alarm = 1
    您将看到: All three sensors active. OR continues to output 1 — there's no "more high" than 1.

使用的组件

实际应用

Home security systems. Window switches, motion detectors, glass-break sensors, and door contacts all OR together to drive a single alarm output. Add another sensor: just OR it in.

Industrial e-stop chains. Emergency-stop buttons throughout a factory feed an OR gate that cuts machine power. Any single button press shuts down the line — exactly what's needed for safety.

Smoke and fire detection. Multiple smoke detectors in a building OR together to trigger sprinklers and the central alarm. One detector is enough to activate the response.

CPU interrupt aggregation. Every peripheral that can request CPU attention — keyboard, network card, disk, timer — drives an interrupt line. Those lines OR together to a single CPU input. The CPU then reads a separate "who interrupted" register to identify the source.

Multi-fault detection. Power-supply over-voltage, over-current, and over-temperature signals OR together to drive a single "fault" line that shuts the supply down.

常见问题

Why use OR instead of AND for an alarm system?
An alarm should trigger if anything goes wrong, not only if every sensor agrees. AND would require all sensors to detect the same event simultaneously — too restrictive. OR matches the real safety requirement: any sensor is enough.
What if I want to require two sensors before alarming (false-alarm reduction)?
Use a majority gate — true when at least 2 of N inputs are high. It can be built from a network of ANDs and ORs, or via a threshold function. Some commercial alarms use this exact pattern to reduce nuisance triggers.
How would I add a fourth sensor?
Replace the 3-input OR with a 4-input OR, or chain a 2-input OR after the existing one (associativity guarantees the same result). Wide-fan-in ORs are common in alarm systems.
Can I disable a sensor temporarily?
Yes — feed each sensor through an AND gate with an enable line, then OR the AND outputs. Setting an enable low effectively masks that sensor without rewiring.
What's the difference between OR-alarm and any-failed-NAND logic?
Functionally similar but inverted: OR-alarm is high when any sensor is active; NAND-of-NOTs is also high when any sensor is active. They're De Morgan duals.

继续学习