electronics
play

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


  1. EET EET-241: Programming For Electronics PCC Walter Lara

  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

  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.

  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

  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 .

  6. Front Panel Example

  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.

  8. Block Diagram Example

  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

  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

  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

  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

  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

  14. Wire Colors

  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

  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

  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

  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

  19. USB-6008 Pinout

  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

  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

  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

  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

  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

  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

  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

Recommend


More recommend