LabVIEW Assignment

profileamaabd
labview_tutorial.pdf

P.S. Nair

EGGN 100: Introduction to Engineering

LabVIEW Tutorial

Dr. Pradeep Nair Associate Professor, Computer Engineering

Objectives of the Tutorial: To generate, display and modify a desired signal shape using LabVIEW graphical programming LabVIEW Description: • LabVIEW is the abbreviation for Laboratory Virtual

Instrumentation Engineering Workbench • LabVIEW is a product from National Instruments

Corporation (NI) • LabVIEW is a system design platform that makes use of

Visual Programming/Graphical Programming • In visual programming, we make use of visual

programming elements known as Virtual Instruments, or VIs, instead of writing programs/code using traditional text-based instructions

P.S. Nair

• In other words, we can say that a LabVIEW program is a collection of VIs

• Visual/Graphical Programming makes the programming task easier because it allows you to drag- and-drop icons that represent programming constructs

• Some of the things that LabVIEW can do (it is a

powerful design platform!):  Generate inputs (also known as input signals)  Create a virtual system that meets a set of required

specifications  Analyze the behavior of the system (outputs/output

signals) for a set of inputs  Record/store behavior-related data of the system  Acquire data from external hardware instruments  Communicate with external hardware instruments

Components of a LabVIEW Program: • User Interface built by the user (you); this interface is

known as the Front Panel • A window that contains the VIs that make up the

program, known as the Block Diagram window • The front panel is built using Controls and Indicators

P.S. Nair

• Controls are the various input mechanisms that are available. Examples: Virtual dials, virtual knobs, virtual push-buttons etc.

• Indicators are the output mechanisms. Examples are Graphs, Virtual output displays, virtual LEDs etc.

LabVIEW Programming Sequence:

Build Front Panel  Add Controls to Front Panel  Add System/Process-VIs in Block Diagram window Add Indicators to Front Panel Make connections in Block Diagram window  Run Program in Front Panel Analyze ResultsStore Results, if necessary

P.S. Nair

Using LabVIEW to Generate, Display and Modify Signals

1. Open LabVIEW

2. Click FileNewVI. Then expand the box ‘From Template’. After this, select ‘Tutorial (Getting Started)’’Generate and Display’. Click OK.

P.S. Nair

3. This will open up two new windows: Front Panel and Block Diagram. The front panel is where the controls and indicators are placed.

In this part of the tutorial, the process required to generate a sine wave has already been added to the block diagram and the required controls and indicators have already been added to the front panel. We will now learn how to run this program and observe the sine wave output.

4. The front panel and the block diagram look like this:

P.S. Nair

5. The block diagram is the core of the graphical program. It contains structures and VIs that interact with the front-panel objects. It looks like this:

6. Click on the ‘Run’ button in the front panel to run the

program. It looks like this: You should now see a sine wave being displayed on the front-panel indicator. When the program is running, the ‘Run’ button changes in appearance and color, like this:

7. Stop the execution of the program by clicking on the control named ‘STOP’ in the front panel:

P.S. Nair

8. Next, we will add a ‘Knob’ control (shown below) to the front panel. For this, first select ‘View’ ‘Controls’ ‘Num Ctrls’. Then click on ‘Knob’ and then, drag the ‘Knob’ control and drop it inside the front panel.

9. Save the file by clicking ‘File’ ‘Save As’ in the front

panel. Choose the file name as ‘SignalGeneration.vi’. Save in Desktop.

10. Next, we will change the signal display type from Sine wave to a ‘Sawtooth’ wave. For this, first click on the block diagram window. Then double click on the VI block that is named as ‘Simulate Signal’.

P.S. Nair

11. You will now see that a new window pops up, as shown below. Change the ‘Signal type’ to ‘Sawtooth’. Click OK.

12. If you run the program in the front panel now, you will see the new Sawtooth signal in the front panel

13. Highlight the ‘Simulate Signal’ block by clicking over it once in the block diagram window and keep the cursor over the lower part of the ‘Simulate Signal’ block. A double-sided arrow will appear. Click and pull downwards till you can see an input called ‘Amplitude’

P.S. Nair

being displayed. An input is denoted by an arrow feeding into the ‘Simulate Signal’ block and an output is denoted by an arrow feeding leaving the ‘Simulate Signal’ block

14. In the block diagram, move the ‘Knob’ VI to the left of

the ‘Simulate Signal’ block. Click on the output of the ‘Knob’ VI and draw out a wire (click and pull till the termination point). Terminate the wire at the input of ‘Amplitude’ in the ‘Simulate Signal’ VI. The amplitude of the Sawtooth wave generated can now be controlled from the front panel using the knob. Run the program to verify this and then stop execution using ‘STOP’.

15. Next, we will scale the amplitude of the signal according to a formula. For this, first click on the wire connecting the ‘Simulate Signal’ VI with the ‘Waveform Graph’

P.S. Nair

and delete the wire using the Delete button on your keyboard.

16. In the block diagram window, click on ‘View’’Functions Palette’ ‘Arith & Compar’  ‘Formula’. Drag the ‘Formula’ VI to the block diagram window, as shown below:

17. Double-click on the ‘Formula’ VI and change the label in the first label field (in this example, it is X1) to the name of the output wave generated by the ‘Simulate Signal’ VI (in this example it is ‘Sawtooth’). The display field in the ‘Formula’ VI will now read as ‘Sawtooth’. Replace it by ‘Sawtooth * 2’. Click OK. This VI will

P.S. Nair

now multiply the incoming sawtooth signal amplitude by 2.

18. Connect the ‘Sawtooth’ output of the Simulate Signal’ VI to the ‘Sawtooth’ input of the ‘Formula’ VI using a wire.

19. Connect the ‘Result’ output of the Simulate Signal’ VI to the input of the ‘Waveform Graph’ VI using another wire.

20. Run your program in the front panel and verify that the signal amplitude of the original sawtooth waveform is now scaled by 2. Also verify that the amplitude is still sensitive to the input from the knob.