Professional Documents
Culture Documents
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 youve 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 youll be doing in this class deal with simulations. This week, youll be introduced to some
basic structures of LabVIEW by first simulating a function generator, then simulating some digital
logic circuits.
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.
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, then go to the File menu and
select New-> Blank 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 Help->VI, Function, & How-to Help, 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, youll 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 Num
Ctrls Num Ctrl 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 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 3.
Change the dropdown selection from Significant Digits to Digits of Precision and
enter 0 (zero) in the corresponding field. Click OK.
Figure 3. Format and Precision dialog window
4. At this point it is time to put down some more controls. Find the Dial under the controls
palette, or using Controls Num Ctrls 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 Graph. This can be found
under Controls Graph Inds 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 4.
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 block diagram window by
choosing Window Show Block Diagram from the menu on the top of the screen. This
will open a window like that of Figure 6. If the window doesnt look exactly like that of
Figure 6, dont 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.
9. Click on the orange box below the labels to move components around. Drag the components
labeled Amplitude, Frequency, and Function Number to the left side of the window so that
theyre arranged in a column.
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. The next step will be to draw a case selection box. This can be done by
choosing Functions All 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 6 below. (Later in the lab, you will be asked to
explain what the case statement does. For now, the case selection box can be thought of as a
graphical representation of a case statement in a programming language.)
12. 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 on the selector label 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.
13. Then to make the case selection work as designed, we need to give it some value that it can
select from. Again, the mouse is context sensitive and changes to suit what it thinks you
want to do. When its on a connector, like one of the little triangle connectors, it will change
to something that looks like a little spool of wire. If you left click on the mouse when it is
on top of one of the connectors, the connector will be highlighted. Hold the button down and
drag the wire to the other connector. Click on the blue box below Function Number and drag
to the little question mark on the side of the Case Selection Box.
14. Before continuing, make sure that case 1 is in the little box at the top of the Case Selection
Box. Now right click between the arrows and choose Make this the Default Case from the
menu. This sets case 1 as the default if no case is selected. When done you should have
something that looks like Figure 7.
15. 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 Analysis Simulate Sig. Place this in the
middle of the case selection box. You can double click on this component at any time to
configure its properties but as soon as you drop the icon inside the case statement the
Configure Simulate Signal Window will pop up whether you want it to or not. In the
Configure Simulate Signal Window:
a. Under Timing, set Samples/second (Hz) to 1000
b. Next to Number of Samples, uncheck the Automatic checkbox.
c. Set Number of Samples to 1000.
These settings will set the x-axis to 1 second.
16. The Configure Simulate Signal window should look similar to Figure 8. Click OK.
17. Case 2 will be a square wave. Switch to case 2 by clicking on the arrow on the right on top
of the case selection box. Inside of case 2, place another Simulate Sig component in the
middle of the case selection box. In the Configure Simulate Signal window, change the wave
type to Square. Make the same changes as described in 15a-c.
18. Case 3 will be a triangle wave. Switch to case 3. By now you should be able to figure out
how to add the triangle wave simulator. (Its just like the last two steps!) You should end up
with a block diagram window that looks like Figure 9.
Figure 9: Diagram window after adding the waveforms to the Case Selection Box
19. Wire the output of the Frequency function to the Frequency input connector 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.
Figure 10: Completed Diagram Window after wiring the Sine Wave Function
20. Repeat this same process for the other two cases also. This exact wiring scheme works for all
three functions.
21. 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.
Figure 10: Completed Front Panel Window continuously executing the Triangle Function
To Turn In:
22. Demonstrate to your TA that the simulator you built works, and have your TA initial your
data sheet in the appropriate spot.
23. 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.
24. On your data sheet, write a few sentences about what the differences are between the Front
Panel window and the Block Diagram window.
2. Add a Boolean toggle switch to the Front Panel from the Controls Palette. This is found
under Controls Buttons & Switches {Any type of switch}. Name this A. Add
another switch and name this B.
3. Add a Boolean indicator from the LEDS menu. This is an LED that will light up when the
Boolean is in the True state. Name this X (or something appropriate).
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.
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.
1.
Table 2: Prelab Truth Table for Figure 1
Inputs Output
A B X
2.
Figure 3: Draw the circuit for Table 2 above
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 1: Truth table for simulation or prelab circuit
Inputs Output
A B X
0 0
0 1
1 0
1 1
2. TA initials: ________
1. TA initials: ________