Lab 2: Circuit Simulation



Introduction to LabVIEW

Objective

LabVIEW is a type of simulation software, but unlike Spice, LabVIEW can be used to connect to the real world. Many of the devices that you’ve already used in the lab have the ability to be connected to a LabVIEW computer by what is called GPIB (General Purpose Interface Bus). This allows LabVIEW to take user-defined inputs and create outputs for real world instruments such as power supplies and multimeters.

The labs you’ll be doing in this class deal with simulations. This week, you’ll be introduced to some basic structures of LabVIEW by first simulating a function generator, then simulating some digital logic circuits.

Equipment and Components

LabVIEW!

Prelab (25 points) – Due at the beginning of lab

1. Figure 1 shows a logic circuit. On your data sheet, give the truth table for the circuit.

[pic]

Figure 1: Prelab Logic Circuit

2. Table 1 a hypothetical logic circuit output. On your data sheet, draw a circuit that would produce the output shown in Table 1 from the inputs shown.

Table 1: Truth Table

|Inputs |Output |

|A |B |X |

|0 |0 |1 |

|0 |1 |0 |

|1 |0 |0 |

|1 |1 |1 |

3. Before going to lab, open up LabVIEW by going to the File menu and selecting New IV. There are thee main ‘palettes’ that allow you to build in and interact with LabVIEW. What are they? Use the ‘LabVIEW Environment’ section of the Help menu, and write the three palette names and tell what they do on your data sheet.

Part 1: Function Generator

The first portion of our show will be to build a function generator from the step-by-step instructions that follow. At the end, you’ll demonstrate to your instructor that the simulator works, and answer a few questions about its operation on your data sheet.

1. Open LabVIEW which can be found in the Start Menu as “National Instruments LabVIEW” or something closely related. Once that is open choose, “New VI” from the window. This will open at least one new window. If there are two windows it is alright, we will need them both.

2. Put down a digital control from the controls palette. This can be done by Controls ( Numeric ( Digital Control then click on the Front Panel Window. Now type Function Number before doing anything else. This will save us some work in the future. Once this is done you should have a window like that of Figure 3.

[pic]

Figure 2: Front panel after Step 2

3. Right click on the new control that you just placed and select Format & Precision from the menu. This will give a new window titled “Format & Precision” like that of Figure 4. In the Format drop down menu, make sure its reads Decimal. Then in the Digits of Precision field enter 0 (zero) and click OK.

[pic]

Figure 3: Format and Precision Window

4. At this point it is time to put down some more controls. Find the Dial under the controls palette, or using Controls ( Numeric ( Dial. Place this on the Front Panel Window and type Amplitude. This will be the amplitude of the waveforms.

5. Place another dial in the same manner and type Frequency. This will be the frequency of the waveforms.

6. Now, under the Graph part, place a Waveform Chart. This can be found under Controls ( Graph ( Waveform Graph and type in Waveform Output before doing anything further. Right click on the Waveform Chart and select Visible Items ( Plot Legend from the menu. This will remove the Plot Legend from the chart. After this the Front Panel should look like that of Figure 5.

[pic]

Figure 4: Completed Front Panel after adding the Waveform Graph

7. This will take care of the Front Panel for now. Now switch to the diagram window by choosing Window ( Show Diagram from the menu on the top of the screen. This will open a window like that of Figure 6. If the window doesn’t look exactly like that of Figure 6, don’t worry, it is about to be changed anyway. This is where the coding for LabVIEW takes place. Like SPICE, LabVIEW has its own work environment.

[pic]

Figure 5: LabVIEW Diagram Window

8. Switch to the Position/Size/Select tool from the Tools Palette. This is the tool that looks like a little arrow. This allows the movement and selection of components in the Front Panel and Diagram windows.

9. Click on the orange box below the word Frequency and drag it over and place it under the Amplitude box.

10. Right click on the orange box for the Function Number and choose Representation ( I8 from the pop up menu. This will change the indicator from a double precision variable to an integer value.

11. Now create a numeric constant by choosing Functions ( Numeric ( Numeric Constant, and place this on the Diagram window near the Frequency box. Now you should type 128 into the constant box before proceeding.

12. The next step would be to draw a case selection box. This can be done by choosing Functions ( Structures ( Case. Now click and drag from somewhere near the amplitude box to somewhere down towards the right of the screen. You should get something that looks like Figure 7 below.

[pic]

Figure 6: Diagram window before adding the waveforms

13. The tricky part begins. Right click on where the case box says “True” and select Add Case After. Enter 1 from the key board. Repeat this 2 more times entering 2 and 3 from the keyboard. Now, click between the two arrows and go back to one of the two cases (“True” or “False”). Then right click again and select Delete This Case from the menu. Repeat this for the “False” (or “True”) case also.

14. Then to make the case selection work as designed, we need to give it some value that is can select from. This is done by changing to the Connect Wire tool in the Tools Palette. This tool looks like a spindle of wire. Click on the blue box below Function Number and drag to the little question mark on the side of the Case Selection Box. When done you should have something that looks like Figure 8.

15. Before continuing, make sure that case “1” is in the little box at the top of the Case Selection Box. Now right click and choose Make this the Default Case from the menu. This sets case 1 as the default if no case is selected.

[pic]

Figure 7: Diagram window after case additions and wire

16. Now from here we have to add the specific waveforms. Under case 1 we are going to put a sine wave. This can be found under Functions ( Analyze ( Signal Processing ( Signal Generation ( Sine Wave.vi. Place this in the middle of the case selection box.

17. Switch to case 2 by click on the arrow on the right on top of the case selection box. Inside of case 2 place a square wave. This can be found under Functions ( Analyze ( Signal Processing ( Signal Generation ( Square Wave.vi. Place this in the middle of the case selection box.

18. Switch to case 3 by clicking on the arrow on the right on top of the case selection box. For case 3 place a triangle waveform. This can be found under Functions ( Analyze ( Signal Processing ( Signal Generation ( Triangle Wave.vi. Place this in the middle of the case selection box. Return to case 1 and be sure that you have something that looks like Figure 9.

[pic]

Figure 8: Diagram window after adding the waveforms to the Case Selection Box

19. At this point there needs to be a few additions made to the outside of the Case Selection Box. Place a division box near the frequency box. This can be found under Functions ( Numeric ( Divide. Once this is placed, wire the top of the division box to the frequency box, and the bottom to the constant 128 box.

20. Wire the output of the division box to the ‘f’ box of the sine wave. Wire the 128 constant to the ‘samples’ of the sine wave. Then wire the amplitude box to the ‘amplitude’ of the sine wave. Then wire the ‘sine wave’ output to the Waveform Output box. Check this against Figure 10 to verify that it is correct.

[pic]

Figure 9: Completed Diagram Window after wiring the Sine Wave Function

21. Repeat this exact process for the other two cases also. This exact wiring scheme works for all three functions. The figures of the other two functions are shown below in Figure 11 and Figure 12.

[pic]

Figure 10: Case 2 the Square Wave Function

[pic]

Figure 11: Case 3 the Triangle Wave Function

22. Return to the Front Panel Window and click the ‘Run Continuously’ button. This button looks like two arrows chasing each other. Now you can change the values of Amplitude, Frequency, and Function Number. Notice that if Function Number is less than 1 or greater than 3 the waveform defaults back to the sine wave. The simulation is complete.

To Turn In:

23. Demonstrate to your TA that the simulator you build works, and have your TA initial your data sheet in the appropriate spot.

24. What is a case structure? On your data sheet write a paragraph describing what a LabVIEW case structure does in general, and how it operates, then describe how it operates specifically in your function generator simulator.

25. On your data sheet, write a few sentences about what the differences are between the Front Panel window and the Block Diagram window.

Part 2: Logic Simulation

1. In this part of the lab we are going to create a digital logic circuit. The circuit you’ll build is the one that you drew using Table 1.

2. Add a Boolean toggle switch to the Front Panel from the Controls Palette. This is found under Controls ( Boolean ( {Any type of switch}. Name this ‘A’. Add another switch and name this ‘B’.

3. Add a Boolean indicator under the same menu. This is an LED that will light up when the Boolean is in the True state.

4. Switch to the Diagram and wire up the circuit you drew from the prelab (Table 1).

5. Switch back to the Front Panel and run the circuit continuously and fill in the truth table for the circuit into Table 3 on your data sheet.

6. Demonstrate operation for the TA and have the TA initial your sheet.

Part 3: Logic Simulation II

Simulate a circuit in LabVIEW that behaves according to the truth table in Table 4. As a hint, you can do more than two inputs of an ‘AND’ or ‘OR’ gate, add the following component to the diagram window (Functions ( Numeric ( Compound Arithmetic). Once this is done, right click on the input side and choose Add Input until the desired number of inputs is reached. The mode can be changed also, by right clicking and choose Change Mode ( {Desired Mode} on the output side.

[pic]

Figure 12: Compound Arithmetic with several

Alternatively, you can reduce the truth table using what you know from digital logic class, then build the simpler circuit. Have your TA initial your data sheet after you demonstrate it.

Table 1: Assignment truth table

|Inputs |Output |

|A |B |C |X |

|0 |0 |0 |1 |

|0 |0 |1 |0 |

|0 |1 |0 |0 |

|0 |1 |1 |1 |

|1 |0 |0 |1 |

|1 |0 |1 |1 |

|1 |1 |0 |0 |

|1 |1 |1 |1 |

Lab 5: Introduction to LabVIEW

Name_____________________________ Section________

Prelab (due at the beginning of lab)

1.

Table 2: Prelab Truth Table for Figure 1

|Inputs |Output |

|A |B |X |

| | | |

| | | |

| | | |

| | | |

2.

Figure 13: Draw the circuit for Table 2 here

3. The three palettes and what they do:

Part 1: Measurement of Time Varying Signals

1. Appropriate spot for TA initials for part one: _________

2. Write a paragraph describing what a LabVIEW case structure does in general, and how it operates, then describe how it operates specifically in your function generator simulator.

3. Write a few sentences about what the differences are between the Front Panel window and the Block Diagram window.

Part 2: Logic Simulation

1.

Table 2: Truth table for simulation or prelab circuit

|Inputs |Output |

|A |B |X |

|0 |0 | |

|0 |1 | |

|1 |0 | |

|1 |1 | |

2. TA initials: ________

Part 2: Logic Simulation II

1. TA initials: ________

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download