Electronics PCC Walter Lara A Graphical Programming Language - - PowerPoint PPT Presentation

electronics
SMART_READER_LITE
LIVE PREVIEW

Electronics PCC Walter Lara A Graphical Programming Language - - PowerPoint PPT Presentation

EET EET-241: Programming For Electronics PCC Walter Lara A Graphical Programming Language Allows to create programs with graphical symbols instead of text code like traditional programming languages (C, C++, Java, etc.) Performs many


slide-1
SLIDE 1

EET EET-241: Programming For Electronics

PCC Walter Lara

slide-2
SLIDE 2

A Graphical Programming Language

  • Allows to create programs with graphical symbols instead of text code

like traditional programming languages (C, C++, Java, etc.)

  • Performs many of the same functions requiring less time and programming

experience

  • LabView programs are called Virtual Instruments (VI)
  • Because of their appearance and operation VI imitate actual

instruments

  • However, they are analogous to main programs, functions and subroutines

from traditional languages

slide-3
SLIDE 3

Why LabView?

  • Ideal for experimental lab simulations because the VI actually imitate

real-world instruments.

  • Replacing actual instruments with virtual instruments allows flexibility

and reduced project cost avoiding to purchase expensive laboratory hardware to perform their functions.

slide-4
SLIDE 4

VI Architecture

  • A VI consist of two main part which appear as two major windows on

the development environment:

  • The Front Panel
  • The Block Diagram
slide-5
SLIDE 5

The Front Panel

  • The Front Panel is a window where you create your virtual

instruments.

  • This is where the user interacts with the program by entering data

and viewing results. It is called the Front Panel because it is supposed to look like the front panel of an instrument or a group of instruments.

  • The Front Panel virtual instruments generally come in two forms: user

inputs called controls and the program outputs called indicators.

slide-6
SLIDE 6

Front Panel Example

slide-7
SLIDE 7

The Block Diagram

  • The Block Diagram is a window where the graphical code is created. This is

the "programming" that replaces text syntax in traditional programming languages.

  • What you see in this window are icons called nodes which are classified as:
  • Terminals - represent the controls and indicators on the Front Panel.
  • Functions – operations like add, subtract, compare or constant
  • Structures – program flow constructs such as while loops, for loops and case and

sequence structures

  • Nodes are wired together for logical functioning of the program
  • Have one or more input and/or output terminals called connectors to wire to and

from.

slide-8
SLIDE 8

Block Diagram Example

slide-9
SLIDE 9

A Datafl flow Programming Language

  • Labview uses dataflow:
  • A node executes its function only after it has received data from a previous

node.

  • After the node is through with its function, the processed data is transferred

via the wire to the next node.

  • Traditional text-based languages (C, C++, Java, etc.) use control flow
  • Code executes sequentially in the order in which is written
slide-10
SLIDE 10

Waveform Chart

  • The Waveform Chart acts as a real-time data plotter
  • As each new data point is generated on the block diagram, this single

value is passed to the Waveform Chart’s terminal and immediately displayed on the front-panel plot

  • Found on front panel under Controls->Modern->Graph->Waveform

Chart

slide-11
SLIDE 11

Waveform Graph

  • The Waveform Graph accepts an entire block of data that has been

generated previously

  • The Waveform Graph’s terminal accepts data as a one-dimensional

array:

  • Numerical value is y-value of the plot
  • Index is x-value
  • Found on front panel under Controls->Modern->Graph->Waveform

Graph

slide-12
SLIDE 12

The While Loop

  • A Structure used to control repetitive operations
  • Executes the subprogram (called subdiagram) within its borders until

a specified Boolean value is no longer FALSE

  • Equivalent Pseudo-code:

Do Execute subprogram (which sets condition) While condition is FALSE

  • Iteration terminal (i) initialized to zero and incremented at the end of

each iteration if condition is FALSE.

  • Found under Functions->Programming->Structures->While Loop
slide-13
SLIDE 13

The For Loop

  • Another Structure used to control repetitive operations
  • Executes the subprogram (called subdiagram) within its borders the

number of times specified by the count terminal (N)

  • Equivalent Pseudo-code:

For i = 0 to N -1 Execute subprogram (which sets condition)

  • Found under Functions->Programming->Structures->For Loop
slide-14
SLIDE 14

Wire Colors

slide-15
SLIDE 15

MathScript & Formula Nodes

  • Encoding mathematical relations using graphical programming can be

more cumbersome than using text-based languages

  • LabView solution: MathScript Node
  • Resizable box that allows entering text-based math formulas directly onto

Block Diagram

  • C-like syntax
  • Supports common math operations (+, -, x …), trigonometric & logarithm

functions, Boolean algebra, comparison and conditional branching

  • Arrays and iteration capabilities
  • Available from Functions->Programming->Structures
  • Formula Node supports subset of MathScript Node
slide-16
SLIDE 16

XY Graph

  • Produces Cartesian-style plots.
  • Each point located at its x, y value
  • The XY Graph’s terminal accepts a cluster of two one-dimensional

arrays:

  • Array of X values
  • Array of Y values
  • Found on front panel under Controls->Modern->Graph->XY Graph
slide-17
SLIDE 17

USB-6008 Device

  • Low-cost, multifunction data acquisition device (DAQ)
  • USB interface
  • Eight analog input (AI) channels (differential or single-ended):
  • Range: ±20 V
  • Resolution: 12-bit differential or 11-bit single-ended
  • Maximum Sample Rate: 10 KS/s
  • On-demand or buffered hardware-timed support
  • Two analog output (AO) channels
  • Range: 0 to +5 V
  • Resolution: 12-bit
  • Maximum Update Rate: 150 S/s
slide-18
SLIDE 18

USB-6008 Device (Cont’d)

  • Twelve digital input/output channels (open-collector)
  • One configurable input (PFI 0)that can be use as:
  • Digital trigger input
  • Event counter input
slide-19
SLIDE 19

USB-6008 Pinout

slide-20
SLIDE 20

DAQmx Simulated Device

  • Replica of any device
  • Allows to develop/operate any program without hardware
  • Behave similar to a real device
  • Analog input is limited to a noisy sine wave
  • Analog output only verify data against valid limits
  • Created via MAX
slide-21
SLIDE 21

Shift Registers

  • Allows values created on a previous iteration of a loop to be used on

the current iteration

  • A set of terminals on the loop behave as a First-In, First-Out (FIFO)

digital shift register

slide-22
SLIDE 22

The Case Structure

  • Allows conditional branching in LabView
  • Analogous to if-else statement in text-based languages
  • Found under Function-Programming->Structures
  • Argument can be Boolean, Numeric, Enum or String depending on

value wired to its terminal

slide-23
SLIDE 23

State Machines

  • State Machines can be created with a while loop, a shift register and a

case structure

  • While loop execute state cases
  • Shift register keeps next state
  • Case structure define per-state actions, next state and when to stop
slide-24
SLIDE 24

Object Oriented Programming (O (OOP)

  • An Object is a collection of data and methods that interact with that

data

  • A class is the data type of an Object
  • Object oriented languages have features to make OOP easier
  • C++, C#, Java, Python and LabView
  • Main benefit is that code is:
  • Easier to write
  • More stable
  • Easier to maintain
slide-25
SLIDE 25

Basic Object-Oriented Concepts

  • Encapsulation: consolidation of data and methods into an object with

restricted access to data

  • Use of accessor methods
  • Inheritance: technique to allow reusing a class a start point for

another one by sub-typing

  • Subtypes inherit method implementations from supertype
  • Polymorphism: technique that allows for a variable, method or object

to take on multiple forms

  • Subtypes override method implementations from supertype
slide-26
SLIDE 26

OOP in Labview

  • An Object is like a very smart cluster
  • Composite of other data types
  • Uses bundle and unbundle
  • A class is an user-defined data type implemented as a library (.lvclass

file)

  • Each Labview class consists of:
  • A data control (defines the cluster)
  • Additional VI to access data (read/write)
  • Additional VI to implement methods
  • Properties