Using Truth Tables to Solve Logic Problems

Summary

Students will use two-, three-, or four-input truth tables to solve logic problems.  This lesson assumes that the students know how to implement logic solutions to digital logic gates (engineering) or software (computer science).

Pre-Reqs

Students will know how to implement logic solutions to digital logic gates (engineering) or software (computer science).  Potential solutions include the following:

Digital Logic Gates

Students will have a basic understanding of digital logic gates (ANDs, ORs, and Inverters).  Solutions to simple problems can be implemented using littleBits (littlebits.com) or Snap Circuit Kits (www.elenco.com/brand/snap-circuits/).  More complicated solutions can be implemented using semi-conductors, breadboards, and wires.

Software

Students will have a basic understanding of a computer software.  Solutions to simple problems can be implemented using block-based languages such as Scratch (scratch.mit.edu/) or AppInventor (ai2.appinventor.mit.edu).  Solutions can also be implemented using littleBits Code Kit (littlebits.com/pages/code-kit-download) that would be used with littleBits.  More complicates solutions can be implemented using text-based languages such as Python or Java.  Text-based solutions should be implemented in an Integrated Development Environment such as jGRASP (www.jgrasp.org/) for Python, Java, or other languages and BlueJ (www.bluej.org/) for Java.

Procedure

1) Present the attached lesson on Truth Tables

Download: Solving_Logic_Problems_using_Truth_Tables.pdf

Consider enlarging the font size on the presentation for easier access.

Provide practice for students throughout the presentation.

Embed questions and feedback through out presentation.

Download: Solving_Logic_Problems_using_Truth_Tables_1_WwZ3MG0.pptx

PPT has larger font for more accessible viewing.


Slide

Explanation

1

Title Slide for the presentation

2

Index of the presentation

3

Definition of logic problem

4

The definition of 0/1 is dependent on the particular input sensor.  The burglar alarm is 0 when it is turned off or disengaged and 1 when it is turned on or engaged.  Window or door sensors are electronic switches which are 1 when the window or door is closed and 0 when they are open.  A motion detector is 1 when motion is detected and 0 when it is not detected.

The definition of 0/1 is dependent on the particular output device, though most devices are 1 when they are on and 0 when they are off.

5

The user needs to count the number of inputs and use the truth table for that number of inputs.  The example on slide 4 uses three inputs, so you would use a three-input truth table.

6

The inputs of the truth table have already been entered.  By convention, the numbers “count” in binary from all zeros to all ones.  The easiest way to visualize this is that the last bit (Z in this case) is the least significant bit and it changes from 0 to 1 and then repeats.  The next bit (Y in this case) counts each number twice before changing to the next number (0, 0, 1, 1).  The final bit (X in this case) is the most significant bit and it counts each number four times before changing to the next number (0, 0, 0, 0, 1, 1, 1, 1).  If there is a fourth bit to the left of the X, then it would count each number eight times before changing.

The outputs are entered based on what the expected output is for the given input combination.  In this case, if the burglar alarm is turned off, the output would be off, so the first four combinations have an output of 0.  For the fifth combination, the burglar alarm is turned on and the window is 0, or open, so the alarm will sound.  For the sixth combination, the burglar alarm is turned on, the window is open, and motion is detected, so the alarm will sound.  For the seventh combination, the burglar alarm is turned on, but the window is closed and no motion is detected, so the alarm will not sound.  For the eighth and final combination, the burglar alarm is turned on and motion is detected, so the alarm will sound.

7

Document the solution by noting where the output is 1.  You write down each min-term by noting what state each input is in.  If the input is 0, then you write the name of the input (X, Y, or Z in this case) and put a line over the individual letter.  This indicates that the output will be a 1 when this input is a 0 (and the other inputs are the corresponding states).  So the first min-term is  (note that there are separate lines over the Y and the Z.  This has to do with order of operations, which is beyond the scope of this lesson).  Each of the min-terms are OR’ed together with plus signs (the three min-terms combine to form the solution ).

8

It is possible to simplify the solution (some students might recognize the simplified solution is )).  There are two ways to simplify logic expressions, Boolean Algebra and Karnaugh maps.  Both are beyond the scope of this lesson, so we will continue to use the unsimplified expression.

9

There are two ways to test the solution; using hardware or using software.  There are several methods of testing the hardware, but two fairly easy methods are to use littleBits or Snap Circuit Kits.  This slide demonstrates how to implement the inverters.  The inputs that have a line over them (refer back to slide 7) have to be inverted first.  Take the output of the sensor and connect it to the input of the inverter.  The output of the inverter will be the inverted signal.

10

The next thing to do is to combine the inputs to form the min-term.  In this example, there are three inputs, so each min-term will require two AND gates.  Connect the output of two of the sensors (or the sensor’s inverter if they were inverted in slide 9) and connect them to one of the AND gate’s inputs.  One sensor connects to one input and the other sensor connects to the other input.  Connect the output of the first AND gate to one of the inputs of the second AND gate and connect the third sensor to the remaining input of the second AND gate.  Note that if you only have two sensors/inputs, you only need one AND gate; connect one sensor to one input and the other sensor to the other input.  If you have four sensors/inputs, then you will need three AND gates.  Connect two sensors to the first AND gate, two sensors to the second AND gate and then connect the outputs of the two AND gates to the inputs of the third AND gate.

11

Finally connect all of the min-terms using OR gates.  In this example there are three min-terms, so two min-terms (the outputs of their respective AND gates) are connected to one OR gate, and the third min-term and the output of the first OR gate is connected to the second OR gate.  The solution is the output of the second OR gate and is connected to the output device (an alarm in this example).

12

The second way to test the solution is to use software.  There are several methods of testing the software, but two fairly easy methods are to use the littleBits Code Kit or Scratch.  In both cases you need to create variables to represent the sensor inputs.  With the littleBits code kit, you can use the variable to read the output of the sensor.  With Scratch, the user will have to enter the value of the sensor.

13

Just like in the hardware (slide 9), some sensor inputs have to be inverted first.  This can be done using the NOT command.

14

To form the min-terms, using the AND command.  The first AND command combines the first two inputs and the second AND command combines the output of the first AND command and the remaining input.

15

To form the final solution, use the OR command to combine the min-terms.  In this case, the first OR command combines the first two min-terms and the second OR command combines the output of the first OR command and the remaining min-term.

2) Demonstrate solving a logic problem using this process and test the solution using either hardware or software, depending on what is available in your classroom.  Blank two-, three-, and four-input truth tables are attached.

Download: Truth_Tables.pdf

Consider enlarging the size of the tables for easier accessibility.  Allow students to work with peers as they begin to solve problems.

3) Complete on problem as guided practice, then assign one or more problems below or others that you create for independent practice, with feedback.

a. Fire/Smoke Detector – sound an alarm when the detector senses fire or smoke.  Use a temperature sensor to detect heat and a light and light sensor to detect smoke.

Download: Fire-Smoke_Detector.pdf

b. Ventilation Fan – A fan has two settings (On or Automatic).  Turn on the fan when the fan is on automatic and it is hot or when the fan is on.  Use a switch to control the fan and use a temperature sensor to detect temperature.

Download: Ventilation_Fan.pdf


Download: Solving_Logic_Problems_using_Truth_Tables_1.pptx


Return to top