Difference between revisions of "Introduction to Digital Logic"

From EG1004 Lab Manual
Jump to: navigation, search
(35 intermediate revisions by 5 users not shown)
Line 1: Line 1:
= Objective =
= Objective =
 
The objective of this lab is to use digital logic to design a combinational logic circuit for an alarm system and to build and test the system using prototyping components.
The objective of this lab is to use LabVIEW and digital logic to design a heating and cooling system and an alarm system, and to test both systems on the NI-ELVIS II+ prototyping board. Building these systems will demonstrate the potential for using simulated instruments in a laboratory. These programs will also obtain data from outside the computer and incorporate it into a program design. The lab will be divided into two parts. Both parts of the lab focus on creating a solution for the assigned problem statement.


= Overview =
= Overview =
== LabVIEW ==
The <b>Laboratory Virtual Instrument Engineering Workbench (LabVIEW)</b> is a development environment designed by National Instruments that creates graphics-based programs called virtual instruments (VI) that simulate actual laboratory instruments. A VI consists of two parts: a front panel and a back panel (Figure 1). The <b>front panel</b> allows the user to interact with the VI by displaying outputs and allows the user to supply the program with inputs. The <b>back panel</b> consists of the code used by the VI to obtain inputs from the front panel, operates on the inputs, and displays the results.
[[Image:LabVIEW_Panels.jpg|500px|thumb|center|Figure 1: Front Panel (Left) and Back Panel (Right)]]
The front panel is built using controls and indicators. <b>Controls</b> are inputs that allow a user to supply information to the VI. <b>Indicators</b> are outputs that display the results based on the inputs given to the VI. Controls can be switches, knobs, dials, and buttons. Indicators can be meters, gauges, LEDs, and displays. These are located on the <b>Controls palette</b> and are placed on the front panel (Figure 2).
[[Image:Controls_Palette.jpg|300px|thumb|center|Figure 2: Controls Palette]]
The back panel, which is also known as the block diagram, contains the graphics-based source code. The environment of the back panel is built using the <b>Tools palette</b> (Figure 3).
[[Image:Tools_Palette.jpg|150px|thumb|center|Figure 3: Tools Palette]]
In Figure 3, only the icons in colored boxes will be used in this experiment. The <span style="color:red;"> '''operating tool'''</span> changes the value of a control. The <span style="color:gold;"> '''positioning tool'''</span> positions, resizes, and selects objects. The <span style="color:green;"> '''labeling tool'''</span> is used to create and edit all labels in the VI, such as the name of a Boolean control. The <span style="color:blue;"> '''wiring tool''' </span> wires objects together on the back panel. The <span style="color:purple;"> '''scrolling tool''' </span> allows scrolling the window by clicking and dragging.
All of the objects placed on the front panel will appear on the back panel as terminals. <b>Terminals</b> are basically entry and exit ports. They exchange information between the front panel and block diagram and appear with small triangles in the icons to indicate that they can be used to process information (Figure 4). A control terminal has the triangle to the right to indicate that it sends data to be processed. An indicator terminal has the triangle to the left to indicate that it receives data.
[[Image:Terminals.jpg|600px|thumb|center|Figure 4: Control and Indicator Terminals]]
The back panel also contains structures and functions that perform operations on controls and supply data to indicators. Structures and functions are found on the <b>Functions palette</b> and are placed on the back panel (Figure 5).
[[Image:Functions_Palette.jpg|300px|thumb|center|Figure 5: Functions Palette]]
<b>Structures</b> are process control elements, such as while loops and for loops. The structure to be used in this experiment is the <b>case structure</b> (Figure 6), which is essentially multiple if-statements. A case structure contains multiple sub-diagrams (or cases), and a case will be executed depending on the input to the case structure.
[[Image:Case_Structure.jpg|500px|thumb|center|Figure 6: Case Structure]]
In Figure 6, Item 1 is the <b>selector label</b> that displays the input value that the associated case will execute. The black arrows on the side of the selector label toggle between the different cases. Item 2 is the <b>area for the code</b> that executes the specific input in the selector label. When the selector label is toggled, the code in this area will also change. Item 3 is the <b>case selector</b>, which gives the input value to the case structure. The data type that is wired to the case selector that will determine the possible cases. For example, if a Boolean data type is wired to the case selector, the possible cases will only be true and false.
<b>Functions</b> are the fundamental operating elements of LabVIEW and have input and output terminals to pass data in and out. They are indicated by a pale yellow background in the icon (Figure 7).
[[Image:Functions_Examples.jpg|300px|thumb|center|Figure 7: Examples of Functions]]
Functions have a certain number of inputs and outputs, depending on the type of function. For example, the addition function (leftmost icon in Figure 7) has two inputs as it will add the two inputs together, and it will have one output that is the sum of the inputs. The inputs are wired to the left side of the function, and the outputs are wired to the right side of the function. The number of inputs and outputs of a function can be observed by hovering over the icon with the wiring tool and observing the terminals that appear (Figure 8).
[[Image:Function_Terminals.jpg|150px|thumb|center|Figure 8: Function Terminals]]
Collectively, controls, indicators, structures, and functions are referred to as nodes. <b>Nodes</b> are connected to one another using the wiring tool. For example, two controls and an indicator can be wired to the addition function so that the indicator displays the sum of the two controls (Figure 9). Notice how the two controls have the triangle on the right, and the indicator has the triangle on the left.
[[Image:Wiring_Nodes.jpg|300px|thumb|center|Figure 9: Wiring Nodes]]
The <b>toolbar</b> at the top of the front panel is used to execute and stop the program (Figure 10). The <b>run tool</b> (white arrow) runs the program once. The <b>run continuously tool</b> (two white arrows in a circle) keeps the program running continuously until the program is paused or stopped. This tool should be used when executing programs in this experiment. The <b>abort execution tool</b> (red stop sign) stops the VI immediately. The <b>pause button</b> (two vertical black rectangles) pauses the program and can be clicked again to continue the program.
[[Image:ToolBar.jpg|300px|thumb|center|Figure 10: Toolbar]]
== NI ELVIS II+ Board ==
<b>National Instruments' Educational Laboratory Virtual Instrumentation Suite (NI ELVIS II+) board</b> (Figure 11) is one solution LabVIEW can utilize to physically interface with external devices. It is a modular engineering device that includes a breadboard, power supply, ground, thermocouple, oscilloscope, function analyzer, and other common lab instruments. In this experiment, an NI ELVIS board II+ will be used to provide inputs and display outputs for the VIs that will be created.  Here is a tutorial video on NI ELVIS boards II+.
[[Image:NI_Elvis.jpg|500px|thumb|center|Figure 11: NI ELVIS II+ Board]]


== Digital Logic ==  
== Digital Logic ==  
Line 93: Line 40:
|}
|}
</center>
</center>
=== Boolean Equations ===
A truth table is used to write a <b>Boolean equation</b> for a problem. All the combinations that yield an output of 1 are kept, and the equation is written. This is called a Sum of Products solution. Only the combinations that yield an output of 1 are kept because the Boolean equation intends to represent a quantitative function when the output will be true (when a fee is charged in the example of the ATM machine). The combinations that yield an output of 0 are discarded because there is no interest in when the result has a false value. The Boolean equation for the ATM example can be seen in Figure 13.
<center><math>C = \overline{P} W \overline{D} + \overline{P} W D + P \overline{W}\,\overline{D} + P W \overline{D} + P W D\,</math><br>
Figure 13: Boolean Equation</center><br>
For each of the combinations (rows) resulting in true in Table 1, the terms of the Boolean equation are determined by multiplying the variables together (the AND operation). If an input is true, the variable can be used as-is; for an input that is false, the variable is inverted using the horizontal bar (the NOT operation). Since the output is true if any of the combinations are true, the equation is formed by using addition operations (the OR operation) on all the terms formed by the product of each combination.
=== Karnaugh Maps (K-Maps) ===
A truth table showing every combination of inputs and their corresponding outputs yields a Boolean equation that is the solution to a problem in digital logic. This equation can be simplified using a <b> Karnaugh map (K-map)</b>. A K-map identifies and eliminates all the conditions that do not contribute to the solution. The resulting simplified Boolean equation is used to build the digital circuit and will be a combination of the logic gates described earlier.
A K-map is a two-dimensional representation of the truth table that shows the common characteristics of the inputs. For an equation with three inputs, usually all the combinations of the first two inputs are shown as four columns and the values for the third input are shown as two rows. For four inputs, all the combinations of the third and fourth inputs are shown as four rows. Only one value can change at a time in adjacent rows or columns. For example, in Table 5, the columns change from 00 to 01 to 11 to 10. Table 5 illustrates the K-map for the ATM example.
<center> Table 5: K-Map for the ATM Example
{| class="kmap"
|-
!!!!!0 0!!0 1!!1 1!!1 0
|-
!!!!!<math>\overline{P} \, \overline{W}\,</math>!!<math>\overline{P} W</math>!!<math>P W\,</math>!!<math>P \overline{W}</math>
|-
!0!!<math>\overline{D}\,</math>
|0||1||1||1
|-
!1!!<math>D\,</math>
|0||1||1||0
|-
|}
</center>
=== Simplified Boolean Equations ===
To develop the <b>simplified Boolean equation</b>, look for the cells that have the 1 value in common. Look for cells that can physically be boxed together, where the number of cells in the box is a power of 2 (1, 2, 4, or 8 and so on). The boxes are allowed to overlap so the same cells can be used more than once. Look for the biggest boxes first, and keep finding smaller boxes until all the cells with a 1 in them are used. This means that sometimes just single cells will remain at the end. The cells in the K-map for the ATM example can be grouped like what is shown in Table 6.
<center>Table 6: K-Map Boxes for the ATM Example</center><br>
[[Image:Kmap_Boxes.gif|250px|center]]
In this example, all the cells containing a 1 were covered with two boxes. This means that if the conditions for either box are true, the output will be true. This also means that the simplified Boolean equation will only have two terms. The term for each box can be determined by observing which variables are constant throughout each cell of that box. For the red box, only W remains constant through the four cells. D switches from the top row to the bottom row, and P switches from the left column to the right column. For the blue box, P and remains constant through the two cells, while W switches from the left cell to the right cell. The two boxes yield the simplified Boolean equation shown in Figure 14.
<center><math>C = W + P\overline{D}\,</math></center>
<center>Figure 14: Simplified Boolean Equation for the ATM Example</center><br>
This equation meets the conditions in the truth table in Table 1 and achieves the desired result with the minimum number of logic elements.


=== Logic Gates ===
=== Logic Gates ===
Line 98: Line 91:
Boolean logic is applied to digital circuitry through the use of simple <b>logic gates</b>. There are symbols for each of these gates, and the connections between them are represented by lines running from the output of one gate to the input of another. A line can connect only one output to each input. There are seven gates: the NOT, AND, OR, NAND, NOR, XOR, and XNOR gates. Only the first three will be used in this lab (Figure 12).
Boolean logic is applied to digital circuitry through the use of simple <b>logic gates</b>. There are symbols for each of these gates, and the connections between them are represented by lines running from the output of one gate to the input of another. A line can connect only one output to each input. There are seven gates: the NOT, AND, OR, NAND, NOR, XOR, and XNOR gates. Only the first three will be used in this lab (Figure 12).


[[Image:LogicGates.jpg|500px|thumb|center|Figure 12: Logic Gate Symbols]]
[[Image:ICchips.jpg|500px|thumb|center|Figure 1: Logic Gate Symbols]]


The <b>NOT gate</b> is the simplest of the three. It is an inverter. It has one input and produces its opposite as the output. For example, if a 1 is the input to a NOT gate, a 0 value is outputted, as seen in Table 2. The symbol for the operation is a horizontal bar over the variable. The truth table for a NOT gate is shown in Table 2.
The <b>NOT gate</b> is the simplest of the three. It is an inverter. It has one input and produces its opposite as the output. For example, if a 1 is the input to a NOT gate, a 0 value is outputted, as seen in Table 2. The symbol for the operation is a horizontal bar over the variable. The truth table for a NOT gate is shown in Table 2.
Line 150: Line 143:
</center>
</center>


=== Boolean Equations ===


A truth table is used to write a <b>Boolean equation</b> for a problem. All the combinations that yield an output of 1 are kept, and the equation is written. This is called a Sum of Products solution. Only the combinations that yield an output of 1 are kept because the Boolean equation intends to represent a quantitative function when the output will be true (when a fee is charged in the example of the ATM machine). The combinations that yield an output of 0 are discarded because there is no interest in when the result has a false value. The Boolean equation for the ATM example can be seen in Figure 13.
=== Combinational Logic Circuits ===


<center><math>C = \overline{P} W \overline{D} + \overline{P} W D + P \overline{W}\,\overline{D} + P W \overline{D} + P W D\,</math><br>
Lastly, a <b>combinational logic circuit</b> can be created using the simplified equation. First, a NOT operation is performed on D by inputting and outputting D through a NOT gate. Then, the P and inverted D are inputted into an AND gate, as denoted by them being multiplied in figure 14. Finally, the result of the AND operation between the P and inverted D and the W is inputted into an OR gate, as denoted by the addition function in figure 14. The final combinational logic circuit can be seen in Figure 15.
Figure 13: Boolean Equation</center><br>


For each of the combinations (rows) resulting in true in Table 1, the terms of the Boolean equation are determined by multiplying the variables together (the AND operation). If an input is true, the variable can be used as-is; for an input that is false, the variable is inverted using the horizontal bar (the NOT operation). Since the output is true if any of the combinations are true, the equation is formed by using addition operations (the OR operation) on all the terms formed by the product of each combination.
[[Image:CombinationalCircuit.jpg|500px|thumb|center|Figure 2: Combinational Logic Circuit for ATM Example]]


=== Karnaugh Maps (K-Maps) ===
=== Integrated Circuits ===


A truth table showing every combination of inputs and their corresponding outputs yields a Boolean equation that is the solution to a problem in digital logic. This equation can be simplified using a <b> Karnaugh map (K-map)</b>. A K-map identifies and eliminates all the conditions that do not contribute to the solution. The resulting simplified Boolean equation is used to build the digital circuit and will be a combination of the logic gates described earlier.
<b>Integrated circuits (IC)</b> can be used to prototype a combinational logic circuit on a breadboard. These devices are small assemblies of electronic components that have been combined into a single unit. In this lab, the IC chips consist of logic gates that can be wired to prototype the logic circuit (Figure 3).  


A K-map is a two-dimensional representation of the truth table that shows the common characteristics of the inputs. For an equation with three inputs, usually all the combinations of the first two inputs are shown as four columns and the values for the third input are shown as two rows. For four inputs, all the combinations of the third and fourth inputs are shown as four rows. Only one value can change at a time in adjacent rows or columns. For example, in Table 5, the columns change from 00 to 01 to 11 to 10. Table 5 illustrates the K-map for the ATM example.
[[Image:Lab_ICChip.jpg|500px|thumb|center|Figure 3: An IC Chip]]


<center> Table 5: K-Map for the ATM Example
Each chip consists of multiple logic gates. A 7408 chip consists of four AND gates, a 7432 chip consists of four OR gates, and a 7404 chip consists of six NOT gates. These gates can be wired to inputs and outputs to create a combinational logic circuit. The IC chips must also be connected to a power source and ground to operate.
{| class="kmap"
|-
!!!!!0 0!!0 1!!1 1!!1 0
|-
!!!!!<math>\overline{P} \, \overline{W}\,</math>!!<math>\overline{P} W</math>!!<math>P W\,</math>!!<math>P \overline{W}</math>
|-
!0!!<math>\overline{D}\,</math>
|0||1||1||1
|-
!1!!<math>D\,</math>
|0||1||1||0
|-
|}
</center>


=== Simplified Boolean Equations ===
Figure 4 shows how the IC chips can be used to wire the circuit for the ATM problem. In this circuit in Tinkercad, a piezo buzzer represents the output. Slide switches control the Print, Withdraw, and Deposit inputs. The pink wire represents the Print (P) input, the blue wire represents the Withdraw (W) input, and the yellow wire represents the Deposit (D) inputs.
 
To develop the <b>simplified Boolean equation</b>, look for the cells that have the 1 value in common. Look for cells that can physically be boxed together, where the number of cells in the box is a power of 2 (1, 2, 4, or 8 and so on). The boxes are allowed to overlap so the same cells can be used more than once. Look for the biggest boxes first, and keep finding smaller boxes until all the cells with a 1 in them are used. This means that sometimes just single cells will remain at the end. The cells in the K-map for the ATM example can be grouped like what is shown in Table 6.
 
<center>Table 6: K-Map Boxes for the ATM Example</center><br>
[[Image:Kmap_Boxes.gif|250px|center]]


[[Image:Lab_ICBreadboard.jpg|500px|thumb|center|Figure 4: The ATM Problem Prototyped on a Breadboard using IC Chips]]


In this example, all the cells containing a 1 were covered with two boxes. This means that if the conditions for either box are true, the output will be true. This also means that the simplified Boolean equation will only have two terms. The term for each box can be determined by observing which variables are constant throughout each cell of that box. For the red box, only W remains constant through the four cells. D switches from the top row to the bottom row, and P switches from the left column to the right column. For the blue box, P and remains constant through the two cells, while W switches from the left cell to the right cell. The two boxes yield the simplified Boolean equation shown in Figure 14.
The <math>D</math> input is wired to a NOT gate (Chip 7404) to get a <math>\overline{D}</math> output. This is wired to an AND gate input (Chip 7408), along with a <math>P</math> input to get a <math>P\overline{D}</math> output. This output is wired to an OR gate (Chip 7432), along with a W input to get the final output of <math>W+ P\overline{D}</math>.
 
<center><math>C = W + P\overline{D}\,</math></center>
<center>Figure 14: Simplified Boolean Equation for the ATM Example</center><br>
 
This equation meets the conditions in the truth table in Table 1 and achieves the desired result with the minimum number of logic elements.
 
=== Combinational Logic Circuits ===
 
Lastly, a <b>combinational logic circuit</b> can be created using the simplified equation. First, a NOT operation is performed on D by inputting and outputting D through a NOT gate. Then, the P and inverted D are inputted into an AND gate, as denoted by them being multiplied in figure 14. Finally, the result of the AND operation between the P and inverted D and the W is inputted into an OR gate, as denoted by the addition function in figure 14. The final combinational logic circuit can be seen in Figure 15.
 
[[Image:CombinationalCircuit.jpg|500px|thumb|center|Figure 15: Combinational Logic Circuit for ATM Example]]
 
=== Minimization of Boolean Functions ===
 
When working with logic circuits, it is important to derive the simplified boolean expression via the k-map for the overall efficiency of the circuit. In the ATM example listed above, the simplified boolean expression in Figure 14 and drawn in Figure 15 is significantly less complex than that of Figure 13. If the ATM were to employ a circuit created from Figure 13 as versus Figure 14, the resulting software would function the exact same way; it would still be able to charge a fee under the circumstances listed by the bank. However, the process that it would undergo would take more computing power than that of the simplified version. In programming, it is typically desirable to have not only an accurate program but also the most efficient program. In more complex examples with significantly more variables, the inefficiency of cost and implementation would skyrocket.


= Materials =
= Materials =
* Computer with LabVIEW 2019 software
* 7432 IC (4 dual-input OR gates)
* Materials for in-person lab:
* 7408 IC (4 dual-input AND gates)
** 7432 IC (4 dual-input OR gates)
* 7404 IC (6 single-input NOT gates)
** 7408 IC (4 dual-input AND gates)
* Wires
** 7404 IC (6 single-input NOT gates)
* 5V Battery Case
** NI-ELVIS II+ with prototyping board
* Music Voltmeter
** Wires
* Slide Switches
** Electrical leads
** Two 100 kΩ resistors (brown, black, yellow)


= Problem Statement =  
= Problem Statement =  


Farmer Georgi owns a 350-acre dairy farm in upstate New York. In addition to milk and butter, Farmer Georgi sells fresh eggs at the Union Square Greenmarket in Manhattan. Farmer Georgi is praised for the quality of his eggs, which is a direct effect of his treating his hen well. He keeps his barns at the optimal temperature for the hen to lay eggs. It is also imperative that Farmer Georgi protects the hen that produces eggs for his business.
Farmer Georgi owns a 350-acre dairy farm in upstate New York. He sells fresh eggs at the Union Square Greenmarket in Manhattan. It is imperative that Farmer Georgi protects his hen that produces his eggs.
 
=== Part I: Heating & Cooling System ===
 
Because Farmer Georgi cares about the quality of his eggs, Farmer Georgi treats the hen with the utmost respect. The hen is most comfortable and stress-free when the temperature of the two barns are between 60°F and 80°F. Farmer Georgi needs a heating and cooling system in his barns that maintain a temperature in that optimal range.


=== Part II: Alarm System ===
Farmer Georgi has two barns, one hen, and a supply of corn. A fox has been attempting to eat the hen by hiding in one of the two barns. The hen can move freely from one barn to the other. Farmer Georgi sometimes stores corn in one barn and sometimes in the other, but he never stores it in both at the same time. The hen would like to eat the corn and the fox would like to eat the hen. Farmer Georgi needs an alarm system that uses digital logic circuits to protect the hen and the corn. The design should use the fewest logic gates and input variables possible. The alarm should sound if:
 
Farmer Georgi has two barns, one hen, and a supply of corn. A fox has been attempting to eat the hen by hiding in a barn. The hen can move freely from one barn to the other. Farmer Georgi sometimes stores corn in one barn and sometimes in the other, but he never stores it in both at the same time. The hen would like to eat the corn and the fox would like to eat the hen. Farmer Georgi needs an alarm system that uses a digital logic circuit to protect the hen and the corn. The design should use the fewest logic gates and input variables possible. The alarm will sound if:
* The fox and the hen are in the same barn
* The fox and the hen are in the same barn
* The hen and the corn are in the same barn
* The hen and the corn are in the same barn
Line 233: Line 183:
= Procedure =  
= Procedure =  


== Setting up a Blank VI ==
=== Step 1. Formulate the Simplified Boolean Equation ===
 
# Open LabVIEW and select Blank VI under Create Project.
# Click Window > Tile Left and Right to display the front panel (left window) and back panel (right window) side by side. This will make them visible at the same time, making it easier to work.
# With the back panel selected, click View > Tools Palette to open the Tools palette.
# With the front panel selected, click View > Controls Palette. The workspace should look like Figure 16. To open the Controls palette in the future, simply right click in the front panel. Similarly, to open the Functions palette, simply right click in the back panel.
 
[[Image:Lab_labview_1.png|700px|thumb|center|Figure 16: LabVIEW Workspace]]
 
For help with the operation of any LabVIEW icon, select Help > Show Context Help > click the icon for the operation that is unclear. It will be explained in the Context Help window.
 
== Part I: Heating & Cooling System ==
 
Build a VI that simulates a heating and cooling system. The system must be able to be controlled manually or automatically. The VI’s specifications are listed below.
 
* Must be able to be controlled automatically and manually
* In manual mode, the heater and air conditioning (AC) can be switched on/off by the user
* In automatic mode, the heater and AC turn on/off based on the following conditions:
** The air conditioner is turned on when the temperature is above 80 °F
** The heater is turned on when the temperature is below 60 °F
** The heater and the air conditioner are turned off when the temperature is between 60 °F and 80 °F
 
=== 1. Design the Heating & Cooling System in LabVIEW ===
 
<span style="color:red;">Note: A LabVIEW digest of common tasks at the bottom of the page contains references for faster navigation.</span>
 
# Follow the steps in Setting up a New VI to start a new VI in LabVIEW.
# In the front panel, drag and drop three Round LEDs and three Slide Switches by going to the Controls palette > Modern tab > Boolean (Figure 17). The round LEDs and slide switches will separately represent the AC, heater, and manual mode. The round LEDs will indicate if the item is on, and the slide switches will toggle the items on/off.[[Image:SlideSwitches.jpg|500px|thumb|center|Figure 17: Slide Switches and Round LEDs in the Controls Palette]]
# Rename the LEDs and their corresponding switches to "Manual," "AC," and "Heater" to make building the system clearer (Figure 18). This can be done by using the editing text tool in the Tools palette.[[Image:NamedSwitches.jpg|500px|thumb|center|Figure 18: Named Switches and LEDs in the Front Panel]]
# Drag and drop a thermometer (Figure 19) into the front panel (Controls palette > Modern tab > Numeric > Thermometer).[[Image:Thermometer.jpg|500px|thumb|center|Figure 19:Thermometer Control]]
# In the back panel, right click the thermometer terminal and select Change to Control, and observe the arrow switches from the left side to the right side (Figure 20). This makes the thermometer a control that will give an input to the program, which will be temperature.[[Image:Indicator.jpg|300px|thumb|center|Figure 20:Indicator (Left) vs Control (Right)]]
# In the back panel, insert a case structure to control the manual and automatic operation of the heating and cooling system (Functions palette > Structures > Case Structure). To place the case structure, click once to place one corner of the case structure, and once more to place the other corner of the case structure in the back panel (Figure 21).[[Image:ProcedureCaseStructure.jpg|500px|thumb|center|Figure 21: Case Structure]]
# Wire the Manual slide switch to the case selector on the case structure (Figure 22). This should automatically change the selector label values to True and False, if they were not already, because the slide switch is a Boolean data type. The true value corresponds to manual mode being on (where the user can directly toggle the heater and AC), and the false value corresponds to manual mode being off (where the heater and AC are automatically toggled by the system).[[Image:ManualSwitch.jpg|500px|thumb|center|Figure 22: Manual Switch as Case Selector]]
# Because the temperature of the barn is input into the system only when the system is not in manual mode (the false case), the thermometer terminal should be moved into the false sub-diagram (Figure 23).[[Image:FalseCase.jpg|500px|thumb|center|Figure 23: Thermometer in the False Sub-diagram]]
# In the true sub-diagram, wire the AC and heater switches directly to their corresponding LEDs (Figure 24). This allows the switches to directly toggle their corresponding LEDs.[[Image:WiringSwitches.jpg|500px|thumb|center|Figure 24:Wiring the Switches to the LEDs]]
#Staying in the true sub-diagram, insert a True Constant (Functions palette > Programming tab > Boolean > True Constant). Wire the true constant to the manual LED to turn the manual LED on and indicate that the system is in manual mode (Figure 25).[[Image:Labview.png|500px|thumb|center|Figure 25: Sub-diagram for True Case]]
# In the false sub-diagram, insert two Numeric Constants (Functions palette > Programming > Numeric > Numeric Constant), one Greater? function and one Less? function (Functions palette > Programming > Comparison). These will be used to build the program for the heating and cooling system in automatic mode (Figure 26).[[Image:FalseTerminals.jpg|500px|thumb|center|Figure 26: Terminals for False Sub-diagram]]
# The less than and greater than functions compare what is wired to the upper input terminal to what is wired to the lower input terminal. Wire the thermometer to the upper input terminals of the less and greater functions. Set a numeric constant to 60 and the other to 80. Wire the 60 numeric constant to the lower input terminal of the less than function and the 80 numeric constant to the lower input terminal of the greater than function. Wire the output terminal of the greater than function to the AC LED and wire the output of the than less function to the heater LED (Figure 27).[[Image:HeatAcWiring.jpg|500px|thumb|center|Figure 27: Wiring to Heater and AC LEDs]]
# In the false sub-diagram, Insert a False Constant (Functions palette > Programming > Boolean > False Constant) and wire it to the manual LED (Figure 28). This turns off the manual LED and indicates that the system is in automatic mode.[[Image:SubFalseDiagram.jpg|500px|thumb|center|Figure 28: Sub-diagram for False Case]]
# The system is now complete. Click the continuously run button to control and test the VI. If the continuously run button is faded out, that means the system is wired completely. When successfully running the system, the gridlines in the background of the front panel should disappear (Figure 29). Click the switches and thermometer on the front panel to test the system.[[Image:HeatCoolSystem.jpg|500px|thumb|center|Figure 29: Running Heating and Cooling System]]
# Have a TA check the VI. Once testing is complete, take a screenshot of the VI. Save the heating and cooling system as a VI file (saving the file will save both the front panel and back panel in one file). Send the VI file to the lab participants via email.
 
=== 2. Interfacing with a Heat Cube ===
 
The VI will now be altered to interact with a heat cube, which is a physical device that houses a heating element, a fan, and a thermocouple, and LEDs located on an NI ELVIS II+ board. The heat cube will take the ambient temperature of the room and input it into the heating and cooling system. The fan (i.e. the AC) and heater in the heat cube can be turned on/off manually or automatically using the heating and cooling VI that was just created. This will be done by uploading pre-written sub-VIs that will interface the heating and cooling VI with the circuit on the NI ELVIS board II+.
 
#[[Media:Sub-VIs.zip | Download the sub-VIs onto the desktop.]] Unzip the folder. There should be three sub-VIs – Cooling Control.vi, Heat Control.vi, and Temp Reading.vi.
#Insert the sub-VIs into the back panel by right-clicking on the back panel > Select a VI… > click the sub-VI. Click on the back panel outside of the case structure to place the sub-VIs. They should appear as small boxes with text and an icon (Figure 30).[[Image:SubVi.jpg|200px|thumb|center|Figure 30:Sub-VI Terminals]]
# In the automatic sub-diagram, wire the output tunnel (green box along the border of the case structure) of the Less? function to the input terminal of the Heat Control sub-VI labeled Heat. Wire the output tunnel of the Greater? function to the input terminal of the Cool Control sub-VI labeled Cooling.
# Delete the orange wiring from the thermometer terminal to the upper input terminals of the less than and greater than functions. Wire the output terminal of the Temp Reading sub-VI labeled Result to the upper input terminals of the less than and greater than functions. The Temp Reading sub-VI will effectively replace the thermometer control terminal.
# Change the thermometer node to an indicator. In the back panel, right click the thermometer terminal and select Change to Indicator.
# Wire the Result output terminal on the Temp Reading sub-VI to the thermometer indicator terminal. The thermometer indicator terminal will be used to display the temperature being read by the thermocouple in the heat cube.
# A device constant must be defined for each of the pre-written sub-VIs. The device constant selects the external device the sub-VIs transmit data to and receive data from.
# With the wiring tool selected, right click on the input terminal of the sub-VIs labeled Device Name > Create > Constant.
# Verify that all three device constants are equivalent. The device constant can be changed using the operating tool in the Tools palette.
# Ask the TA to check over the modifications to the VI. Take a screenshot of the VI and send the file to the lab participants via email.
 
=== 3. Build the Circuit on an NI ELVIS II+ Board ===
 
# The TA will supply an NI ELVIS board II+, a heat cube, two 100 kΩ resistors, and electrical wires.
# Using two 100 kΩ resistors (Brown, Black, Yellow), insert one end of each resistor into AIGND (row 18) of the NI ELVIS II+ board.
# Insert the other end of one of the resistors into the AI 7+ (row 15), and the end of the other resistor into AI 7- (row 16).
# Using a wire, connect the AI 7+ port (row 15) to the screw terminal 1 port (row 46).
# Using a wire, connect the AI 7- port (row 16) to the screw terminal 2 port (row 47).
# Insert the positive and negative wires from the fan into Variable Power Supplies SUPPLY+ (row 48) and Variable Power Supplies GROUND (row 49), respectively, at the lower-left-hand corner of the NI ELVIS II+ board.
# Connect the positive wire from the heater to DC +5 V (row 54) on the lower-right-hand corner of the NI ELVIS II+ board.
# Connect the source of the MOSFET from the heat cube circuit to DC ground (row 53) on the lower-right-hand corner of the NI ELVIS II+ board.
# Connect the gate of the MOSFET from the heat cube circuit to DIO 19 (row 20) on the upper-right-hand corner of the NI ELVIS II+ board.
# Power the NI ELVIS II+ board with the power cable and also connect it to the PC with the USB cable. The device constants on the back panel of the VI should update to reference the NI ELVIS II+ board.
# Run the VI. Observe how the fan and heater in the heat cube can be turned on manually and automatically. Observe how the thermometer indicator in the front panel displays the actual temperature of the room.
 
== Part II: Alarm System ==
 
Design and build a VI that simulates an alarm system using digital logic. The specifications for the alarm system are listed under the Problem Statement section.
 
=== 1. Test the Integrated Circuits (ICs) ===
 
<span style="color:red;">Note: Read the procedure below to familiarize yourself with how to test IC chips that will be used in this lab. This part of the procedure is for your information only. Nothing has to be performed for this part of the lab.</span>
 
Before performing the lab, the <b>integrated circuits (IC)</b> used in wiring the alarm system on the NI-ELVIS II+ board must be tested to determine if they are functioning. If the procedure is completed without verifying that the ICs work, problems may occur in the circuit that require additional time and troubleshooting. The system for checking the ICs uses an Arduino board to send and receive signals from the AND/OR/NOT chips and determines if they are functioning properly.
 
First, load the chip onto the Arduino board (Figure 31) and start the Serial Monitor on the Arduino program (top right corner). The code will cycle through the basic inputs (0, 1 for NOT; 00, 01, 10, 11 for AND/OR) and then send the outputs of each gate in the chip back to the Arduino board. The code compares those results to the expected result. It displays each input/output pair and displays the final result indicating if the chip is functional or defective. The goal is to determine if the gates are outputting the correct results. After, remove the chips carefully from the Arduino board.
 
[[Image:ICtesting.jpg|500px|thumb|center|Figure 31:IC Testing Setup]]
 
=== 2. Formulate the Simplified Boolean Equation ===


# The two barns must be assigned a numeric equivalent before the truth table is prepared. Use 1 for Barn A and 0 for Barn B (1 does not mean true and 0 does not mean false for the inputs). For the alarm output, use 0 to indicate that the alarm should be off, and 1 to indicate that the alarm should be on.
# The two barns must be assigned a numeric equivalent before the truth table is prepared. Use 1 for Barn A and 0 for Barn B (1 does not mean true and 0 does not mean false for the inputs). For the alarm output, use 0 to indicate that the alarm should be off, and 1 to indicate that the alarm should be on.
# On a sheet of paper or on the Zoom whiteboard, create a truth table that includes the three inputs (hen, fox, corn) and one output (alarm). Assign the input variables. Use all scenarios for hen, the corn, and the fox. For example, one possible scenario is that the hen, corn and fox are in Barn B, so place a 0 in the three input columns.
# On a sheet of paper, create a truth table that includes the three inputs (hen, fox, corn) and one output (alarm). Assign the input variables. Use all scenarios for hen, the corn, and the fox. For example, one possible scenario is that the hen, corn and fox are in Barn B, so place a 0 in the three input columns.
# Compute the output column. To do this, analyze the three inputs and logically determine if the alarm will sound in each scenario. Place a 1 in the output column if the alarm will sound and a 0 if it will not.
# Compute the output column. To do this, analyze the three inputs and logically determine if the alarm will sound in each scenario. Place a 1 in the output column if the alarm will sound and a 0 if it will not.
# Circle all the combinations that produce a 1 in the output column. Create a Boolean equation from this table that uses each of the input combinations that produced a true output. Refer to the Overview section if there is any confusion.
# Circle all the combinations that produce a 1 in the output column. Create a Boolean equation from this table that uses each of the input combinations that produced a true output. Refer to the Overview section if there is any confusion.
Line 327: Line 192:
# Box the pairs of 1s. The 1s may only be boxed in powers of 2 starting with the largest possible combination and working down to the smallest. The outcomes that do not contribute to the solution are to be discarded.
# Box the pairs of 1s. The 1s may only be boxed in powers of 2 starting with the largest possible combination and working down to the smallest. The outcomes that do not contribute to the solution are to be discarded.
# This process yields a simplified Boolean equation. Write this simplified Boolean equation down.
# This process yields a simplified Boolean equation. Write this simplified Boolean equation down.
# Draw a combinational logic circuit of the simplified Boolean equation.
# Draw a combinational logic circuit of the simplified Boolean equation. EG1003 recommends using [https://logic.ly/demo/ logic.ly] for creating the combinational logic circuit. Screenshot the circuit instead of saving it.
# Have a TA approve the steps to obtain the combinational logic circuit.
# Have a TA approve the steps to obtain the combinational logic circuit.


=== 3. Build the Logic Circuit in LabVIEW ===
=== Step 2. Test the Integrated Circuits (ICs) ===


<span style="color:red;">Note: A LabVIEW digest of common tasks at the bottom of the page contains references for faster navigation.</span>
Before building the circuit, the ICs used in wiring the alarm system must be tested to determine if they are functioning. If the procedure is completed without verifying that the ICs work, it will require additional time and troubleshooting in Step 3. The system for checking the ICs uses an Arduino board to send and receive signals from the AND/OR/NOT chips and determines if they are functioning properly.


Build the logic circuit in <b>LabVIEW 2019</b> using the combinational logic circuit that was drawn.  
Load the chip onto the Arduino board (Figure 5 ) and start the Serial Monitor on the Arduino program (top right corner). The code will cycle through the basic inputs (0, 1 for NOT; 00, 01, 10, 11 for AND/OR) and then send the outputs of each gate in the chip back to the Arduino board. The code compares those results to the expected result. It displays each input/output pair and the final result.  After the test is done, carefully remove the chips from the test station.


# Follow the steps in Setting up a New VI to start a new VI in LabVIEW.
[[Image:ICtesting.jpg|500px|thumb|center|Figure 5:IC Testing Setup]]
# Place three switches on the front panel by going to the Controls palette > Modern tab > Boolean > select the switch. The switches will represent the hen, the corn, and the fox.
# Place a Boolean indicator on the front panel to represent the alarm or the output. Go to the Functions palette > Programming > Boolean > select the AND, NOT, and OR gates necessary for the circuit.
# Wire the gates to build the combinational logic circuit.
# Click run continuously to simulate the circuit. Once the LabVIEW program is complete, have a TA check and approve the circuit.


=== 4. Build the Circuit on an NI ELVIS II+ Board ===
=== Step 3. Build the Combinational Logic Circuit ===


# Build the circuit on a NI-ELVIS II+ prototyping board. On the board, identify each of the three IC chips as an AND, OR, or NOT gate. To do this, read the number on the chip and match it with the numbers shown in Figure 16. Look for the notch at one end of each chip to orient the chip to the diagrams in Figure 32 and to match the pins.[[Image:ICnumbers.jpg|500px|thumb|center|Figure 32: IC Numbers and Pins]]
# Obtain a pre-assembled breadboard from the TA.
# Place the IC chips over the bridge in the NI-ELVIS II+ board (Figure 33).[[Image:ICbreadboard.jpg|500px|thumb|center|Figure 33: IC Chip in Breadboard]]
# Build the circuit on a pre-assembled breadboard. On the board, identify each of the three IC chips as an AND, OR, or NOT gate. To do this, read the number on the chip and match it with the numbers shown in Figure 7. <b>Look for the notch at one end of each chip to orient the chip to the diagrams in Figure 7 and to match the pins</b>.[[Image:ICchips.jpg|500px|thumb|center|Figure 7: IC Numbers and Pins]]
# Power the chips. Insert one end of an electrical lead into Row 54 (marked +5V) of the NI-ELVIS II+ board. Insert the other end of the lead into Pin 14 of the IC chip. Repeat this process for all three chips.
# Place the IC chips over the bridge in the breadboard with the NOT chip on top, the AND chip in the middle, and the OR chip at the end (Figure 8).
# Ground the chips using the same method. Insert one end of another electrical lead into Row 53 (marked Ground) of the NI-ELVIS II+ board and the other end into Pin 7 of the IC chip. Repeat this process for all three chips.
#;[[Image:ICbreadboard.jpg|500px|thumb|center|Figure 8: IC Chip in Breadboard]]
# Look at the top right corner of the breadboard to find the Digital Input/Output (DIO) holes. Select one of the DIO rows to use as one of the input variables and begin wiring the circuit based on the simplified Boolean equation. Assign the other DIO rows for the remaining input variables.
# Power the chips by inserting one end of an electrical lead into the power column marked + on the breadboard. Insert the other end of the lead into Pin 14 of the IC chip. Repeat this process for all three chips.
# Continue this process until the entire circuit is wired. Insert one end of a lead into the final output of the NI-ELVIS circuit. Attach the other end of the lead to any row for an LED on the board.
# Ground the chips by inserting one end of another electrical lead into the ground column marked – on the breadboard and the other end into Pin 7 of the IC chip. Repeat this process for all three chips (Figure 9).
# Plug in the NI-ELVIS II+ board and connect the USB cable to the lab PC.
#; [[Image:ICPower.jpg|500px|thumb|center|Figure 9:  IC Chips Connected to Power and Ground]]
# Power on the NI-ELVIS II+ board by toggling the switches on the back of the device and top of the device. When the pop-up window appears, select NI-ELVISmx Instrument Launcher and click OK (Figure 34).[[Image:NewDataAquisition.jpg|500px|thumb|center|Figure 34: New Data Acquisition Device Dialog Window]]
Look at the top right corner of the breadboard to find the rows for each input. Wire the last lead of the first switch to use as the fox input variable and begin wiring based on the simplified Boolean equation. Repeat this for the second switch for the hen input and the third switch for the corn input.
# Click on the DigOut Icon on the Instrument Launcher window (Figure 35).[[Image:InstrumentLauncher.jpg|200px|thumb|center|Figure 35: NI ELVISmx Instrument Launcher Dialog Window]]
# Continue this process until the entire circuit is wired. Insert one end of a wire into the final output of the logic circuit. Attach the other end of the wire to the last row of the breadboard where no other connections are made. This will serve as the row of connection for the power side of the music voltmeter.
# The NI ELVISmx Digital Writer window should appear (Figure 36). Select the correct range for the Lines to Write corresponding to the DIO rows used in the wiring. For example, if the fox, hen, and corn are wired to DIO 21, 22, and 23, select 16–23 for the Lines to Write.[[Image:DigitalWriter.jpg|500px|thumb|center|Figure 36: Digital Writer Window]]
# Operate the slide switches corresponding to the corn, fox, and hen. Observe the music voltmeter to see if the alarm goes off based on the inputs to each barn. Compare the results to the truth table to determine if the circuit is operating correctly.
# Click Run and toggle the switches corresponding to the fox, hen, and corn. Observe the LED to see if the alarm lights up based on the inputs to each barn. Compare the results to the truth table to determine if the circuit is operating correctly.
# If the circuit is operating correctly, take pictures of the circuit and clean up the workspace.
# Have a TA check the circuit. Once the TA approves, start with Part II of the lab.
# If the circuit is not operating properly, disconnect the circuit from power and examine the circuit including wiring issues.  


The lab work is now complete. Refer to the Assignment section for the instructions to prepare the lab report.
The lab work is now complete. Refer to the Assignment section for the instructions to prepare the lab report.
Line 361: Line 222:
= Assignment =
= Assignment =


== Team Lab Report ==  
== Individual Lab Report ==  
{{Labs:Lab Report}}
{{Labs:Lab Report}}


Line 367: Line 228:
* Describe how AND, OR, and NOT gates work
* Describe how AND, OR, and NOT gates work
* What is a truth table? Explain the process for obtaining a Boolean equation from a truth table
* What is a truth table? Explain the process for obtaining a Boolean equation from a truth table
* What is a K-map? How does it contribute to obtaining a simplified Boolean equation? To demonstrate the simplification, show what the equation would look like if terms were written for each of the true values and the simplified equation by applying the K-map. Discuss how much simpler the circuitry is as a result of applying the K-map
* What is a K-map? How does it contribute to obtaining a simplified Boolean equation? To demonstrate simplification, show what the equation would look like if terms were written for each of the true values and the simplified equation by applying the K-map. Discuss how much simpler the circuitry is as a result of applying the K-map
* Include the truth table, Boolean equation, K-map, simplified Boolean equation, and combinational logic circuit developed during the lab
* Include the truth table, Boolean equation, K-map, simplified Boolean equation, and combinational logic circuit developed during the lab
* Describe how to construct a digital logic circuit using Boolean equations, K-maps, truth table etc.
* Describe how to construct a digital logic circuit using Boolean equations, K-maps, truth table  
* Why is there a need for the minimization of a logic design and what are the advantages?
* Why is there a need for the minimization of a logic design and what are the advantages?
* How does the use of a combinational logic circuit contribute to advances in technology?
* How does the use of a combinational logic circuit contribute to advances in technology?
* Describe how the final combinational logic circuit was obtained
* Describe how the final combinational logic circuit was obtained
* Discuss LabVIEW and how does it help engineers and scientists with their work. What are its advantages and disadvantages?
* How is LabVIEW important today?
* Discuss what an NI ELVIS II+ board is
* Explain what a VI is
* What are controls and indicators?
* What are structures and functions?
* What is the front panel used for? The back panel?
* Because the procedural elements for the heating & cooling system are extensive, only briefly summarize the heating & cooling system procedure
* Did the alarm system and VI work?
* Suggest improvements for the VI
* Include a screenshot of the front and back panels of the LabVIEW VIs for the alarm system and heating & cooling system
* Discuss other possible design/procedural improvements
* Discuss other possible design/procedural improvements
* Discuss what part of the lab each individual member completed for the group and how it was important to the overall experiment.
* Contribution Statement


{{Labs:Lab Notes}}
<!--{{Labs:Lab Notes}}-->


== Team Powerpoint Presentation ==
== Team Powerpoint Presentation ==
Line 396: Line 246:
* Looking into the future, how will digital logic change the world?
* Looking into the future, how will digital logic change the world?
* Include the truth table, Boolean equation, K-map, simplified Boolean equation, and combinational logic circuit developed during the lab
* Include the truth table, Boolean equation, K-map, simplified Boolean equation, and combinational logic circuit developed during the lab
* Describe the advantages and disadvantages of using LabVIEW
* Explain what a VI is
= LabVIEW Digest of Common Tasks =
== Front Panel ==
* <b>How to get a slide control:</b>
** Controls palette > Modern tab > Numeric [[Image:lab_labview_2.png]]
** Select Horizontal Pointer Slide [[Image:Slide Control 2.png|55px]]
** Click on the front panel to place the slide at a specific location
* <b>How to get an LED indicator:</b>
** Controls palette > Modern tab > Boolean [[Image:lab_labview_8.png]]
** Select the Round LED [[File:LED 1.png|55px]] or Square LED [[File:LED 2.png|55px]]
** Click on the front panel to place the LED at a specific location
* <b>How to get a numeric control:</b>
** Controls palette > Modern tab > Numeric [[Image:lab_labview_2.png]]
** Click on Numeric Control [[Image:NC.png|55px]]
** Click on the front panel to place the numeric control at a specific location
* <b>How to get a numeric indicator:</b>
** Controls palette > Modern tab > Numeric [[Image:lab_labview_2.png]]
** Click on Numeric Indicator [[Image:NI.png|55px]]
** Click on the front panel to place the numeric indicator at a specific location
== Back Panel ==
* <b>How to define an arithmetic operation:</b>
** Functions palette > Programming tab > Numeric [[Image:lab_labview_33.png]]
** Click on the function of the desired arithmetic operation [[Image:Arithmetic.png|300px]]
** Click on the back panel to place the arithmetic function at a specific location
* <b>How to define Boolean constants (usually used to turn on/off LEDs):</b>
** Functions palette > Programming tab > Boolean [[Image:lab_labview_36.png]]
** Click on the True Constant [[Image:lab_labview_42.png]] or False Constant [[Image:lab_labview_43.png]]
** Click on the back panel to place the Boolean constant at a specific location
* <b>How to wire:</b>
** Tools palette > Wiring tool [[Image:lab_labview_19.png]]
** Click the desired object output terminal (on the left side) to wire from
** Click the desired object input terminal (on the right side) to wire to


= References =  
= References =  
Introduction to LabVIEW, Six-Hour Course [Courseware]. (June 2003) Austin, TX: Worldwide Technical Support and Product Information, National Instruments Corporation.
“LabVIEW Block Diagram Explained.” National Instruments, National Instruments, 4 Feb. 2020, www.ni.com/en-us/support/documentation/supplemental/08/labview-block-diagram-explained.html.
“Case Structure.” National Instruments, National Instruments, 4 Feb. 2020, www.zone.ni.com/reference/en-XX/help/371361R-01/glang/case_structure/.
“LabVIEW Front Panel Explained.” National Instruments, National Instruments, 4 Feb. 2020, www.ni.com/en-us/support/documentation/supplemental/08/labview-front-panel-explained.html.


Boole, George, Encyclopedia Britannica, 2003. Encyclopedia Britannica Online. Retrieved July 29, 2003 http://www.britannica.com/eb/article?eu=82823
Boole, George, Encyclopedia Britannica, 2003. Encyclopedia Britannica Online. Retrieved July 29, 2003 http://www.britannica.com/eb/article?eu=82823


{{Laboratory Experiments}}
{{Laboratory Experiments}}

Revision as of 18:01, 19 February 2022

Objective

The objective of this lab is to use digital logic to design a combinational logic circuit for an alarm system and to build and test the system using prototyping components.

Overview

Digital Logic

Digital logic is the conceptual language behind modern computer systems. It uses the Boolean language, which consists of a system of rules that essentially says “yes” or “no” to a series of questions, leading to extremely complicated decisions. The fundamentals of digital logic will be explored in this lab, and a digital logic system will be designed to address a simple problem statement.

Truth Tables

In Boolean logic, there are only two values, true and false, represented by 1 and 0, respectively. These values are combined in equations to yield results that also have these two values. The equations are represented by truth tables that show the inputs to the equation and the outputs produced for those inputs. The rows of the table contain all the combinations of 1s and 0s for the inputs. The number of rows is determined by the number of combinations.

To illustrate a truth table and additional concepts that will be introduced, think of an ATM that has three options: print a statement, withdraw money, or deposit money. The ATM will charge a fee to (1) withdraw money or (2) print a statement without depositing money. The intent of the problem is to develop a Boolean equation and logic circuit that will determine the combinations of actions will result in a fee being charged. First, a truth table should be made for all the combinations of inputs. The inputs are the ATM's three functions. Let variable P stand for printing a statement, W for withdrawing money, and D for depositing money. A “1” indicates the user has taken that action and a “0” indicates the user has not taken that action. There are two outputs -- charge a fee (1) or do not charge a fee (0). The output column will be denoted by C. The truth table in Table 1 shows all the combinations of the inputs and their corresponding outputs.

Table 1: Truth Table for the ATM Example

Inputs Output
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 1

Boolean Equations

A truth table is used to write a Boolean equation for a problem. All the combinations that yield an output of 1 are kept, and the equation is written. This is called a Sum of Products solution. Only the combinations that yield an output of 1 are kept because the Boolean equation intends to represent a quantitative function when the output will be true (when a fee is charged in the example of the ATM machine). The combinations that yield an output of 0 are discarded because there is no interest in when the result has a false value. The Boolean equation for the ATM example can be seen in Figure 13.


Figure 13: Boolean Equation


For each of the combinations (rows) resulting in true in Table 1, the terms of the Boolean equation are determined by multiplying the variables together (the AND operation). If an input is true, the variable can be used as-is; for an input that is false, the variable is inverted using the horizontal bar (the NOT operation). Since the output is true if any of the combinations are true, the equation is formed by using addition operations (the OR operation) on all the terms formed by the product of each combination.

Karnaugh Maps (K-Maps)

A truth table showing every combination of inputs and their corresponding outputs yields a Boolean equation that is the solution to a problem in digital logic. This equation can be simplified using a Karnaugh map (K-map). A K-map identifies and eliminates all the conditions that do not contribute to the solution. The resulting simplified Boolean equation is used to build the digital circuit and will be a combination of the logic gates described earlier.

A K-map is a two-dimensional representation of the truth table that shows the common characteristics of the inputs. For an equation with three inputs, usually all the combinations of the first two inputs are shown as four columns and the values for the third input are shown as two rows. For four inputs, all the combinations of the third and fourth inputs are shown as four rows. Only one value can change at a time in adjacent rows or columns. For example, in Table 5, the columns change from 00 to 01 to 11 to 10. Table 5 illustrates the K-map for the ATM example.

Table 5: K-Map for the ATM Example
0 0 0 1 1 1 1 0
0 0 1 1 1
1 0 1 1 0

Simplified Boolean Equations

To develop the simplified Boolean equation, look for the cells that have the 1 value in common. Look for cells that can physically be boxed together, where the number of cells in the box is a power of 2 (1, 2, 4, or 8 and so on). The boxes are allowed to overlap so the same cells can be used more than once. Look for the biggest boxes first, and keep finding smaller boxes until all the cells with a 1 in them are used. This means that sometimes just single cells will remain at the end. The cells in the K-map for the ATM example can be grouped like what is shown in Table 6.

Table 6: K-Map Boxes for the ATM Example


Kmap Boxes.gif


In this example, all the cells containing a 1 were covered with two boxes. This means that if the conditions for either box are true, the output will be true. This also means that the simplified Boolean equation will only have two terms. The term for each box can be determined by observing which variables are constant throughout each cell of that box. For the red box, only W remains constant through the four cells. D switches from the top row to the bottom row, and P switches from the left column to the right column. For the blue box, P and remains constant through the two cells, while W switches from the left cell to the right cell. The two boxes yield the simplified Boolean equation shown in Figure 14.

Figure 14: Simplified Boolean Equation for the ATM Example


This equation meets the conditions in the truth table in Table 1 and achieves the desired result with the minimum number of logic elements.

Logic Gates

Boolean logic is applied to digital circuitry through the use of simple logic gates. There are symbols for each of these gates, and the connections between them are represented by lines running from the output of one gate to the input of another. A line can connect only one output to each input. There are seven gates: the NOT, AND, OR, NAND, NOR, XOR, and XNOR gates. Only the first three will be used in this lab (Figure 12).

Figure 1: Logic Gate Symbols

The NOT gate is the simplest of the three. It is an inverter. It has one input and produces its opposite as the output. For example, if a 1 is the input to a NOT gate, a 0 value is outputted, as seen in Table 2. The symbol for the operation is a horizontal bar over the variable. The truth table for a NOT gate is shown in Table 2.

Table 2: Truth Table for a NOT Gate
0 1
1 0

The AND gate performs a multiplication operation on its inputs. If all the inputs are true, the output is also true. But if either of the inputs is false, the output is also false. An AND gate can have two or more inputs, but for this lab, it will have two inputs (denoted by A and B in Table 3). The symbol for the AND operation is a dot (·) or the two inputs one after the other with nothing between them. The truth table for an AND gate is shown in Table 3.

Table 3: Truth Table for an AND Gate
0 0 0
0 1 0
1 0 0
1 1 1

An OR gate performs an addition operation on its inputs. If either of the inputs is true, the output is also true. But if all the inputs are false, the output is also false. An OR gate can have two or more inputs, but for this lab, it will have two inputs (denoted by A and B in Table 4). The symbol for the OR operation is a plus (+). The truth table for an OR gate is shown in Table 4.

Table 4: Truth Table for an OR Gate
0 0 0
0 1 1
1 0 1
1 1 1


Combinational Logic Circuits

Lastly, a combinational logic circuit can be created using the simplified equation. First, a NOT operation is performed on D by inputting and outputting D through a NOT gate. Then, the P and inverted D are inputted into an AND gate, as denoted by them being multiplied in figure 14. Finally, the result of the AND operation between the P and inverted D and the W is inputted into an OR gate, as denoted by the addition function in figure 14. The final combinational logic circuit can be seen in Figure 15.

Figure 2: Combinational Logic Circuit for ATM Example

Integrated Circuits

Integrated circuits (IC) can be used to prototype a combinational logic circuit on a breadboard. These devices are small assemblies of electronic components that have been combined into a single unit. In this lab, the IC chips consist of logic gates that can be wired to prototype the logic circuit (Figure 3).

Figure 3: An IC Chip

Each chip consists of multiple logic gates. A 7408 chip consists of four AND gates, a 7432 chip consists of four OR gates, and a 7404 chip consists of six NOT gates. These gates can be wired to inputs and outputs to create a combinational logic circuit. The IC chips must also be connected to a power source and ground to operate.

Figure 4 shows how the IC chips can be used to wire the circuit for the ATM problem. In this circuit in Tinkercad, a piezo buzzer represents the output. Slide switches control the Print, Withdraw, and Deposit inputs. The pink wire represents the Print (P) input, the blue wire represents the Withdraw (W) input, and the yellow wire represents the Deposit (D) inputs.

Figure 4: The ATM Problem Prototyped on a Breadboard using IC Chips

The input is wired to a NOT gate (Chip 7404) to get a output. This is wired to an AND gate input (Chip 7408), along with a input to get a output. This output is wired to an OR gate (Chip 7432), along with a W input to get the final output of .

Materials

  • 7432 IC (4 dual-input OR gates)
  • 7408 IC (4 dual-input AND gates)
  • 7404 IC (6 single-input NOT gates)
  • Wires
  • 5V Battery Case
  • Music Voltmeter
  • Slide Switches

Problem Statement

Farmer Georgi owns a 350-acre dairy farm in upstate New York. He sells fresh eggs at the Union Square Greenmarket in Manhattan. It is imperative that Farmer Georgi protects his hen that produces his eggs.

Farmer Georgi has two barns, one hen, and a supply of corn. A fox has been attempting to eat the hen by hiding in one of the two barns. The hen can move freely from one barn to the other. Farmer Georgi sometimes stores corn in one barn and sometimes in the other, but he never stores it in both at the same time. The hen would like to eat the corn and the fox would like to eat the hen. Farmer Georgi needs an alarm system that uses digital logic circuits to protect the hen and the corn. The design should use the fewest logic gates and input variables possible. The alarm should sound if:

  • The fox and the hen are in the same barn
  • The hen and the corn are in the same barn

Procedure

Step 1. Formulate the Simplified Boolean Equation

  1. The two barns must be assigned a numeric equivalent before the truth table is prepared. Use 1 for Barn A and 0 for Barn B (1 does not mean true and 0 does not mean false for the inputs). For the alarm output, use 0 to indicate that the alarm should be off, and 1 to indicate that the alarm should be on.
  2. On a sheet of paper, create a truth table that includes the three inputs (hen, fox, corn) and one output (alarm). Assign the input variables. Use all scenarios for hen, the corn, and the fox. For example, one possible scenario is that the hen, corn and fox are in Barn B, so place a 0 in the three input columns.
  3. Compute the output column. To do this, analyze the three inputs and logically determine if the alarm will sound in each scenario. Place a 1 in the output column if the alarm will sound and a 0 if it will not.
  4. Circle all the combinations that produce a 1 in the output column. Create a Boolean equation from this table that uses each of the input combinations that produced a true output. Refer to the Overview section if there is any confusion.
  5. Create a K-map. Draw a map that uses all the combinations from the Boolean equation. Use the Boolean equation to fill in the 1s and 0s on the K-map.
  6. Box the pairs of 1s. The 1s may only be boxed in powers of 2 starting with the largest possible combination and working down to the smallest. The outcomes that do not contribute to the solution are to be discarded.
  7. This process yields a simplified Boolean equation. Write this simplified Boolean equation down.
  8. Draw a combinational logic circuit of the simplified Boolean equation. EG1003 recommends using logic.ly for creating the combinational logic circuit. Screenshot the circuit instead of saving it.
  9. Have a TA approve the steps to obtain the combinational logic circuit.

Step 2. Test the Integrated Circuits (ICs)

Before building the circuit, the ICs used in wiring the alarm system must be tested to determine if they are functioning. If the procedure is completed without verifying that the ICs work, it will require additional time and troubleshooting in Step 3. The system for checking the ICs uses an Arduino board to send and receive signals from the AND/OR/NOT chips and determines if they are functioning properly.

Load the chip onto the Arduino board (Figure 5 ) and start the Serial Monitor on the Arduino program (top right corner). The code will cycle through the basic inputs (0, 1 for NOT; 00, 01, 10, 11 for AND/OR) and then send the outputs of each gate in the chip back to the Arduino board. The code compares those results to the expected result. It displays each input/output pair and the final result. After the test is done, carefully remove the chips from the test station.

Figure 5:IC Testing Setup

Step 3. Build the Combinational Logic Circuit

  1. Obtain a pre-assembled breadboard from the TA.
  2. Build the circuit on a pre-assembled breadboard. On the board, identify each of the three IC chips as an AND, OR, or NOT gate. To do this, read the number on the chip and match it with the numbers shown in Figure 7. Look for the notch at one end of each chip to orient the chip to the diagrams in Figure 7 and to match the pins.
    Figure 7: IC Numbers and Pins
  3. Place the IC chips over the bridge in the breadboard with the NOT chip on top, the AND chip in the middle, and the OR chip at the end (Figure 8).
    Figure 8: IC Chip in Breadboard
  4. Power the chips by inserting one end of an electrical lead into the power column marked + on the breadboard. Insert the other end of the lead into Pin 14 of the IC chip. Repeat this process for all three chips.
  5. Ground the chips by inserting one end of another electrical lead into the ground column marked – on the breadboard and the other end into Pin 7 of the IC chip. Repeat this process for all three chips (Figure 9).
    Figure 9: IC Chips Connected to Power and Ground
  6. Look at the top right corner of the breadboard to find the rows for each input. Wire the last lead of the first switch to use as the fox input variable and begin wiring based on the simplified Boolean equation. Repeat this for the second switch for the hen input and the third switch for the corn input.
  7. Continue this process until the entire circuit is wired. Insert one end of a wire into the final output of the logic circuit. Attach the other end of the wire to the last row of the breadboard where no other connections are made. This will serve as the row of connection for the power side of the music voltmeter.
  8. Operate the slide switches corresponding to the corn, fox, and hen. Observe the music voltmeter to see if the alarm goes off based on the inputs to each barn. Compare the results to the truth table to determine if the circuit is operating correctly.
  9. If the circuit is operating correctly, take pictures of the circuit and clean up the workspace.
  10. If the circuit is not operating properly, disconnect the circuit from power and examine the circuit including wiring issues.

The lab work is now complete. Refer to the Assignment section for the instructions to prepare the lab report.

Assignment

Individual Lab Report

Follow the lab report guidelines laid out in the EG1004 Writing Style Guide in the Technical Writing section of the manual. Use the outline below to write this report.

  • Describe the problem statement regarding Farmer Georgi
  • Describe how AND, OR, and NOT gates work
  • What is a truth table? Explain the process for obtaining a Boolean equation from a truth table
  • What is a K-map? How does it contribute to obtaining a simplified Boolean equation? To demonstrate simplification, show what the equation would look like if terms were written for each of the true values and the simplified equation by applying the K-map. Discuss how much simpler the circuitry is as a result of applying the K-map
  • Include the truth table, Boolean equation, K-map, simplified Boolean equation, and combinational logic circuit developed during the lab
  • Describe how to construct a digital logic circuit using Boolean equations, K-maps, truth table
  • Why is there a need for the minimization of a logic design and what are the advantages?
  • How does the use of a combinational logic circuit contribute to advances in technology?
  • Describe how the final combinational logic circuit was obtained
  • Discuss other possible design/procedural improvements
  • Contribution Statement


Team Powerpoint Presentation

Follow the presentation guidelines laid out in the EG1004 Lab Presentation Format in the Technical Presentations section of the manual. When preparing the presentation, consider the following points.

  • How does digital logic impact the world today?
  • Looking into the future, how will digital logic change the world?
  • Include the truth table, Boolean equation, K-map, simplified Boolean equation, and combinational logic circuit developed during the lab

References

Boole, George, Encyclopedia Britannica, 2003. Encyclopedia Britannica Online. Retrieved July 29, 2003 http://www.britannica.com/eb/article?eu=82823