The answersDownload the PDF
Worksheet

A8.9 Project: the robot's safety logic

Boolean algebra and logic circuits · A level · OCR H446 1.4.3, AQA 7517 4.6.4.1, Eduqas A500QS 1.2 · about 30 min

BugBotLab
NameClassDate

What this lesson is about

From a rule table to a Karnaugh map, a simplified expression, a proof and a robot that stops for the right reasons.

Questions 5 marks in all

  1. [1 mark]A rule has four inputs. How many rows does its truth table have?

  2. [1 mark]With rows numbered 8C + 4K + 2L + D, which row number is C = 1, K = 0, L = 1, D = 1?

  3. [1 mark]Put the stages of designing a logic rule in order.

    Number the lines 1 to 6 to put them in the right order.

    1. Write the simplified expression
    2. Draw the circuit or write the code
    3. Write the truth table
    4. Name each input with a letter
    5. Check it against the truth table
    6. Draw the Karnaugh map and group the 1s
  4. [1 mark]Two groups on a map give (¬K ∧ D) ∨ (¬K ∧ ¬C ∧ ¬L). Which law turns this into ¬K ∧ (D ∨ (¬C ∧ ¬L))?

    1. ADistribution
    2. BDe Morgan's law
    3. CDouble negation
    4. DCommutation
  5. [1 mark]Which expression is equal to ¬C ∧ ¬L?

    1. A¬(C ∨ L)
    2. B¬(C ∧ L)
    3. CC ∨ L
    4. D¬C ∨ ¬L

The task: the robot's safety logic

The starter gives GO_ROWS, the truth table rows (numbered 8C + 4K + 2L + D) where G = 1, and draft(c, k, l, d), which takes four bits and returns 1 on those rows and 0 otherwise. 1. Write go(c, k, l, d), taking four bits, as a single return line using at most six of and, or and not in total. It may not use GO_ROWS or call draft. Any true result means drive. 2. Check go against draft on all sixteen combinations, treating a true result as 1 and a false one as 0, and print matches: True if they agree on every one, or matches: False if not. 3. Drive the robot. Set docking = 0. In a loop, read close (1 if distance() is under 20, else 0), hit (1 if bumped(), else 0) and low (1 if battery() is under 20, else 0), and call go(close, hit, low, docking). While it is true, drive forward. When it is false, stop, print one line in exactly the form stopped: C=1 K=0 L=0 D=0 using the values that stopped it, and end the loop. The robot must finish in the band before the wall without touching it.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

GO_ROWS = [0, 1, 3, 9, 11]

def draft(c, k, l, d):
    return 1 if 8 * c + 4 * k + 2 * l + d in GO_ROWS else 0

def go(c, k, l, d):
    return 0

Plan your program here, then type it in and press Run.

QR code
Do it on the robot
www.bugbotlab.com/learn/a8-9-project-safety-logic/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Draw the circuit for your go expression using AND, OR and NOT gates. How many gates does it need, compared with the sum of products?
  2. Redraw it using only NAND gates.
  3. The safety officer adds a sixth case: docking with a low battery and something knocked, but nothing close, is allowed. Add the row, redo the map, and find the new simplest expression.