Kaylee: Labview digital logic
NI ELVIS Tutorial Video
General Engineering has created a video that discusses breadboard wiring and digital logic circuits: NI ELVIS Tutorial Video. This video provides information on the educational NI-ELVIS II + prototyping board that will aid in designing and wiring the physical circuit. Material covered in the video will be on the Lab 7 quiz. Viewing the video is a mandatory pre-lab assignment.
The experimental objective of this lab is to design two systems using LabVIEW: a thermal control system and alarm system.The experimental objective of this lab is to design a combinational logic circuit that will activate under specific conditions and test it using LabVIEW. After testing, it will be built on an 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. In contrast to the more common text-based languages, LabVIEW uses a graphical programming language. The logic of graphical programming will be shown during the course of this lab.
Adapted from Introduction to LabVIEW, Six-Hour Course.
LabVIEW is a development environment for creating graphical programs called virtual instruments (VI), that simulate actual laboratory instruments. A VI consists of two parts: a front panel and a back panel. The front panel allows the user to interact with the VI by displaying output and allowing the user to supply the program with input. The back panel consists of the code used by the VI to obtain input from the front panel, operate on the input, and display the results.
The front panel is built using controls and indicators. Controls are inputs that allow a user to supply information to the VI. Indicators 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 controls palette and can be placed on the front panel.
The back panel, which is a block diagram, contains the graphical source code. All of the objects placed on the front panel will appear on the back panel as 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 functions palette and can be placed on the back panel. Collectively, controls, indicators, structures, and functions are referred to as nodes. Nodes are connected to one another using wires. 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.
In any programming language, structures are used to create conditions. In LabVIEW, structures are accessed by opening the functions palette and selecting Structures. The following are some examples of structures:
- The while loop is similar to the do loop or while in text-based programming languages. It executes its subdiagram (or subroutine) until it receives a false value
- The for loop executes a subdiagram a set number of times specified by the value in the count terminal
- The case structure is similar to if/else, switch/case, or match/with in text-based programming languages. It contains multiple subdiagrams — one for each possible value of the input to the case structure
National Instruments' Educational Laboratory Virtual Instrumentation Suite (NI-ELVIS) board is one solution LabVIEW can utilize to physically interface with the outside world. Keep in mind that National Instruments offers different hardware solutions to meet clients' individual needs.
Some useful key shortcuts when working in the LabVIEW environment are:
- CTRL+H: Show/hide context help
- CTRL+B: Clean up broken wiring
- CTRL+E: Toggle between front/back panels
- CTRL+Z: Undo last action
The first step in understanding the digital circuits that control the function of electronic devices is the mastery of Boolean logic. George Boole, an English mathematician, established modern symbolic logic in 1854 with the publication of his paper, "Laws of Thought." Boolean logic is the foundation of digital circuitry. Boole's method of logical inference allows conclusions to be drawn from any proposition involving any number of terms. Boolean logic demonstrates that the conclusions found are logically contained in the original premises.
In Boolean logic, there are only two values, true and false, represented by the numbers 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 possible combinations of 1s and 0s for the inputs. The number of rows is determined by the number of possible combinations.
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 the other. A line can connect only one output to each input. There are seven of these gates: the NOT, AND, OR, NAND, NOR, XOR, and XNOR gates. Only the first three will be used in this lab.
The NOT gate is the simplest of these three. It is an inverter. It has one input and produces its opposite as output. The symbol for a NOT gate is shown in Figure 1.
The truth table for a NOT gate has one input, or A in this example, and one output. The symbol for the operation is a horizontal bar over the variable. The truth table for a NOT gate is shown in Table 1.
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. The symbol for an AND gate is shown in Figure 2.
This gate has two inputs, or A and B in this example, and one output. 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 2.
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. The symbol for an OR gate is shown in Figure 3.
An OR gate has two inputs, or A and B in this example, and one output. The symbol for the OR operation is a plus (+). The truth table for an OR gate is shown in Table 3.
The truth table attached to each of these gates indicates when the gate will return a value of true. These tables are 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.
A truth table showing every possible 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. This simplified equation is used to build the digital circuit and will be a combination of the gates described above.
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 the truth table in Table 4, A, B, and C are the inputs and D is the output.
This table looks complex, but it can be simplified with a K-map (Table 5).
|0 0||0 1||1 1||1 0|
Look for the cells that have values in common. For example, the entire bottom row has ones in all its cells. This means that any time C is true, the output is true. This can be done in a more organized manner. Look for cells that form rectangles, where the number of cells in the rectangle is a power of 2: 1, 2, 4, or 8 and so on. The bottom row is an example of this. There is another small rectangle of two cells in the column with 1 1 at the top. This means that the output is true whenever A and B are true. The rectangles are allowed to overlap so the same cells can be used more than once, which happened here. Look for the biggest rectangles first, and keep finding smaller rectangles until all the cells with a 1 in them are used. This means that sometimes just single cells will remain at the end. In this example, all the cells containing a 1 were covered with two rectangles. This means is that if the conditions for either rectangle are true, the output will be true. Looking at the row and column labels, the bottom row is C, and for the column, the header is AB. This yields the simplified Boolean equation shown in Figure 4.
Figure 4: Simplified Boolean Equation
This equation meets the conditions in the truth table and achieves the desired result with the minimum number of logic elements.
Materials and Equipment
- A lab PC
- LabVIEW software
- An NI-ELVIS II+ prototyping board
- A 7432 IC (4 dual-input OR gates)
- A 7408 IC (4 dual-input AND gates)
- A 7404 IC (6 single input NOT gates)
- A lab PC with LabVIEW software
- An NI-ELVIS II+ with prototyping board
- Open LabVIEW and select Blank VI under Create Project
- Click on Window and select Tile Left & Right to set 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
- On the right window, pull down the View menu, select Tools Palette
- On the left window, pull down the View menu again, select Controls Palette. At this point, the screen should look like Figure 1. Note the Controls Palette and the Tools Palette, and their icons
For help with the operation of any LabVIEW icon, select Help from the main menu bar, choose Show Context Help, and click the icon for the operation that is unclear. It will be explained in the open window.
The approach for each of these projects is to place items on the front panel that the user will see and interact with. The corresponding items on the back panel will make the device work if the wiring is correct.
Note: Some tasks will be repeated and the same icons will be used. A LabVIEW digest at the end of this lab has references for faster navigation.
Design 1: Heating and Cooling System
Build a VI that simulates a heating and cooling system. The system must be controlled manually or automatically. Design the VI so that:
- The air conditioner is turned on when the temperature is above 95°F
- The heater is turned on when the temperature is less than 75°F
- The heater and the air conditioner are turned off when the temperature is between 60°F and 80°F
- In the front panel, drag and drop three round LEDs and three slide switches from the Boolean menu (under Modern in the Controls Palette) to represent the AC, the heater, and manual mode. Rename the LEDs and switches to "Manual," "AC," and "Heater" to make wiring easier
- Drag and drop a thermometer from the Numeric menu (under Modern in the Controls Palette) into the front panel. Right click the thermometer and select Change to Control and double check that the icon in the back panel is a control (see Figure 5). This means that the thermometer will act as an input and can be controlled by the mouse while the program is running
- In the back panel, insert a case structure from the Programming menu (in the Functions Palette) to control the manual and automatic operation of the AC and heater. Set the case structure to True/False if not already set to that
- In the back panel, wire the switch designated as "Manual" to the question mark symbol on the case structure. This means that when the manual switch is on ("true") the case structure will perform its true statement and when the manual switch is off ("false") the case structure will perform its false statement
- Because the temperature of the room only matters when the system is not in manual mode, move the thermometer icon into the False case structure. Click the small arrow next to "True" to toggle between the two cases
- In the true case, wire the AC and Heater switches directly to their corresponding LEDs. Insert a true constant from the Boolean menu in the Functions Palette under Programming. Wire the constant to the Manual LED so that the Manual LED is on when the Manual switch is "true"
- In the false case, insert two numeric constants, one greater than, and one less than. These will be used to control the VI in automatic mode
- Wire the thermometer to the less than and greater than. Set a numeric constant to 60 and the other to 80. Wire the 60 numeric constant to the less than symbol and the 80 numeric constant to the greater than symbol. Make sure the thermometer is wired to the top left of the inequalities and the constants are wired to the bottom left of the inequalities.
- Hit the run button to control and test your VI
- Have a TA check the VI. Once testing is completed, take a screenshot of the VI
- Save the VI
The VI will 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 board.
- Include the pre-written sub-VIs provided to interface with the circuit on the NI-ELVIS board.
- Insert the sub-VIs into the back panel by right-clicking on the back panel and clicking on Select A VI from the context menu that pops up. Open the Heating Control, Cooling Control, and Temperature Reading VIs located in the EG MENU shortcut on the Lab PC desktop
- Wire the output tunnels of the case structure for the heating and cooling indicators to the green terminals labeled Heat on the Heating Control and Cooling on the Cooling Control, respectively
- Connect the orange terminal labeled Result on the Temperature Reading node to the comparison operators used in the Automatic case. The Temperature Reading sub-VI will effectively replace the thermometer control
- Change the thermometer node to an indicator and connect the Result terminal on the Temperature Reading sub-VI to the thermometer. Since the Temperature Reading sub-VI replaces the thermometer, the thermometer will be used to monitor the temperature being read.
- Define a device constant for each of the pre-written sub-VIs. The device constant will determine the device(s) the sub-VIs read from and write to.
- Right-click on the purple Device Name or device name terminals on the sub-VI nodes using the Connect Wire tool. Mouse over Create on the context menu, and select Constant
- Verify that all three device constants are equivalent
- Ask the TA to check over the modifications. If correct, the TA will supply an NI-ELVIS board with a pre-built circuit.
- Connect the heat cube and its circuit to the NI-ELVIS board.
- Using two 100,000 Ω resistors (Brown, Black, Yellow), insert one end of each resistor into AIGND (row 18) of the NI-ELVIS board
- 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 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)
- Insert the positive and negative wires from the fan into Variable Power Supplies SUPPLY+ (row 48) and Variable Power Supplies GROUND (row 49) at the lower-left-hand corner of the NI-ELVIS board
- Connect the positive wire from the heating pad to DC +5V (row 54) on the lower-right-hand corner of the NI-ELVIS 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 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 board
- Attach the USB cable to the NI-ELVIS board, and power it. The device constants on the back panel should update to reference the NI-ELVIS device
- Run the VI
Design 2: Alarm System
Prior to Beginning the Procedure
Before moving on with the lab, the integrated circuits (IC) used 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 to send and receive signals from the AND/OR/NOT chips and determines if they are functioning properly.
First, load the chip onto the IC tester (Figure 8) and start the Serial Monitor on the Arduino program. 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 within the chip back into the Arduino. The code compares those results to the expected result. It displays each input/output pair and displays the final result showing if the chip is functional or defective. The goal is to determine if the gates are outputting the correct results. Remove the chip carefully from the IC tester.
Note: The two zoo enclosures must be assigned a numeric equivalent before the truth table is prepared for Step 1. Use 1 for Enclosure 1 and 0 for Enclosure 2. For the alarm output, use 0 to indicate the alarm should be off, and 1 to indicate that the alarm should be on.
- On a sheet of lined lab note paper from the EG Website, create a truth table that includes three inputs and one output. Assign the input variables. Include all possible scenarios for the hen, the corn, and the fox.
- Compute the output column. To do this, analyze the three inputs and 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.
- Note all the combinations that produce a 1 in the output column.
- Create a Boolean equation from this table that includes each of the inputs that produced a true output.
- Create a K-map. Draw a map that lists all the possible combinations. Use the Boolean equation to fill in the 1s on the K-map.
- Circle the pairs of 1s. The 1s may only be circled 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 discarded.
- This process yields a simplified Boolean equation. Write this simplified equation down.
- Draw a schematic diagram of the simplified Boolean equation.
- Have a TA sign the diagram.
- Test the circuit diagram. Build the circuit in LabVIEW. Use the simplified Boolean equation. Open LabVIEW and select New VI. Pull down the Window menu, select Tile Left and Right.
- Place three switches on the front panel that represent the hen, the corn, and the fox. Place one Boolean indicator on the front panel to represent the output.
- Open the Functions palette. Under Programming, select Boolean and choose the AND, NOT, and OR gates necessary for the circuit. A TA will assist in this process.
- Once the LabVIEW program is complete, have a TA check the circuit.
- Build the circuit on a prototyping board.
- On the board, identify each of the three black chips as an AND, OR, or NOT gate. To do this, read the number on the chip and match it with the list in the Materials and Equipment section of this lab. Use the pinouts in Figure 9 to wire the gates. Look for the notch at one end of each chip to orient the chip to diagrams in Figure 9 to match the pinouts.
- Power the chips. Insert one end of the wire into a hole on Row 54 (marked +5V) of the side breadboards. Insert the other end of the wire into the hole on the breadboard nearest Pin 14 on the chip. Repeat this process for all three chips.
- The breadboard is set up in the following manner:
- The leftmost and rightmost columns of slots (the ones in between the red and blue lines) are connected vertically.
- The rest of the breadboard is connected horizontally, however, there is a break that runs down the center of the breadboard, separating Columns A-E and F-J, as shown in Figure 10.
- Ground the chips using the same method. Insert one end of a wire into a hole on Row 53 (marked Ground) of the small breadboards and the other end into Pin 7 of the chip. Repeat this process for all three chips.
- Look at the top right corner of the breadboard to find the Digital Input/Output (DIO) holes. Select one of the DIO row of holes to use as one of the variables and begin wiring the circuit based on the simplified Boolean equation. Assign the other DIO rows for the remaining variables.
- Continue this process until the entire circuit is wired. Insert one end of the wire into the final output of the simplified Boolean equation. Attach the other end to any hole marked LED on the board.
- Plug in the NI-ELVIS II+ and connect the USB cable to the lab PC.
- Power on the NI-ELVIS II+ by toggling the switch on the back of the device. When the pop-up window appears, select NI-ELVISmx Instrument Launcher and click OK (Figure 11).
- Click on the DigOut Icon on the Instrument Launcher window (Figure 12).
- Click Run and toggle the switches corresponding to crocodile, bird, and fish.
- Have a TA check the circuit.
The lab work is now complete. Please clean up the workstation. Return all unused materials to a TA. Refer to Assignment for the instructions to prepare the lab report.
Individual Lab Report
Follow the lab report guidelines laid out in the page called Specifications for Writing Your Lab Reports in the Technical Communication section of this manual. The following points should be addressed in the appropriate section of the lab report:
- How is LabVIEW important today?
- Explain what LabVIEW is and describe how it helps engineers and scientists with their work
- 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?
- Discuss what an NI-ELVIS board is
- Were the objectives of the experiment achieved? If not why?
- Describe the advantages and disadvantages of using LabVIEW
- Suggest some improvements for the lab procedure
- Suggest improvements for each VI
- Describe how digital logic impacts the real world
- Describe the problem that was solved in the Introduction
- Describe how AND, OR, and NOT gates work
- What is a truth table? How does it contribute to obtaining a Boolean equation?
- 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
- Describe how to construct a digital logic circuit using Boolean equations and K-maps
- Explain why the alarm system did or did not work
- 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 the design changes that would be necessary if one of the enclosures used a bell as an alarm and the other used a horn
- Discuss other possible design/procedural improvements
- Describe how the final combinational logic circuit was obtained
- Insert a screenshot of the front and back panels in the report
IMPORTANT: Because the procedural elements in this lab are extensive, please include only the procedures employed to build Design 2, the lighting system, in the lab report. Do not document the procedures followed to build Design 1: the heating and cooling system.
Note: Though the Procedure section is limited to the lighting system, discuss both of the designs in the Data/Observations and Conclusion sections of the lab report.
Please consider the value of LabVIEW as a substitute for actual instruments and systems. The Data/Observations section should include information on ease of use, the LabVIEW user interface, and the available help options.
In describing the design of all the systems, show screenshots in the lab reports showing the VIs that were designed. Look at the Online Manual under "Instructional Web Pages" for instructions on how to take a screen shot and use it.
Remember: Lab notes must be taken. Experimental details are easily forgotten unless written down. EG1003 Lab Notes Paper can be downloaded and printed from the EG1003 Website. Use the lab notes to write the Procedure section of the lab report. At the end of each lab, a TA will scan the lab notes and upload them to the Lab Documents section of the EG1003 Website. One point of extra credit is awarded if the lab notes are attached at the end of the lab report. Keeping careful notes is an essential component of all scientific practice.
LabVIEW Digest of Common Tasks
Front Panel Controls and Indicators
How to get a slide control:
- On the Controls Palette, select the Numeric icon under the Modern category
- Select Horizontal Pointer Slide
- Click on the front panel to place the slide on the front panel at a specific location
How to get an LED indicator:
- On the Controls Palette, select the Boolean icon under the Modern category
- Select the Round LED icon from the icons shown
- Click on the front panel to place the LED at the location selected
- Rename the LED with a label that indicates what the LED stands for. To rename the LED, click on the Edit Text icon on the Tools Palette. Then click on the default Boolean label on each LED and replace it with the proper text
How to get a Numeric Input Control
- On the Controls Palette, click on the Numeric icon under the Modern category
- Click on the Numeric Control icon and click on the location the control is to be placed
How to get a Numeric Indicator Output
- On the Controls Palette, click on the Numeric icon under the Modern category.
- Click on the Numeric Indicator icon and click on the front panel location where the indicator is to be placed
Back Panel Objects
How to define a case structure
- On the Functions Palette, click on the Structures icon under the Programming category.
- Click on the Case Structure icon. Click on the back panel to place it at the desired location.
- By default, the case structure assumes it is being controlled by a Boolean control. What controls the case structure is any control that is wired to the question mark along the border. When being controlled by a Boolean control, the default cases are False and True; when being controlled by a numeric control, the default cases are 0 and 1. To add more cases, right-click anywhere on the Case Structure and select Add Case After.
- Define what happens for each case. Use arrows on each side of the caption to switch between cases. Switch to the case that is to be defined and fill the case structure with whatever needs to be done for that case. Make sure each case is fully defined. When output wires cross the border of the case structure, incomplete tunnels will be created. To complete the tunnels, an output wire must be wired to the tunnel for each case.
How to define an arithmetic operation
- On the Functions Palette, click on the Numeric icon under the Programming category
- On the Numeric Programming window, click on the icon for the desired arithmetic operation. Click on the front panel location where the icon goes
How to define Boolean constants (usually used to illuminate LEDs)
- On the Functions Palette, click on the Boolean icon under the Programming category.
- Click on the True Constant icon or False Constant icon , and then click the location of the constant on the back panel
How to wire
- Objects have inputs on their left side and outputs on their right side. The output (right side) of one object is always wired to the input (left side) of another object
- On the Tools Palette, chose the "Connect Wire" icon
- Click the object output that is to be wired from. Click the desired object input to wire to. The first object's output is now connected to the second object's input