Truth Tables - Scientists for Tomorrow

 Introduction to Robotics Lesson 7 : Truth Tables Grade Level:​ 6-­8 Brief Description of Lesson: ​Participants will understand​ truth tables/logic ​and build corresponding circuits on the breadboard. Participants will be introduced to the ​breadboard​, ​resistors​, ​LEDs​, wire​, and ​wire strippers​. The instructor will guide participants through the development of ​truth tables​. Then, the symbolic representations contained in the truth tables will be made into drawings of circuits, and then participants will build physical circuits that correspond to the functions in the table/diagram. Circuits increase in complexity, incorporating functions such as “​and​” and “​or​”. IDENTIFY DESIRED RESULTS Essential Questions 1. What is logic? How logic can be implemented by electronic systems 2. What is a multi-­ meaning statement? and how do we reduce it to a binary statement? 3. How does a computer uses logic to solve problems? 4. What is the difference between the continuous and discrete world (infinity data versus discrete data)? Enduring Understandings 1. Any statement that can not be defined as true or false receives the name of multi meaning statement. 2. Any statement that can be precisely defined as true or false received the name of binary statement. Binary statements and logic functions can be translated in a symbolic language, independent of the meaning of the binary statements. This symbolic language allows the generation of generic algorithms that can be implemented by a generic hardware (e.g. a computer). 3. A switch is a device that can simulate a binary statement (open = false, close = true). Combination of switches generates an emulation of binary statements connected through logic functions. Then, the combination of multiple logic functions forms an algorithm. A computer is a system conformed by large number of switches that are arranged to implement a desired algorithm. 4. The variables in the physical world (continuous world) include infinity amount of data (e.g. between 1cm there are infinity points). Computers can not store infinity data, then the data need to be “sampled” meaning taking only part of the information making it “discrete”. Then these discrete data need to be converted in an array of binary statement (“1” and “0”) forming binary representation of the “discrete” data. Computers manipulate binary data to operate their designed algorithm. STANDARDS Next Generation Science Standards HS-­ETS1-­1. ​Analyze a major global challenge. ​Asking Questions and Defining Problems. ​Asking questions and defining problems in 9–12 builds on K–8 experiences and progresses to formulating, refining, and evaluating empirically testable questions and design problems using models and simulations. Analyze complex real-­world problems by specifying criteria and constraints for successful solutions to specify qualitative and quantitative criteria and constraints for solutions that account for societal needs and wants. CCSS Standards for English Language Arts Standards CCSS.ELA-­LITERACY.SL.8.1​ Engage effectively in a range of collaborative discussions (one-­on-­one, in groups, and instructor-­led) with diverse partners on grade 8 topics, texts, and issues, building on others' ideas and expressing their own clearly. CCSS.ELA-­LITERACY.L.8.6​ Acquire and use accurately grade-­appropriate general academic and domain-­specific words and phrases; gather vocabulary knowledge when considering a word or phrase important to comprehension or expression. CCSS Standard for ​CCSS.Math.Practice.MP2​ Reason abstractly and quantitatively. Mathematical Practice: KNOWLEDGE AND SKILLS Key Content Participants will know: Any statement that can be precisely defined as true or Knowledge and false received the name of binary statement. Skills 1. List of vocabulary terms: Logic, ​Participants will be able to: 1. To build circuits using the breadboard and understand some of the internal connections English Participants will know: Language 1. Vocabulary terms such as ​proposition, LED, switch, truth table, breadboard, Development open, closed, true, false. Knowledge and Skills (for Participants will be able to: starting, 1. Use these terms in discussion with their peers and instructors emerging, and 2. Describe the procedures of the activity on tutorials using the vocabulary developing ELLs) words in their own sentences with 90% accuracy. DETERMINE ACCEPTABLE EVIDENCE Pre-­requisite/Prior knowledge for Both Content and Language: 1. Understanding of Logic and Electricity Formative Assessment for Both Content and Language 1. Participant Product and/or Performance a. Participants will build circuits using breadboards and understand some of the internal connections. Other Forms of Assessment 1. The instructor will walk around and observe that participants are working together and appropriately while working on truth tables and circuits. Assessment Criteria 1. Participants will be able to define on/off closed/open and 1/0 with 100% accuracy 2. All activities must be done cooperatively. 3. Participants will be able to complete truth tables and circuits Summative Assessment 1. Participant Product and/or Performance (tests, worksheets, oral presentations, etc.) PLAN LEARNING EXPERIENCES Time Required for Segments Set/Hook Minutes 10 minutes Grouping Arrangements Whole Class Instructor Demonstration/Lecture 20 minutes Whole Class Guided/Independent Practice 55 minutes Small Groups Closure 05 minutes Whole Groups Total 90 minutes MATERIALS AND TECHNOLOGY Disposable Material -­
Wire Tools -­
-­
-­
-­
-­
-­
Breadboards 9V battery and connectors Switches Resistors LEDs Wire cutter/stripper Forms Pre-­Assessment/Consent Forms (Sp) /Attendance Sheets/Weekly Participant Surveys Instructor Preparation 1. Assemble materials, practice procedures beforehand, identify new vocabulary and organize workstations. 2. The instructor should arrive at the site 15-­30 minutes prior to the start of class. 3. The instructor will need to write definitions and diagrams on boards if available. 4. Watch video tutorials and lesson plans displayed in the SfT website 5. As participants arrive, instructor should take attendance so they can fully complete instructor log afterwards. Set/Hook (10 min) Explanation of what the material that we will use for the experiment is. The instructor will demonstrate how to use each of the materials 1. Breadboard (sometimes called Protoboard -­ ​Prototype board): a. The breadboard is a re-­usable electronic device that allows the participants to build circuits without any soldering. In order to use the breadboard, participants will have to understand some of the internal connections. Each hole in the breadboard has a clamp and the clamps are connected in different configurations in the breadboard (see picture below) b. +/-­ i.
On each side of the breadboard there are symbols for positive (+) and negative (-­). The breadboard is wired so that all of the holes in the positive (+) column are connected, and all of the holes in the negative (-­) column are connected. Generally these columns are used to connect a power supply to any of the devices connected in other holes in the breadboard. This enables the user to build circuits in the board and easily provide power and ground connection c. Rows 1-­30 i.
The rows are electrically connected. If current is provided to any hole in the row, then current will be available at all other holes in that row. The exception is that in the middle of the breadboard is a crevasse that separates the two sides. There is no electrical connection across the crevasse. This space between the rows is designed to facilitate the user to use standard integrated circuits d. More breadboard information at https://learn.sparkfun.com/tutorials/how-­to-­use-­a-­breadboar
d 2. LED a. LED stands for ​light emitting diode. The LED is a semiconductor that produces light when an electrical current is passed through it. The LEDs are directional, meaning electricity can only pass through them in one direction. Each LED has one long leg and one short leg. The long leg is anode (positive), the short leg is the cathode (negative). This is important to remember when building circuits. If the LED is connected incorrectly it will not light up. Also when the LED is connected in the right polarity (anode to the positive and cathode to the negative) there is nothing that will limit the current, therefore the LED will burn out. To avoid burning the LED it is necessary to connect a resistor in series. 3. Resistor a. The unit of resistance is OHM (Ώ) it is the relation between the voltage and the current. OHM (Ώ) =
V oltage(V )
Current(A)
The value of the resistor can be read from the device using the Color Code (see picture above). Each color represents a number from 0 to 9. The resistor has three bands with colors B1, B2 and B3. The value of the resistor can be obtained by replacing the color of the band by its number in the expression below Resistor Value = B1 B2 and 10B3
​ ​ zeroes Example: If a resistor has the following color bands B1 = red, B2 = violet and B3 = orange, so the value of the resistor is … Resistor Value = B1 B3 and 10B3
​ ​ zeroes = 2(red) 7(violet) 000 3​
(10​ Orange)= 27000 ohms Tolerance Value = The last band indicates how much percentage of the claimed resistance the true resistance could be off by 4. Wire and Stripper 5. SPDT Switch After briefly explaining all the materials above, go over the following concepts by drawing on the board or using a computer/projector Instructor Demonstration/Le
cture (20 min) Introduction to Logic 1. When learning to code (meaning writing a program or a set of instructions the computer will follow), it is important that participants have an understanding of logic. We can think of logic as ​a system or set of principles that will lead to provide a valid reasoning outcome to a given set of input premises. These inputs receive the name of ​“logic propositions”​, and the relation between multiple propositions (​logic operations​) will dictate the outcome of the situation. Both the logic propositions as well the outcome of the situation can have only two possible values: TRUE or FALSE. 2. To be able to apply a logic operation to propositions from real situations, first we will need to be able to convert any multi-­meaning proposition in a single-­meaning proposition that can have only two values, true or false. For example, the phrase a “​The girl is pretty” is a multi-­meaning proposition, has several meanings, as each person may have a different interpretation of ​pretty. In order to be a logic proposition the sentence need to be, without exceptions, be able to be assessed and have only two possible values: True or False. For example “​The girl has red hair.” This statement could be only true or it could be false, and therefore, it is a logic proposition. 3. After we understood that a logic proposition can have only two values, true or false, we need to find a real world device that can represent the state of the logic proposition. This physical device is: ​the switch​. The switch can have only two positions: open and close, therefore the switch can emulate the states of a logic proposition. Let’s say that we want to represent the proposition “​The girl has red hair” with a switch​. If the proposition is true, the switch will be close and if the proposition is false, the switch will be open. Proposition: the girl has red hair State of the proposition State of the switch True Close (generally called ON) False Open (generally called OFF) 4. An electronic device such as a computer is composed for a large number of switches. These switches, when turned ON and OFF in the correct combinations produce the outcomes we desire. Switches have only two possible values; ordinarily, we’d think of switches as either “on” or “off”, but for the purposes of this unit we will use ​“true” to mean “on” and “false” to mean “off”​. These values are represented symbolically with n​umber 1 for true, and 0 for false​. In other words, we can convert a single meaning sentence from our language (English in our case) into a symbolic expression, totally disconnected to the original meaning of the single meaning sentence and can be replaced by a “logic variable”. Single meaning sentence (logic proposition) Logic Variable State of the switch that represent the variable The girl has red hair A True 1 Close False 0 Open 5. Practice: ​have participants change multi-­meaning statements into single-­meaning, true/false statements. Multi-­Meaning Single Meaning The runner runs fast The runner runs faster than a turtle, the runner runs slower than Usain Bolt The car is cool The car is a corvette The teacher is tall The teacher is taller than a pencil, the teacher is shorter than the classroom. The girl is pretty The girl has brown hair 6. ​Given the fact that each logic variable (physical representation of a proposition) can be replaced by a switch, we can construct electrical systems that will be analogies of the real world meaning of the proposition. To symbolize the outcome of a logic variable or system we will use a lamp. If the variable value is true (switch ON = 1 logic), the lamp will be on. If the variable values is false (switch OFF = 0 logic) the lamp will be off. Variable A (switch) Output (lamp) False (switch open, OFF = 0 Logic) Lamp is off (0 Logic) True (Switch close, ON = 1 Logic) Lamp is on (1 Logic) Truth Tables 1. Many systems that use logic to define the relationship between the inputs (propositions emulated by switches) and outputs (something acting such as a lamp, a motor, etc) have more than one input. To ensure that we know the actions of the system for “ALL” the possible combination of values of the inputs we will explore systematically all these possible combinations. This is graphically shown through a truth table. A truth table shows in a systematic way, all the combination of the inputs, using logic 1 for true and logic 0 for false. All permutations of the inputs are listed on the left, and according to the logic operation or function between the inputs, the output or outputs of the circuit will be listed on the right. 2. The design of the truth table depends on the number of variables (commonly we use capital letters to symbolize variables such as A, B, C…) and the outputs (generally we use O​1, O
​2,.. to symbolize th
​e ​
​
outputs). 3. A table has columns and rows. The number of column will be the addition of the number of variables and the number of outputs. If the logic operation has three variables (A,B, and C) and two outputs (O​1, ​
O​2 ) then the truth table will have five columns (A, B, C, O
​1, O
​2 ). The ​
​
​
number of rows will be dictated by the number of possible permutations of the variables. Each variable has the possibility to have two values, 0 and 1. If we have only one variable, we will have only two possibilities 0, or 1, therefore we will have two rows. If we have two variables (A, B) , when the variable A has a value of 0, the variables B can have two values 0 and 1 [00 and 01] and when the variable A has the value of 1, the variables B can have two values 0 and 1 [10 and 11]. Therefore when we have two variables we will have four rows. Following the same procedures we can find that for three variables (A,B, C) we will have eight rows as shown in the figures below. Guided/ independent Practice (55 min) ​The logic function AND its Truth Table Let's build a truth table for a logic function known as “And.” In this logic function only when all the inputs are true (1 logic – or its equivalent of close switch) the output will be true (1 logic – or its equivalent of something working – e.g. the lamp is “on”). For this exercise we assume we have two variables: A and B. In this circuit, both switches must be closed (true) in order for the lamp to light. When constructing a truth table, the number of rows is determined using the equation Number of rows = 2n , where ​n is equal to the number of input variables . Our “AND” truth table has two variables , therefore will have four rows : Number of Rows = 22 so Number of Rows = 4 Below, is the same truth table filled in step by step in order to demonstrate the procedure of systematically filling in values of the variables into the truth table. a) In the column of the last variable on the right (in this case will be the column of the variable B) please fill this column alternating 0 and 1 – the two possible values of the variable – until complete the column b) Move one column to the left (in this case will be the column of the variable A) please fill this column alternating two rows of 0 and two rows of 1, until you complete the column c) If we have more variables (not in this case) the next step will be go to the next column to the left and fill it alternating four rows of 0 and four rows of 1 until complete the column d) If there are more variables, follow the same procedure but alternating 8, 16, 32, etc rows of 0 and rows of 1 until complete the column e) When the values of the variables is completed, you can proceed to fill the output(s) according to the definition of the logic system. In the case we are studying now – the AND function, the output will be 1 only when the two inputs are 1, else the output will be 0 Truth Table A (step a) A B OUT 0 1 0 1 Truth Table A (step b) A B OUT 0 0 0 1 1 0 1 1 Truth Table A (step c) A B OUT 0 0 0 0 1 0 1 0 0 1 1 1 Note: ​Demonstrate to participants that a pattern emerges in the way the 0s and 1s are added to the truth tables. In Truth Table A we only consider what the Variable B does. It can be set to 0 or 1. Then we begin determining the possibilities for Variable A, as in Truth Table B. The values of the Variable A also can be set to 0 or 1 but need to produce a different combination between A and B. In Truth Table C, the outputs are determined following the logic function between the variables. Building the Electric Circuit! Until now we discussed about logic, and how to make decision based on external inputs. To facilitate the process, we transformed any external input into a proposition that has two values -­ True and False, and decide the outcome of the logic function based in the states of the input propositions using a symbolic language of variables A, B, and outcomes O1, O2,... Now is time to convert this symbolic languages into a physical system, such as, an electric circuit. As explained before, the propositions (Variables) will be emulated by a switch (open = 0, close = 1) and the outcomes will be emulate by an LED (off = 0, on = 1). Below is the truth table of the variable A and below, the implementation of an electrical circuit that emulate the logic function A = O A O 0 0 1 1 The electric circuit of the logic function AND As we discussed before the logic function AND will give a logic outcome True (1) only if the value of all the propositions are True (1). In symbolic language: A [AND] B will be true only if A is true [AND] B is true Following the definition of the relation between the state of the variable and the state of the switch, only when switch A is closed (1) [AND] switch B is closed (1), then the Outcome 0 will be one (1). An electric circuit that emulates this behaviour is a series circuit as shown in the picture below. We can implement the series circuit using the breadboard, two switches to emulate the Variables A and B, and one LED (and its attached resistance) to emulate the outcome of the logic function. Note: any technological system needs energy to work, therefore we will need to add the battery to provide energy to the emulation circuit, and the resistance R is necessary to limit the current through the LED. For the use in this class we will define that the LED and the Resistor together are the emulation of the Outcome (on = 1, off = 0) S1 S2 L1 (OUT) Activity: 1. Provide participants with: LED, battery, resistor, two switches, breadboard, red wire and wire strippers. 2. Instruct participants to build the AND circuit on their breadboards 3. Ask participant to draw the truth table of the logic function AND 4. Instruct participants to manipulate the switches to every permutation possible and record the outputs in a blank true table Afterward: Discuss, participants should report which combinations of 0/1 or true/false cause the LED to light up. Is the series circuit a good emulation of the logic function AND? How you can implement the AND logic function with three variables (ask the participants to build a truth table with three variables, then give them a third switch and let them try). Note: connecting three switches in series will emulate the function A [AND] B [AND] C then Outcome – If A, B and C are (1) then Outcome will be (1) The Logic Function OR and its Truth Table In the same way we learned about the logic function AND we will learn about another important logic function, the logic function OR. For this logic function will be enough that one of the propositions will be true, then the outcome of the function will be true. If we have the following function A [OR] B then the Outcome will be true when: A is true, B is true or A and B are true Based in the definition of the [OR] logic function, ask to the participants to draw the truth table of the [OR] logic function, and how they think we need to connect the switches in a different type of circuit that will emulate the [OR] logic function, (participants may recognize this as a parallel circuit as shown below). Truth Table (step a) A B OUT 0 1 0 1 Truth Table (step b) A B OUT 0 0 0 1 1 0 1 1 Truth Table (step c) A B OUT 0 0 0 0 1 1 1 0 1 1 1 1 Building the Circuit! S3 S4 L2 (OUT) Activity: a) Provide participants with: LED, battery, resistor, two switches, breadboard, red wire and wire strippers. b) Instruct participants to build the OR circuit on their breadboards c) Ask participants to draw the truth table of the logic function OR. d) Instruct participants to manipulate the switches to every permutation possible and record the outputs in a blank truth table The logic function NOT and its truth table We discussed two important logic functions: AND and OR, and tested their implementation using switches to emulate their function using electrical circuits. The last of the basic logic function is the NOT function. By definition, the NOT function will take as an input the state of the variable A (e.g. true) and give in its outcome the opposite state (e.g. false) and vice-­versa. Generally the NOT function is symbolized by a line above the name of the Variable -­ NOT A = Ā. See below the truth table of the NOT logic function. Logic Function NOT A Ā 0 1 1 0 The NOT function can not be implemented using simple switches. In electronic circuits, the NOT function is implemented using another electronic component called a ​transistor​. Transistors are semiconductors made of silicon that can function as microscopic switches. This property allowed engineers to design and make logic circuits using a large number of switches in a very small space. This property called integration and allowed the development of Integrated Circuits (IC) that led to the production of all the modern electronic devices like computer. See appendix “logic circuits with transistor” for further investigations. The OR/AND Logic Truth Table We explored the logic functions AND and OR, their truth tables and their emulation using electrical switches. Now let's’ explore how we can combine different logic functions to obtain a desired outcome. Let’s analyze the following sentence: “if I am tall or I am fast, and there is a place in the team, I will be in the team.” We can identify three propositions: I am tall, I am fast, and there is a place in the team. Let’s replace each proposition by a Variable: I am tall will be the variable A, I am fast, the variable B, and there is a place in the team C. We will define the outcome I will be in the team as the outcome O. Let’s now replace these variables in the initial sentence. (A [OR] B) [AND] C then O Then we can see that we have three variables, one outcome, and logic operations between them to define the state of the outcome. Now we will build a truth table and an electrical emulation that will represent the logic function presented above. This logic function has three variables ( therefore will require three switches). Remember that to build the truth table, the number of rows in the truth table can be determined as follows Number of Rows = 2n , where n= number of variables (switches). A B C O 0 1 0 1 0 1 0 1 A B C D 0 1 0 1 0 1 0 1 A B C D 0 1 0 1 0 1 0 1 A B C D 0 1 0 1 0 1 0 1 Through a systematic approach, first filling in the possibilities for S7, then S6, and finally S5, we have exhausted all possible combinations of switches and determined their corresponding outputs. Building the Circuit! S5 S6 S7 L3 (OUT) Instruct participants to build the circuit and provide them with the blank truth table. Participants should test all combination of switches and fill in the truth table in the same orderly fashion that we followed in creating it. Participants share the combination of switches that caused the LED to light Extension 1: Challenge participants to create an AND circuit using three switches and create the corresponding truth table. Extension 2: Challenge participants to create an AND/OR logic table with more than three switches and create its corresponding truth table. Closure (5 min) 1. Reinforce the idea that a computer or electronic device can understand only true or false statements. All permutations or combination of variables can be determined systematically through the use of patterns, mathematics, and truth tables. Truth tables are a great way to synthesize data. Symbolic representation (0/1 for false/true) is often used in science and engineering. A truth table is a model that systematically and symbolically represents phenomena. 2. Pass out weekly​ ​survey​ that will be done each week. 3. Give participants a preview of what participants will be doing the following week as to keep them engaged and coming back. 4. The Instructor will submit the weekly Activity Journal at the end of every class located at​ ​www.scientistsfortomorrow.org/logs