1 / 12

EET 2259 Unit 8 Other Structures; Local Variables

EET 2259 Unit 8 Other Structures; Local Variables. Read Bishop, Sections 5.6 to 5.12. Lab #8 and Homework #8 due next week . Quiz #4 next week. Review: Structures. Structures control the flow of a program’s execution. We’ve looked at several kinds: For Loops While Loops

cullen
Download Presentation

EET 2259 Unit 8 Other Structures; Local Variables

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EET 2259 Unit 8Other Structures; Local Variables • Read Bishop, Sections 5.6 to 5.12. • Lab #8 and Homework #8 due next week. • Quiz #4 next week

  2. Review: Structures • Structures control the flow of a program’s execution. • We’ve looked at several kinds: • For Loops • While Loops • Case Structures • Sequence Structures • This week we’ll look at two more: • Formula Nodes • Diagram Disable Structures • We’ll also look at local variables.

  3. Entering Formulas • You can perform just about any mathematical calculation using LabVIEW’s built-in arithmetic functions on the Functions >> Mathematics palette. • Example: • But for long, complicated formulas, there’s an easier way, called a Formula Node.

  4. Formula Node • The Formula Node lets you type formulas using the same syntax used in C or C++. • Formulas must end in a semicolon (;). • To raise a number to a power, type **. For example, to set y equal to x4, type y = x**4; (Bishop, pp. 250-253)

  5. Diagram Disable Structure • The Diagram Disable structure lets you disable specific sections of code on the block diagram. • It is similar to commenting out code in a text- based programming language. (Bishop, p. 254)

  6. Usefulness of Diagram Disable Structure • This structure is primarily useful as a debugging tool. If you’ve got some code that you know or suspect is not working correctly, you can temporarily disable that code while you test the rest of your program. • Eventually you’ll probably want to remove all diagram disable structures, after all of your code works correctly.

  7. Example of Diagram Disable Structure

  8. Local Variables • Local variables let you access front panel objects from more than one location in a single VI. They pass information between objects that can’t simply be connected with a wire. (Bishop, p. 255) Local variable

  9. Creating Local Variables • To create a local variable, right-click the desired front panel object and select Create >> Local Variable. (Bishop, p. 257)

  10. Use Local Variables with Care • Since local variables are not inherently part of the LabVIEW dataflow execution model, overusing them or misusing them can make block diagrams difficult to read or create unpredictable situations. (Bishop, p. 257)

  11. Global Variables • Local variables are called local because they only let you pass data from one place to another within a single VI. • In LabVIEW you can also create global variables (not discussed in the text) that pass data between VIs running on the same computer. Global variable

  12. Use Global Variables with Extreme Care • With global variables it can be very hard to see where data is going or where it’s coming from. Misusing them can make block diagrams very difficult to read and can create unpredictable situations. • LabVIEW provides better ways to pass data between VIs, but they’re more complicated and difficult to set up than global variables.

More Related