Lecture notes

Download Report

Transcript Lecture notes

CS320n –Visual Programming
Introduction to LabVIEW
What We Will Do Today
• Look at the LabVIEW programming
environment
• Tests handed back next time and go over
in class
• Assignment 7 on web today
Visual Programming
Introduction to LabVIEW
2
What is LabVIEW
• A product of National Instruments
• Designed to provide a programming tool
for scientists and engineers to write
programs to analyze data gathered by
instrumentation
• Like Alice it is a graphical programming
language
• Unlike Alice it can be used to build a much
greater variety of programs
Visual Programming
Introduction to LabVIEW
3
What is LabVIEW
• LabVIEW = Laboratory Virtual Instrument
Engineering Workbench
• Loaded on the Painter Hall lab computers
• Can be downloaded from engineering
department web page
Visual Programming
Introduction to LabVIEW
4
Creating a LabVIEW program
• start LabVIEW
• Select the arrow on “New”
• On the menu that pops up select
“Blank VI”
Visual Programming
Introduction to LabVIEW
5
Virtual Instruments
• LabVIEW programs are called “VIs” which
stands for Virtual Instruments
• They consist of two parts
– a front panel
– a block diagram
• The front panel is a graphical user interface
– this is how a the user of a program will interact
with it
• The block diagram is the implementation of
the program, the code
Visual Programming
Introduction to LabVIEW
6
Working with a Program
• I find it best to set up the front panel and
block diagram side by side
– Select this choosing “Window” and “Tile Left
and Right” or by pressing the control key and
T at the same time
Visual Programming
Introduction to LabVIEW
7
Front Panel and Block Diagram
Visual Programming
Introduction to LabVIEW
8
Working with the Front Panel and
Block Diagram
• In LabVIEW the programmer can add
things to either the front panel or the block
diagram
• right click in either window to select the
programming elements (commands,
primitives) available
Visual Programming
Introduction to LabVIEW
9
Controls and Functions
• When you right click in the front panel a pop up
menu appears
• These are the controls for the front panel
• click on the pin to make the pop up menu
permanent
• the menu on the block diagram contains
functions
Visual Programming
Introduction to LabVIEW
10
Quick Demonstration of LabVIEW
• Write a program in LabVIEW to convert
kilometers to miles.
– The Milan - San Remo bicycle race was 294
kilometers this year
• Add controls and indicators to front panel
• Connect controls and indicators in block
diagram
Visual Programming
Introduction to LabVIEW
11
More Complicated Program
• LabVIEW comes with a large number of
example programs
• Open an existing LabVIEW program by
selecting “File” -> “Open” or by pressing
the control key and O
• Get to National Instruments Folder
(probably under Program Files)
– LabVIEW 7.0
• examples
– express
» Moonlanding.vi
Visual Programming
Introduction to LabVIEW
12
Moon Landing Simulator – Front Panel
Visual Programming
Introduction to LabVIEW
13
Moon Landing Simulator – Block Diagram
Visual Programming
Introduction to LabVIEW
14