LabVIEW Advanced Programming Techniques



Similar documents
Getting Started with the LabVIEW Mobile Module Version 2009

Software Engineering Best Practices. Christian Hartshorne Field Engineer Daniel Thomas Internal Sales Engineer

Using MCC GPIB Products with LabVIEW

Getting Started with the LabVIEW Mobile Module

Manage Software Development in LabVIEW with Professional Tools

Bitter, Rick et al "Object-Oriented Programming in LabVIEW" LabVIEW Advanced Programming Techinques Boca Raton: CRC Press LLC,2001

OPC and Real-Time Systems in LabVIEW

Test Executive And Development Studio Integrated Test Executive and Application Development Environment

The Essentials of File Management with LabVIEW

Exercise 10: Basic LabVIEW Programming

LabVIEW Tutorial Manual

Visual Basic. murach's TRAINING & REFERENCE

Learning Remote Control Framework ADD-ON for LabVIEW

MA-WA1920: Enterprise iphone and ipad Programming

LabVIEW Internet Toolkit User Guide

User Guide to LabVIEW & APT

Software Engineering for LabVIEW Applications. Elijah Kerry LabVIEW Product Manager

EET 310 Programming Tools

Content Management Implementation Guide 5.3 SP1

Hands-On: Introduction to Object-Oriented Programming in LabVIEW

Introduction to LabVIEW Design Patterns

DataSocket Simplifies Live Data Transfer for LabVIEW

Fundamentals of Java Programming

Introduction to LabVIEW

Glossary of Object Oriented Terms

LabVIEW Report Generation Toolkit for Microsoft Office

Getting Started Guide

and Certification What Does It Take To Get Certified? Steven Hoenig NJ Business Unit Manager

Java (12 Weeks) Introduction to Java Programming Language

Engineering Design. Software. Theory and Practice. Carlos E. Otero. CRC Press. Taylor & Francis Croup. Taylor St Francis Croup, an Informa business

LabVIEW Day 6: Saving Files and Making Sub vis

SCADA/HMI MOVICON TRAINING COURSE PROGRAM

LabVIEW. User Manual. LabVIEW User Manual. April 2003 Edition Part Number E-01

LabVIEW Report Generation Toolkit for Microsoft Office User Guide

LabVIEW DSP Test Integration Toolkit for TI DSP

R&S AFQ100A, R&S AFQ100B I/Q Modulation Generator Supplement

LabVIEW Day 1 Basics. Vern Lindberg. 1 The Look of LabVIEW

PHP Code Design. The data structure of a relational database can be represented with a Data Model diagram, also called an Entity-Relation diagram.

VIRTUAL INSTRUMENTATION

LearnFromGuru Polish your knowledge

October 21 November 5 November 14 December 12. Washington DC Boston Chicago San Jose. ni.com

Microsoft Windows PowerShell v2 For Administrators

Sisense. Product Highlights.

Citrix EdgeSight for Load Testing User s Guide. Citrix EdgeSight for Load Testing 3.8

2. Advance Certificate Course in Information Technology

Deploying Cisco Unified Contact Center Express Volume 1

Changing Your Cameleon Server IP

LABVIEW DSP TEST TOOLKIT FOR TI DSP

Kentico CMS 5 Developer Training Syllabus

Course MS10975A Introduction to Programming. Length: 5 Days

Basics of VTune Performance Analyzer. Intel Software College. Objectives. VTune Performance Analyzer. Agenda

IBM Tivoli Composite Application Manager for Microsoft Applications: Microsoft Hyper-V Server Agent Version Fix Pack 2.

C#5.0 IN A NUTSHELL. Joseph O'REILLY. Albahari and Ben Albahari. Fifth Edition. Tokyo. Sebastopol. Beijing. Cambridge. Koln.

Lab 3: Introduction to Data Acquisition Cards

Dynamic Web Programming BUILDING WEB APPLICATIONS USING ASP.NET, AJAX AND JAVASCRIPT

R&S AFQ100A, R&S AFQ100B I/Q Modulation Generator Supplement

Advanced Web Application Development using Microsoft ASP.NET

DIABLO VALLEY COLLEGE CATALOG

LabVIEW Lesson 5 Clusters

AQA GCSE in Computer Science Computer Science Microsoft IT Academy Mapping

Chapter 11 Compound Documents in Windows 3.1

Tips and Tricks SAGE ACCPAC INTELLIGENCE

Pick a Palette and Beyond: REPORT GENERATION with LABVIEW

Pro ASP.NET 4 CMS. Using the JET 4 Framework. Advanced Techniques for C# Developers. Apress. Alan Harris

Object Technology Toolsets for LabVIEW

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation

MAS 90. Installation and System Administrator's Guide 4WIN /04

Design of Enterprise Systems

Advanced Web Application Development using Microsoft ASP.NET

User's Guide - Beta 1 Draft

Java Application Developer Certificate Program Competencies

Citrix EdgeSight for Load Testing User s Guide. Citrx EdgeSight for Load Testing 2.7

Introduction to Simulink & Stateflow. Coorous Mohtadi

Course Information Course Number: IWT 1229 Course Name: Web Development and Design Foundation

Development and Management

Red Hat Linux Internals

Sage ERP MAS 90 Sage ERP MAS 200 Sage ERP MAS 200 SQL. Installation and System Administrator's Guide 4MASIN450-08

MAS 500 Intelligence Tips and Tricks Booklet Vol. 1

2311A: Advanced Web Application Development using Microsoft ASP.NET Course 2311A Three days Instructor-led

Developing and Implementing Windows-Based Applications With Microsoft Visual C#.NET and Microsoft Visual Studio.NET

Programming with the Microsoft.NET Framework Using Microsoft Visual Studio 2005 (VB)

Chapter 15: Forms. User Guide. 1 P a g e

: provid.ir

Sitecore InDesign Connector 1.1

FactoryTalk Gateway Getting Results Guide

Developing and Implementing Web Applications with Microsoft Visual C#.NET and Microsoft Visual Studio.NET

Data Acquisition Using NI-DAQmx

INTELLECT TM Software Package

Using the Query Analyzer

Measurement Studio. Contents RELEASE NOTES

WebSphere Business Monitor

Agilent Technologies. Connectivity Guide. USB/LAN/GPIB Interfaces. Agilent Technologies

DSP Laboratory: Analog to Digital and Digital to Analog Conversion

Getting Started Guide

TestStand Certification Overview

SCADA, OPC and Database Systems

Microsoft Report Builder 3.0 with SQL 2008R2, SQL 2012 Express and SQL 2012 Course 55005A; 2 Days, Instructor-led

Integrating the Internet into Your Measurement System. DataSocket Technical Overview

Developing a LabVIEW Instrument Driver

Transcription:

LabVIEW Advanced Programming Techniques SECOND EDITION Rick Bitter Motorola, Schaumburg, Illinois Taqi Mohiuddin MindspeedTechnologies, Lisle, Illinois Matt Nawrocki Motorola, Schaumburg, Illinois @ CRC Press Taylor &. Francis Group Boca Raton London New York CRC Press is an imprint of the Taylor & Francis Group, an informa business

Contents Chapter 1 Introduction to Lab VIEW 1 1.1 Virtual Instruments 1 1.1.1 The Front Panel 2 1.1.2 Block Diagram 2 1.1.3 Executing Vis 3 1.1.4 LabVIEW File Extensions 5 1.2 LabVIEW Projects 5 1.3 Help 6 1.3.1 Built-inHelp 7 1.3.2 Websites 8 1.4 Data Flow Programming 8 1.5 Menüs and Palettes 9 1.6 Front Panel Controls 11 1.6.1 User Control Sets 12 1.6.1.1 Numeric 13 1.6.1.2 Boolean 15 1.6.1.3 String & Path 16 1.6.1.4 Ring & Enum, List & Table 18 1.6.1.5 Array, Cluster, and Matrix 20 1.6.1.6 Graphs and Charts 22 1.6.1.7 String & Path and I/O 24 1.7 Block Diagram Functions 26 1.7.1 Structures 26 1.7.1.1 Sequence Structure 27 1.7.1.2 Case Structure 30 1.7.1.3 For Loop 32 1.7.1.4 WhileLoop 37 1.7.1.5 Event Structure 38 1.7.1.6 Disable Structure 38 1.7.1.7 Timed Structure 39 1.7.1.8 FormulaNode 41 1.7.2 Numeric, Boolean, String, and Comparison 42 1.7.3 Array and Cluster 45 1.7.4 Timing 47 1.7.5 Dialog and User Interface 48 1.7.6 File I/O 49 1.7.7 Instrument I/O, Connectivity, and Communication 51 1.7.8 Creating Connectors 52 1.7.9 Editing Icons 54

1.7.10 UsingSubVIs 56 1.7.11 VI Setup 56 1.8 Setting Options 61 1.8.1 Paths 61 1.8.2 Block Diagram 62 1.8.3 Environment 63 1.8.4 Revision History 63 1.8.5 VI Server and Web Server 64 1.8.6 Controls/Functions Palettes 65 Chapter 2 LabVIEW Features 69 2.1 Global and Local Variables 69 2.2 Shared Variables 72 2.3 Customizing Controls 74 2.3.1 Custom Controls 74 2.3.2 Type Definitions 76 2.3.3 Strict Type Definitions 77 2.4 Property Nodes 78 2.5 Reentrant Vis 81 2.6 Libraries (.LLB) 83 2.7 Web Server 86 2.8 Web Publishing Tool 89 2.9 Instrument Driver Tools 90 2.10 Profile Functions 94 2.10.1 VI Profiler 94 2.10.2 Buffer Allocations 97 2.10.3 VIMetrics 97 2.11 Auto SubVI Creation 98 2.12 Graphical Comparison Tools 100 2.12.1 Compare Vis 101 2.12.2 Compare VI Hierarchies 102 2.12.3 SCC Compare Files 103 2.13 Report Generation Palette 104 2.14 Application Builder 106 2.15 Sound Vis 107 2.16 Application Control 109 2.16.1 VI Server Vis 109 2.16.2 Menü Vis 113 2.16.3 Help Vis 117 2.16.4 Other Application Control Vis 118 2.17 Advanced Functions 118 2.17.1 Data Manipulation 118 2.17.2 Calling External Code 119 2.17.3 Synchronization 119

2.18 Source Code Control 121 2.18.1 Configuration 121 2.18.2 Adding and Modifying Files 122 2.18.3 Advanced Features 123 2.19 Graphs 124 2.19.1 Standard Graphs 124 2.19.2 3-D Graphs 125 2.19.3 Digital and Mixed Signal Graphs 126 2.19.4 Picture Graphs 126 2.20 Data Logging 126 2.21 Find and Replace 127 2.22 Print Documentation 129 2.23 VI History 130 2.24 Key Navigation 131 2.25 Express Vis 132 2.26 Navigation Window 133 2.27 Splitter Bar 133 Bibliography 134 Chapter 3 State Machines 135 3.1 Introduction 135 3.1.1 State Machines in LabVIEW 136 3.1.2 When to Use a State Machine 136 3.1.3 Types of State Machines 137 3.2 Enumerated Types and Type Definitions 137 3.2.1 Type Definitions Used with State Machines 138 3.2.2 Creating Enumerated Constants and Type Definitions 139 3.2.3 Converting between Enumerated Types and Strings 139 3.2.4 Drawbacks to Using Type Definitions and Enumerated Controls 140 3.3 Sequence-Style State Machine 140 3.3.1 When to Use a Sequence-Style State Machine 141 3.3.2 Example 142 3.4 Test Executive-Style State Machine 144 3.4.1 The LabVIEW Template Standard State Machine 145 3.4.2 When to Use a Test Executive-Style State Machine 147 3.4.3 Recommended States for a Test Executive-Style State Machine 147 3.4.4 Determining States for Test Executive-Style State Machines 148 3.4.5 Example 149 3.5 Classical-Style State Machine 151 3.5.1 When to Use a Classical-Style State Machine 152 3.5.2 Example 152 3.6 Queued-Style State Machine 161 3.6.1 When to Use the Queued-Style State Machine 162

3.6.2 Example Using Lab VIEW Queue Functions 162 3.6.3 Example Using an Input Array 164 3.7 Drawbacks to Using State Machines 164 3.8 Recommendations and Suggestions 166 3.8.1 Documentation 166 3.8.2 Ensure Proper Setup 166 3.8.3 Error, Open, and Close States 166 3.8.4 Status of Shift Registers 167 3.8.5 Typecasting an Index to an Enumerated Type 167 3.8.6 Make Sure You Have a Way Out 168 3.9 Problems/Examples 168 3.9.1 The Blackjack Example 168 3.9.2 The Test Sequencer Example 171 3.9.3 The PC Calculator Example 176 Bibliography 179 Chapter 4 Application Structure 181 4.1 Planning 181 4.2 Purpose of Structure 182 4.3 Software Models 183 4.3.1 The Waterfall Model 184 4.3.2 The Spiral Model 185 4.3.3 Block Diagrams 186 4.3.4 Description of Logic 186 4.4 Project Administration 187 4.5 Documentation 188 4.5.1 LabVIEW Documentation 188 4.5.2 Printing LabVIEW Documentation 189 4.5.3 VI History 189 4.6 The Three-Tiered Structure 189 4.7 Main Level 192 4.7.1 User Interface 192 4.7.1.1 User Interface Design 192 4.7.1.2 Property Node Examples 194 4.7.1.3 Customizing Menüs 197 4.7.2 Exception-Handling at the Main Level 199 4.8 Second Level Test Level 199 4.9 Bottom Level Drivers 201 4.10 Style Tips 203 4.10.1 Sequence Structures 203 4.10.2 Nested Structures 204 4.10.3 Drivers 205 4.10.4 PollingLoops 205 4.10.5 Array Handling 206

4.11 The Lab VIEW Project 207 4.11.1 Project Overview 207 4.11.2 Project File Operations 209 4.11.3 Project Library 210 4.11.4 Project File Organization 212 4.11.5 Build Specifications 213 4.11.6 Source Code Management 215 4.12 Summary 215 Bibliography 218 Chapter 5 Drivers 219 5.1 Communication Standards 219 5.1.1 GPIB 219 5.1.2 Serial Communications 221 5.1.3 VXI 223 5.1.4 LXI 224 5.1.5 VISA Definition 224 5.1.6 DDE 226 5.1.7 OLE 227 5.1.8 TCP/IP 227 5.1.9 DataSocket 228 5.1.10 Traditional DAQ 229 5.1.11 NI-DAQmx 231 5.1.12 File I/O 235 5.1.13 Code Interface Node and Call Library Function 239 5.2 Driver Classifications 240 5.2.1 Configuration Drivers 241 5.2.2 Measurement Drivers 241 5.2.3 Status Drivers 241 5.3 Inputs/Outputs 241 5.4 Error Handling 242 5.5 NISpy 244 5.5.1 NISpy Introduction 244 5.5.2 Configuring NI Spy 244 5.5.3 RunningNI Spy 246 5.6 Driver Guidelines 247 5.7 Reuse and Development Reduction 247 5.8 Driver Example 248 5.9 Instrument I/O Assistant 250 5.10 IVI Drivers 251 5.10.1 Classes of IVI Drivers 251 5.10.2 Interchangeability 252 5.10.3 Simulation 252 5.10.4 State Management 253 5.10.5 IVI Driver Installation 253

5.10.6 IVI Configuration 254 5.10.7 How to Use IVI Drivers 255 5.10.8 Soft Panels 256 5.10.9 IVI Driver Example 256 Bibliography 260 Chapter 6 Exception Handling 261 6.1 Exception Handling Defined 261 6.2 Types of Errors 263 6.2.1 I/O Errors 263 6.2.2 Logical Errors 264 6.3 Built-in Error Handling 265 6.3.1 Error Cluster 265 6.3.2 Error Codes 268 6.3.3 VISA Error Handling 268 6.3.4 Simple Error Handler 270 6.3.5 General Error Handler 270 6.3.6 Find First Error 271 6.3.7 Clear Error 272 6.4 Performing Exception Handling 272 6.4.1 When? 272 6.4.2 Exception-Handling at Main Level 273 6.4.3 Programmer-Defmed Errors 273 6.4.4 Managing Errors 274 6.4.5 State Machine Exception Handling 276 6.4.6 Logging Errors 277 6.4.7 External Error Handler 277 6.4.8 Proper Exit Procedure 280 6.4.9 Exception Handling Example 281 6.5 Debugging Code 286 6.5.1 Error List 286 6.5.2 Execution Highlighting 287 6.5.3 Single-Stepping 287 6.5.4 Probe Tool 288 6.5.5 Breakpoint Tool 290 6.5.6 Suspending Execution 291 6.5.7 Data Logging 291 6.5.8 NISpy/GPIB Spy 292 6.5.9 Utilization of Debugging Tools 293 6.5.10 Evaluating Race Conditions 295 6.6 Summary 296 Bibliography 297

Chapter 7 Shared Variable 299 7.1 Overview of Shared Variables 299 7.1.1 Single Process Variables 300 7.1.2 Network Published Variable 300 7.2 Shared Variable Engine 301 7.2.1 Accessing the Shared Variable Engine 301 7.2.1.1 Shared Variable Manager 301 7.2.1.2 Windows Event Viewer 302 7.2.1.3 Windows Performance Monitor 302 7.2.1.4 Windows Task Manager 304 7.3 Shared Variable Processes and Services 304 7.4 Shared Variable Networking 306 7.5 Shared Variable Domains 308 7.6 Pitfalls of Distributed Applications 312 7.7 Shared Variables and Network Security 313 7.7.1 LabVIEW Specific Security Issues 316 Bibliography 317 Chapter 8.NET, ActiveX, and COM 319 8.1 Introduction to OLE, COM, and ActiveX 320 8.1.1 Definition of Related Terms 320 8.1.1.1 Properties and Methods 320 8.1.1.2 Interfaces 321 8.1.1.3 Clients and Servers 321 8.1.1.4 In-Process and Out-of-Process 321 8.1.1.5 TheVariant 322 8.2 COM 322 8.3 OLE 323 8.4 ActiveX 323 8.4.1 Description of ActiveX 323 8.4.2 ActiveX Definitions 324 8.4.3 ActiveX Technologies 324 8.4.3.1 ActiveX Terminology 325 8.4.4 Events 326 8.4.5 Containers 326 8.4.6 How ActiveX Controls Are Used 327 8.5.NET 327 8.5.1 Descriptionof.NET 328 8.5.2 Common Language Runtime 328 8.5.3 Intermediate Language 329 8.5.4 WebProtocols 329 8.5.5 Assembly 329 8.5.6 Global Assembly Cache 329

8.6 Lab VIEW and ActiveX 330 8.6.1 The Lab VIEW ActiveX Container 330 8.6.1.1 Embedding Objects 330 8.6.1.2 Inserting ActiveX Controls and Documents 332 8.6.2 The ActiveX Palette 334 8.6.2.1 Automation Open and Close 334 8.6.2.2 The Property Node 335 8.6.2.3 The Invoke Node 336 8.6.2.4 Variant to Data Function 339 8.6.3 Using the Container versus Automation 340 8.6.4 Event Support in LabVIEW 340 8.6.4.1 Register Event 341 8.6.4.2 Event Callback 341 8.6.5 LabVIEW as ActiveX Server 343 8.7 LabVIEW and.net 344 8.7.1.NET Containers 344 8.7.2.NET Palette 347 8.8 The VI Server 348 8.9 ActiveX and.net Examples 350 8.9.1 Common Dialog Control 350 8.9.2 Progress Bar Control 351 8.9.3 Microsoft Calendar Control 353 8.9.4 Web Browser Control 354 8.9.5 Microsoft Scripting Control 358 8.9.6 Microsoft System Information Control 360 8.9.7 Microsoft Status Bar Control 362 8.9.8 Microsoft Tree View Control 365 8.9.9 Microsoft Agent 368 8.9.9.1 Request Objects First Tier 369 8.9.9.2 Other First-Tier Controls 369 8.9.9.3 The Characters Object 369 8.9.9.4 The Character Control 370 8.9.10 Registry Editing Control 375 8.9.11 Controlling Microsoft Word 377 8.9.12 Microsoft Access Control 379 8.9.13 Instrument Control Using ActiveX 383 8.9.14 Instrument Control Using.NET 384 8.9.15 Controlling LabVIEW from Other Applications 387 8.9.16 Understanding ActiveX Error Codes 391 8.9.17 Advanced ActiveX details 393 Bibliography 395 Chapter 9 Multithreading in LabVIEW 397 9.1 Multithreading Terminology 398 9.1.1 Win32 398

9.1.2 UNIX 398 9.1.3 Multitasking 398 9.1.3.1 Preemptive Multithreading 399 9.1.4 Kernel Objects 400 9.1.5 Thread 400 9.1.6 Process 401 9.1.7 Application 401 9.1.8 Priority 402 9.1.8.1 How Operating Systems Determine which Threads 402 9.1.9 Security 402 9.1.10 Thread Safe 402 9.2 Thread Mechanics 403 9.2.1 Thread States 404 9.2.2 Scheduling Threads 404 9.2.3 Context Switching 404 9.3 Win32 Multithreading 405 9.4 Pthreads 406 9.5 Multithreading Problems 407 9.5.1 Race Conditions 408 9.5.2 Priority Inversion 408 9.5.3 Starvation 409 9.5.4 Deadlocking 409 9.5.5 Operating System Solutions 410 9.6 Multithreading Myths 410 9.6.1 The More Threads, the Merrier 410 9.6.2 More Threads, More Speed 411 9.6.3 Makes Applications More Robust 411 9.6.4 Conclusion on Myths 412 9.7 Hyper-Threading 412 9.8 Multithreaded Lab VIEW 413 9.8.1 Execution Subsystems 414 9.8.2 The Run Queue 417 9.8.3 DLLs in Multithreaded LabVIEW 418 9.8.4 Customizing the Thread Connguration 421 9.9 Thread Count Estimation for LabVIEW 423 9.9.1 Same as Caller or Single Subsystem Applications 426 9.9.2 Multiple Subsystem Applications 427 9.9.3 Optimizing Vis for Threading 428 9.9.4 Using VI Priorities 432 9.10 Subroutines in LabVIEW 434 9.10.1 Express Vis 435 9.10.2 LabVIEW Data Types 435 9.10.3 When to Use Subroutines 437 9.11 Summary 441 Bibliography 441

Chapter 10 Object-Oriented Programming in Lab VIEW 443 10.1 What Is Object-Oriented? 444 10.1.1 TheClass 444 10.1.2 Encapsulation 445 10.1.3 Aggregation 446 10.1.4 Inheritance 447 10.1.5 Polymorphism 448 10.2 Objects and Classes 448 10.2.1 Methods 449 10.2.1.1 Special Method Constructor 449 10.2.1.2 Special Method Destructor 450 10.2.2 Properties 450 10.3 Object Analysis 451 10.4 Object Design 459 10.4.1 Container Classes 460 10.4.2 Abstract Classes 460 10.5 Object Programming 464 10.6 Developing Objects in Lab VIEW 465 10.6.1 Properties 466 10.6.2 Constructors 467 10.6.3 Destructors 471 10.6.4 Methods 472 10.6.4.1 Public Methods 472 10.6.4.2 Private Methods 472 10.7 Examples in Developing Instrument Drivers 473 10.7.1 Complex Instrument Designs 476 10.8 Object Template 487 10.9 Exercises 489 Bibliography 489 Index 491