CST115 Introduction to Computer Programming Lecture 3 Introduction

  • Slides: 25
Download presentation
CST-115 Introduction to Computer Programming Lecture 3 - Introduction to the Lab. VIEW Enviornment

CST-115 Introduction to Computer Programming Lecture 3 - Introduction to the Lab. VIEW Enviornment Prof. M. Higazi

What is Lab. VIEW? • Lab. VIEW (short for Laboratory Virtual Instrument Engineering Workbench),

What is Lab. VIEW? • Lab. VIEW (short for Laboratory Virtual Instrument Engineering Workbench), developed by National Instruments, is a system-design platform and development environment for a graphical programming language • The programming language used in Lab. VIEW, also referred to as G, is a dataflow programming language • A program created in Lab. VIEW is known as a Virtual Instrument (VI). • Each VI has three components: a block diagram, a front panel, and a connector panel

Lab. VIEW Graphical Development System • Graphical Programming Environment • Compile code for multiple

Lab. VIEW Graphical Development System • Graphical Programming Environment • Compile code for multiple OS and devices • Useful in a broad range of applications

 • • • Virtual Instrumentation Design Applications – Signal and Image Processing –

• • • Virtual Instrumentation Design Applications – Signal and Image Processing – Embedded System Programming A single graphical development • (PC, DSP, FPGA, platform Microcontroller) – Simulation and Prototyping Design Prototype Deploy – And more… Control – Automatic Controls and Dynamic Systems – Mechatronics and Robotics – And more… Measurements – Circuits and Electronics – Measurements and Instrumentation – And more…

Virtual Instrumentation With Lab. VIEW

Virtual Instrumentation With Lab. VIEW

Lab. VIEW Programs Are Called Virtual Instruments (VIs) Front Panel • Controls = Inputs

Lab. VIEW Programs Are Called Virtual Instruments (VIs) Front Panel • Controls = Inputs • Indicators = Outputs Block Diagram • Accompanying “program” for front panel • Components “wired” together

 • Lab. VIEW programs are called virtual instruments (VIs). • Controls equal inputs,

• Lab. VIEW programs are called virtual instruments (VIs). • Controls equal inputs, indicators equal outputs. • • Each VI contains three main parts: Front Panel – How the user interacts with the VI. Block Diagram – The code that controls the program. Icon/Connector – Means of connecting a VI to other VIs. • The Front Panel is used to interact with the user when the program is running. Users can control the program, change inputs, and see data updated in real time. • Controls are used for inputs- adjusting a slide control to set an alarm value, turning a switch on or off, or stopping a program. • Indicators are used as outputs. Thermometers, lights, and other indicators indicate values from the program. These may include data, program states, and other information. • Every front panel control or indicator has a corresponding terminal on the block diagram. When a VI is run, values from controls flow through the block diagram, where they are used in the functions on the diagram, and the results are passed into other functions or indicators.

VI Front Panel Toolbar Boolean Control Icon Graph Legend Waveform Graph Plot Legend Scale

VI Front Panel Toolbar Boolean Control Icon Graph Legend Waveform Graph Plot Legend Scale Legend

VI Block Diagram Toolbar Divide Function Sub. VI Graph Terminal Wire Data While Loop

VI Block Diagram Toolbar Divide Function Sub. VI Graph Terminal Wire Data While Loop Structure Numeric Constant Timing Function Boolean Control Terminal

 • The block diagram contains this graphical source code • Front panel objects

• The block diagram contains this graphical source code • Front panel objects appear as terminals on the block diagram • Additionally, the block diagram contains functions and structures from built-in Lab. VIEW VI libraries • Wires connect each of the nodes on the block diagram, including control and indicator terminals, functions, and structures

Controls and Functions Palettes Controls Palette (Front Panel Window) Functions Palette (Block Diagram Window)

Controls and Functions Palettes Controls Palette (Front Panel Window) Functions Palette (Block Diagram Window)

 • What Types of Controls and Indicators are Available? Numeric Data – Number

• What Types of Controls and Indicators are Available? Numeric Data – Number input and display – Analog Sliders, Dials, and Gauges • Boolean Data – Buttons and LEDs • Array & Matrix Data – – – • Numeric Display Chart Graph XY Graph Intensity Graph 3 D graph: point, surface, and model Decorations – Tab Control – Arrows • Other – Strings and text boxes – Picture/Image Display – Active. X Controls Express Controls Palette

Tools Palette • Floating Palette • Used to operate and modify front panel and

Tools Palette • Floating Palette • Used to operate and modify front panel and block diagram objects. Automatic Selection Tool Operating Tool Scrolling Tool Positioning/Resizing Tool Breakpoint Tool Labeling Tool Probe Tool Wiring Tool Color Copy Tool Shortcut Menu Tool Coloring Tool

Status Toolbar Run Button Continuous Run Button Abort Execution Pause/Continue Button Text Settings Align

Status Toolbar Run Button Continuous Run Button Abort Execution Pause/Continue Button Text Settings Align Objects Distribute Objects Reorder Resize front panel objects Additional Buttons on the Diagram Toolbar Execution Highlighting Button Step Into Button Step Over Button Step Out Button

Creating a VI Front Panel Window Block Diagram Window When you create an object

Creating a VI Front Panel Window Block Diagram Window When you create an object on the Front Panel, Control a terminal will. Terminals be created on the Block Diagram. These terminals give you access to the Front Panel objects from the Block Diagram code. Indicator Terminals

Creating a VI – Block Diagram In addition to Front Panel terminals, the Block

Creating a VI – Block Diagram In addition to Front Panel terminals, the Block diagram contains functions. Each function may have multiple input and output terminals. Wiring to these terminals is an important part of Lab. VIEW programming.

Wiring Tips – Block Diagram Wiring “Hot Spot” Use Automatic Wire Routing Click To

Wiring Tips – Block Diagram Wiring “Hot Spot” Use Automatic Wire Routing Click To Select Wires Clean Up Wiring

Dataflow Programming • Block diagram executes dependent on the flow of data; block diagram

Dataflow Programming • Block diagram executes dependent on the flow of data; block diagram does NOT execute left to right • Node executes when data is available to ALL input terminals • Nodes supply data to all output terminals when done

Dataflow Programming • Block diagram execution – Dependent on the flow of data –

Dataflow Programming • Block diagram execution – Dependent on the flow of data – Block diagram does NOT execute left to right • Node executes when data is available to ALL input terminals • Nodes supply data to all output terminals when done

Help Options Context Help • Online help • Lock help • Simple/Complex Diagram help

Help Options Context Help • Online help • Lock help • Simple/Complex Diagram help • Ctrl + H Online reference • All menus online • Pop up on functions in diagram to access online info directly

Tips for Working in Lab. VIEW • Keystroke Shortcuts – <Ctrl+H> – Activate/Deactivate Context

Tips for Working in Lab. VIEW • Keystroke Shortcuts – <Ctrl+H> – Activate/Deactivate Context Help Window – <Ctrl+B> – Remove Broken Wires From Block Diagram – <Ctrl+E> – Toggle Between Front Panel and Block Diagram – <Ctrl+Z> – Undo (Also in Edit Menu) • Tools» Options… – Set Preferences in Lab. VIEW • VI Properties–Configure VI Appearance, Documentation, etc.

Debugging Techniques • Finding Errors Click on broken Run button Window showing error appears

Debugging Techniques • Finding Errors Click on broken Run button Window showing error appears • Execution Highlighting • Probe Click on Execution Highlighting button; data flow is animated using bubbles. Values are displayed on wires. Right-click on wire to display probe and it shows data as it flows through wire segment You can also select Probe tool from Tools palette and click on wire

Open and Run Lab. VIEW Start» All Programs» National Instruments Lab. VIEW » Startup

Open and Run Lab. VIEW Start» All Programs» National Instruments Lab. VIEW » Startup Screen: Start from a Blank VI: New» Blank VI or Start from an Example: Examples» Find Examples…

Open and Run a Virtual Instrument Example finder

Open and Run a Virtual Instrument Example finder

Open and Run a Virtual Instrument 1. Select Start » Programs » National Instruments

Open and Run a Virtual Instrument 1. Select Start » Programs » National Instruments » Lab. VIEW to launch Lab. VIEW. The Lab. VIEW dialog box appears. 2. Select Find Examples from the Help menu. The dialog box that appears lists and links to all available Lab. VIEW example VIs. 3. You can browse examples by categories, or you can use a keyword search. Click the Search tab to open the keyword browser. 4. In the “Enter Keyword(s)” box enter “Pulse” 5. Find and double-click Pulse Demo. vi to launch this example. 6. This will open the “Pulse Demo. vi” Front Panel. 7. Run and experiment with this example VI.