Engineering mission · M-007
The Three-Sensor Interlock
Design the logic that lets a robot cell run only when its door is shut, even if one of three door sensors lies.
About 1.5 h · introductory · 5 steps · Uses Lab 05 · Free
The situation
A teaching workshop has a small robot arm inside a clear enclosure with a hinged door. The arm may only move when the door is shut. To guard against a single faulty sensor, the door has three independent door sensors, G1, G2 and G3. Each one outputs 1 when it believes the door is shut and 0 when it believes it is open.
There are two more inputs. E is the emergency-stop button: E = 1 means it has been pressed. S is the start switch: S = 1 means an operator has asked the arm to run.
Your job is to design the combinational logic that produces one output, RUN, which is 1 only when the arm is allowed to move. You will also design a second output, FAULT, which tells a technician that the three door sensors disagree, so a failing sensor gets noticed and replaced before a second one fails.
This is a paper and browser exercise: nothing is built or wired. Real safety systems are designed to published standards, use certified components and are checked by qualified people, so treat this as a way of learning how logic captures a rule, not as a recipe for a real machine.
Several correct circuits exist. You will be judged on whether your truth tables are complete and right, how clearly you reason about what happens when sensors fail, and how honestly you describe what ideal logic leaves out.
You will learn to
- Translate a written safety rule into a complete truth table and a Boolean expression.
- Build and verify a majority-vote circuit and a disagreement detector in the logic lab.
- Analyse how a stuck sensor changes a circuit's behaviour, and identify the failures it cannot catch.
- Compare two circuits for the same function by gate count and by what each one makes easy to check.
Constraints
- C1Use only AND, OR, NOT and XOR gates with at most two inputs each (NOT has one).
- C2RUN must be 0 whenever E = 1 or S = 0, whatever the door sensors say.
- C3RUN must follow the majority of the three door sensors, so any single faulty sensor is outvoted.
- C4FAULT must be 1 exactly when the three door sensors do not all agree.
- C5Give complete truth tables, not just a few example rows, and treat every signal as an ideal 0 or 1.
Background
Logic as a specification
A combinational circuit has no memory: its outputs depend only on its inputs at that moment. That makes it possible to describe it completely with a truth table, one row for every combination of inputs. With n inputs there are 2ⁿ rows, so three door sensors give 8 rows and all five inputs give 32.
The gates you will use are:
- AND: 1 only when every input is 1.
- OR: 1 when at least one input is 1 (including when both are).
- NOT: flips its input.
- XOR: 1 when its two inputs differ.
Voting between sensors
A majority vote of three signals is 1 when at least two of them are 1. One way to write it is:
V = (G1 AND G2) OR (G2 AND G3) OR (G1 AND G3)If one sensor fails, the other two still decide. That is the reason for having three: with two sensors that disagree, there is no way to tell which one is right.
Combining conditions
The arm should run only when the vote says the door is shut, the emergency stop is not pressed and the start switch is on. Each condition is necessary, so they are joined with AND, and the emergency stop needs a NOT because E = 1 means stop.
Detecting disagreement
The three sensors agree when they are all 1 or all 0. Any other pattern means at least one sensor is wrong. Two XOR gates are a compact way to notice a difference: G1 XOR G2 is 1 when those two differ, and G2 XOR G3 is 1 when those two differ.
Stuck-at faults
A common way to reason about failures is the stuck-at model: a broken sensor is assumed to output a constant 1 or a constant 0 whatever the door is doing. For each possible fault you can ask two questions: does RUN still do the safe thing, and does FAULT notice? A sensor stuck at 1 is the more dangerous kind here, because it claims the door is shut.
What ideal logic leaves out
The lab's gates are ideal: they switch instantly, and every signal is exactly 0 or 1. Real circuits have propagation delays, so for a moment after an input changes, an output can briefly show a wrong value (a glitch). Real switches also bounce, and wires can break. Part of this mission is saying honestly which of these your design does not handle.
Lab 05 · Digital logic
Explorer 05 — Digital logic
Build answers out of ones and zeros
- 1 (high)
- 0 (low)
- Unknown
- Inverting output
A single two-input gate. Change its type and watch the truth table change.
Inputs
Gates (1 of 8)
G1 = 0
Add a gate
Outputs
- Gates
- 1
- Depth
- 1
- Longest chain of gates a signal passes through
- Rows
- 4
- 2^2 input combinations
- Check
- —
| Set inputs | A | B | Y |
|---|---|---|---|
| 0 | 0 | 0 | |
| 0 | 1 | 0 | |
| 1 | 0 | 0 | |
| 1 | 1 | 1 |
State
Inputs A = 0, B = 0. Outputs Y = 0.
Inputs A = 0, B = 0. Outputs Y = 0.
How to read this
Signals flow left to right. Circles on the left are the inputs, boxes are gates and squares on the right are outputs. A thick bright wire carries a 1, a thin grey wire carries a 0, and each gate shows the value it outputs. A small circle on a gate's output means it inverts (NOT, NAND, NOR, XNOR).
The truth table lists every possible input combination and what the circuit outputs for each, so it describes the circuit completely. Two circuits with the same truth table are equivalent, however differently they are built. That is why NAND alone can make any other gate. Choose a row to set the inputs to it.
Assumptions & limitations
- Ideal logic: every wire is exactly 0 or 1. Real gates use voltage ranges (for example near 0 V and near 3.3 V or 5 V) and an input between them is undefined.
- Gates switch instantly here. Real gates take nanoseconds each, so a deeper circuit is slower, and outputs can glitch briefly while signals race through different paths.
- Only combinational circuits are allowed: no output may feed back into its own input. Feedback is how memory (latches and flip-flops) works, but it needs timing this model does not simulate, so loops are reported as an error.
- Gates here have one input (NOT) or two inputs. Real chips also have three- and four-input gates, and limits on how many inputs one output can drive (fan-out).
- Gate counts are a simple measure of size; real designs also weigh speed, power and the number of transistors per gate.
How to approach it
- 01
Write the vote truth table
On paper, list all 8 combinations of G1, G2 and G3 in binary counting order, from 000 to 111. For each row, write the majority vote V. Then open the logic lab, build the vote from AND and OR gates, and check that the lab's truth table matches yours row by row. The lab's majority challenge accepts five gates; see whether you can do it with fewer by reusing a gate's output.
- 02
Add the emergency stop and start switch
Write a Boolean expression for RUN using V, E and S. Explain in one sentence why E needs a NOT. Then work out how many of the 32 rows of the full five-input truth table give RUN = 1. You do not need to write all 32 rows: reason from how many rows of the vote table are 1 and which values E and S must take.
- 03
Design the FAULT output
Write the truth table for FAULT over G1, G2 and G3, and count its 1 rows. Build FAULT in the lab using XOR and OR gates, and check that it is 0 only for 000 and 111. Explain why two XOR gates are enough, and why a third, G1 XOR G3, would add nothing.
- 04
Inject stuck-at faults
Imagine G1 is stuck at 1. For both real door states (open and shut), work out what the three sensors report, what V and RUN become (with E = 0 and S = 1) and whether FAULT is raised. Repeat for G1 stuck at 0. Then consider G1 and G2 both stuck at 1 while the door is open. Write down which failures the design survives, which it reports and which it misses.
- 05
Compare and reflect on the limits
Compare two correct versions of your vote circuit, for example the five-gate version and your shortest one. Which is easier for someone else to check against the written rule? Finally, list what the ideal lab ignores, such as propagation delay, glitches and switch bounce, and say which one you think matters most for this machine and why.
Your work
Everything above is free to read and use. To save drafts, submit versions and get feedback, sign in.
You can also work on paper: the prompts below are what a submission asks for.
- Majority-vote truth table and expression
- Rows of the 32-row table where RUN = 1
- Rows of the 8-row sensor table where FAULT = 1
- Fewest two-input AND and OR gates that make the majority vote
- Stuck-at fault analysis
- Comparison and limitations
How it's judged
There is more than one good answer. This rubric describes what strong work looks like.
Truth tables and expressions
- Beginning
- Truth tables are missing, incomplete or have several wrong rows.
- Developing
- Tables are complete but contain an error, or the expression does not match the table.
- Proficient
- Complete, correct tables for V, RUN and FAULT, each matched by an expression verified in the lab.
- Exemplary
- As Proficient, plus a shorter equivalent circuit is found and shown to have the same truth table.
Meeting the safety rule
- Beginning
- RUN can be 1 while E = 1 or S = 0, or ignores the vote.
- Developing
- RUN respects E and S but uses one sensor or an OR of sensors instead of a vote.
- Proficient
- RUN is 1 only when the vote, NOT E and S are all 1, with each condition explained.
- Exemplary
- As Proficient, plus the student explains why AND is the right way to join necessary conditions and what would go wrong with OR.
Fault analysis
- Beginning
- No stuck-at faults are analysed.
- Developing
- One fault is analysed, but the outcome for RUN or FAULT is wrong or missing.
- Proficient
- Stuck-at-1 and stuck-at-0 single faults are analysed correctly for both door states, and the double fault is identified as unsafe.
- Exemplary
- As Proficient, plus a reasoned suggestion for catching the double fault, with its own cost or limitation stated.
Honesty about limitations
- Beginning
- Claims the design would make a real machine safe.
- Developing
- Mentions limitations only in general terms.
- Proficient
- Names specific effects the ideal lab ignores and says which matters most here and why.
- Exemplary
- As Proficient, plus explains what a real design process would add, such as standards, certified parts and independent review.
Reflect
- Which failure surprised you most when you traced it through your circuit, and why?
- Why does the FAULT output make the system safer even though it never stops the arm itself?
- When is a slightly larger circuit a better choice than the smallest one?
Go further
Add a maintenance mode input M. When M = 1, the arm may move with the door open, but only at slow speed and only while a hold-to-run button H is held. Design outputs RUN_FAST and RUN_SLOW, write their truth tables, and explain which new failure your design must now guard against.