LabVIEW 8 Student Edition - gbv.de

11
LabVIEW 8" Student Edition Robert H. Bishop The University of Texas at Austin PEARSON Prentice Hall Upper Saddle River, NJ 07458

Transcript of LabVIEW 8 Student Edition - gbv.de

Page 1: LabVIEW 8 Student Edition - gbv.de

LabVIEW 8" Student Edition

Robert H. Bishop The University of Texas at Austin

PEARSON

Prentice Hall

Upper Saddle River, NJ 07458

Page 2: LabVIEW 8 Student Edition - gbv.de

CONTENTS

Preface xvii

LabVIEW Basics 1.1 System Configuration Requirements 2

1.2 InstallingtheLabWEWSfudenfEd/f/on 2

1.3 The LabVIEW Environment 3

1.4 The Getting Started Screen 5

1.5 Panel and Diagram Windows 9

1.5.1 Front Panel Toolbar 9

1.5.2 Block Diagram Toolbar 13

1.6 Shortcut Menüs 14

1.7 Pull-Down Menüs 16

1.7.1 File Menü 16

1.7.2 EditMenu 17

1.7.3 View Menü 17

1.7.4 Project Menü 19

1.7.5 Operate Menü 20

1.7.6 Tools Menü 20

1.7.7 Window Menü 20

1.7.8 Help Menü 21

1.8 Palettes 22

1.8.1 Tools Palette 22

1.8.2 Controls Palette 23

1.8.3 Functions Palette 25

1.9 Opening, Loading, and Saving Vis 26

Page 3: LabVIEW 8 Student Edition - gbv.de

VÜi Contents

1.10 LabVIEW Help Options 28

1.10.1 Context Help Window 28

1.10.2 LabVIEW Help 29

1.11 Building Blocks: Pulse Width Modulation 30 1.12 Relaxed Reading: Remote Controlled Excavation with

LabVIEW 33

1.13 Summary 35 Exercises 37

Problems 41

Designs 42

2 Virtual Instruments 45 2.1 What Are Virtual Instruments? 45 2.2 Several Worked Examples 48 2.3 The Front Panel 55

2.3.1 Numeric Controls and Indicators 55

2.3.2 Boolean Controls and Indicators 57

2.3.3 Configuring Controls and Indicators 58

2.4 The Block Diagram 60 2.4.1 Vis and Express Vis 60

2.4.2 Nodes 61

2.4.3 Terminals 62

2.4.4 Wiring 65

2.5 Building Your First VI 68

2.6 Data Flow Programming 73 2.7 Building a VI Using Express Vis 75

2.8 Building Blocks: Pulse Width Modulation 82 2.9 Relaxed Reading: LabVIEW Automates Brain Wave

Experiments 84 2.10 Summary 86

Exercises 87

Problems 90

Designs 93

3 MathScript 95 3.1 What is MathScript? 96

3.2 Accessing the MathScript Interactive Window 97 3.2.1 The Command History Window 99

3.2.2 Copying Output Window Data 100

3.2.3 Viewing Data in a Variety of Formats 100

Page 4: LabVIEW 8 Student Edition - gbv.de

Contents ix

3.3 MathScript Help 103

3.4 Syntax 104

3.4.1 Key MathScript Functions 114

3.5 Defining Functions and Creating Scripts 115

3.5.1 User-Defined Functions 116

3.5.2 Scripts 119

3.6 Saving, Loading, and Exporting Data Files 122

3.6.1 Saving and Loading Data Files 122

3.6.2 Exporting to Microsoft Excel 125

3.7 MathScript Nodes 126

3.7.1 Accessing the MathScript Node 127

3.7.2 Entering Scripts into the MathScript Node 128

3.7.3 Input and Output Variables 129

3.7.4 Saving Scripts from within the MathScript Node 132

3.8 Applications of MathScript 135

3.8.1 Instrument your Algorithms 135 3.8.2 Graphical Signal Processing, Analysis, and Mathematics

136

3.8.3 Integrating Measurement Hardware 136

3.9 Building Blocks: Pulse Width Modulation 138

3.10 Relaxed Reading 140

3.11 Summary 141

Exercises 143

Problems 144

Designs 144

4 Editing and Debugging Virtual Instruments 147 4.1 Editing Techniques 148

4.1.1 Creating Controls and Indicators on the Block Diagram 148

4.1.2 Selecting Objects 149

4.1.3 Moving Objects 152

4.1.4 Deleting and Duplicating Objects 152

4.1.5 Resizing Objects 153

4.1.6 Labeling Objects 154

4.1.7 Changing Font, Style, and Size of Text 156

4.1.8 Selecting and Deleting Wires 158

4.1.9 Wire Stretching and Broken Wires 159

4.1.10 Aligning, Distributing, and Resizing Objects 164

4.1.11 Coloring Objects 166

Page 5: LabVIEW 8 Student Edition - gbv.de

X Contents

4.2 Debugging Techniques 173

4.2.1 Finding Errors 173

4.2.2 Highlight Execution 175

4.2.3 Single Stepping Through a VI and Its SubVIs 175

4.2.4 Breakpoints and Probes 177

4.2.5 Navigation Window 181

4.3 AFewShortcuts 181

4.4 Building Blocks: Pulse Width Modulation 183

4.5 Relaxed Reading 185

4.6 Summary 187

Exercises 188

Problems 191

Designs 194

5 SubVIs 196 5.1 What Is a SubVI? 196

5.2 Review of the Basics 198

5.3 Editing the Icon and Connector 200

5.3.1 Icons 200

5.3.2 Connectors 203

5.3.3 Selecting and Modifying Terminal Patterns 204

5.3.4 Assigning Terminals to Controls and Indicators 206

5.4 The Help Window 207

5.5 Using a VI as a SubVI 211

5.6 Creating a SubVI from a Selection 214

5.7 Saving Your SubVI 216

5.8 The Hierarchy Window 216

5.9 Building Blocks: Pulse Width Modulation 219

5.10 Relaxed Reading: LabVIEW Real-Time at Biosphere 222

5.11 Summary 223

Exercises 225

Problems 228

Designs 230

6 Structures 232 6.1 The For Loop 232

6.1.1 Numeric Conversion 234

6.2 The While Loop 239

Page 6: LabVIEW 8 Student Edition - gbv.de

Contents xi

6.3 Shift Registers and Feedback Nodes 244 6.3.1 Shift Registers 244 6.3.2 Using Shift Registers to Remember Data Values from

Previous Loop Iterations 246

6.3.3 Initializing Shift Registers 247

6.3.4 Feedback Nodes 250

6.4 Case Structures 252 6.4.1 Adding and Deleting Cases 255

6.4.2 Wiring Inputs and Outputs 258

6.5 Fiat Sequence Structures 263

6.5.1 Evaluate and Control Timing in a Sequence Structure 263

6.5.2 Avoid the Overuse of Sequence Structures 266

6.6 The Formula Node 266 6.6.1 Formula Node Input and Output Variables 267

6.6.2 Formula Statements 267

6.7 Some Common Problems in Wiring Structures 270 6.7.1 Failing to Wire a Tunnel in All Cases of a Case Structure

270 6.7.2 Overlapping Tunnels 271

6.7.3 Wiring Underneath Rather Than Through a Structure 271

6.8 Building Blocks: Pulse Width Modulation 272 6.9 Relaxed Reading: Investigating Global Warming with

LabVIEW 276

6.10 Summary 278 Exercises 280

Problems 284

Designs 287

7 Arrays and Clusters 289 7.1 Arrays 289

7.1.1 Creating Array Controls and Indicators 290

7.1.2 Multidimensional Arrays 293

7.2 Creating Arrays with Loops 294

7.2.1 Creating Two-Dimensional Arrays 297

7.3 Array Functions 297

7.3.1 Array Size 299

7.3.2 Initialize Array 299

7.3.3 Build Array 300

7.3.4 Array Subset 302

7.3.5 Index Array 303

Page 7: LabVIEW 8 Student Edition - gbv.de

Contents

7.4 Polymorphism 311

7.5 Clusters 314

7.6 Creating Cluster Controls and Indicators 315

7.6.1 Cluster Order 316

7.6.2 Using Clusters to Pass Data to and from SubVIs 318

7.7 Cluster Functions 318

7.7.1 The Bündle Function 318

7.7.2 The Unbundle Function 323

7.7.3 Creating Cluster Constants on the Block Diagram 324

7.7.4 Using Polymorphism with Clusters 325

7.8 Building Blocks: Pulse Width Modulation 326 7.9 Relaxed Reading: LabVIEW Monitors Medieval Bell Tower

329

7.10 Summary 332

Exercises 334

Problems 337

Designs 339

8 Charts and Graphs 342 8.1 Waveform Charts 342

8.2 Waveform Graphs 351

8.3 XY Graphs 358

8.4 Customizing Charts and Graphs 361

8.4.1 Axes Scaling 361

8.4.2 The Legend 365

8.4.3 The Graph Palette and Scale Legend 366

8.4.4 Special Chart-Customizing Features 368

8.4.5 Special Graph-Customizing Features: Cursor Legend 370

8.4.6 Using Graph Annotations 372

8.4.7 Exporting Images of Graphs, Charts, and Tables 373

8.4.8 Using Context Help 374

8.5 Building Blocks: Pulse Width Modulation 374 8.6 Relaxed Reading: Spacecraft Attitüde Determination

on the Web 376

8.7 Summary 378

Exercises 379

Problems 381

Designs 382

Page 8: LabVIEW 8 Student Edition - gbv.de

Contents xiii

9 Data Acquisition 384 9.1 Components of a DAQ System 384

9.2 Types of Signals 386

9.2.1 Digital Signals 387

9.2.2 Analog DC Signals 388

9.2.3 Analog AC Signals 390

9.2.4 Analog Frequency-Domain Signals 391

9.2.5 One Signal—Five Measurement Perspectives 393

9.3 Common Transducers and Signal Conditioning 394

9.4 Signal Grounding and Measurements 398

9.4.1 Signal Source Reference Configuration 398

9.4.2 Measurement System 400

9.5 Analog to Digital Conversion Considerations 403

9.6 DAQ VI Organization 409

9.7 Choosing Your Data Acquisition Device 410

9.7.1 M-Series Data Acquisition Devices 410

9.7.2 Low Cost Data Acquisition for Students 411

9.7.3 Simulated Data Acquisition 411 9.7.4 Macintosh, Linux, Palm OS, Windows Mobile for Pocket PC,

and select Windows CE OS devices 412

9.8 DAQ Hardware Configuration 413

9.8.1 Windows 413

9.8.2 Channels and Tasks 421

9.9 Using the DAQ Assistant 423

9.9.1 DAQmx Task Name Constant 427

9.10 Analog Input 430

9.10.1 TaskTiming 430

9.10.2 Task Triggering 431

9.11 Analog Output 435

9.11.1 TaskTiming 436

9.11.2 Task Triggering 437

9.12 Digital Input and Output 442

9.13 Building Blocks: Pulse Width Modulation 448 9.13.1 Generating Pulse Width Modulated Signals with Hardware

Counters 448

9.13.2 Applications of Pulse Width Modulation 450

9.14 Relaxed Reading: Fuel Cell Catalyst Research 451

Page 9: LabVIEW 8 Student Edition - gbv.de

Contents

9.15 Summary 453

Exercises 457

Problems 457

Designs 459

10 Strings and File I/O 460 10.1 Strings 460

10.1.1 Converting Numenc Values to Strings with the Build Text Express VI 467

10.2 File I/O 470

10.2.1 Writing Data to a File 472

10.2.2 Reading Data from a File 476

10.2.3 Manipulating Spreadsheet Files 477

10.2.4 File I/O Express Vis 480

10.3 Building Blocks: Pulse Width Modulation 485 10.4 Relaxed Reading: Using LabVIEW in Drive-by-Wire Testing

486

10.5 Summary 488

Exercises 489

Problems 491

Designs 493

11 Analysis 495 11.1 Linear Algebra 495

11.1.1 Review of Matrices 496

11.1.2 System of Algebraic Equations 500

11.1.3 Linear System Vis 503

11.2 Statistics and Curve Fitting 505

11.2.1 Curve Fits Based on Least Squares Methods 506

11.2.2 Fitting a Curve to Data with Normal Distributions 509

11.2.3 The Curve Fitting Express VI 511

11.3 Differential Equations 515

11.4 Finding Zeroes of Functions 523

11.5 Integration and Differentiation 526

11.6 Signal Generation 526

11.6.1 Normalized Frequency 527

11.6.2 Wave and Pattern Vis 531

11.6.3 The Simulate Signal Express VI 533

Page 10: LabVIEW 8 Student Edition - gbv.de

Contents XV

11.7 Signal Processing 535

11.7.1 The Fourier Transform 535

11.7.2 Smoothing Windows 539

11.7.3 The Spectral Measurements Express VI 545

11.7.4 Filtering 547

11.7.5 The Filter Express VI 557

11.7.6 The LabVIEW Digital Filter Design Toolkit 559

11.8 Building Blocks: Pulse Width Modulation 560

11.9 Relaxed Reading: Motorcycle Brake Testing 562

11.10 Summary 564

Exercises 566

Problems 567

Designs 568

A Instrument Control 569 A.1 Components of an Instrument Control System 570

A.1.1 WhatlsGPIB? 570

A.1.2 GPIB Messages 571

A.1.3 GPIB Devices and Configurations 571

A.1.4 Serial Port Communication 575

A.2 Detecting and Configuring Instruments 576

A.2.1 Windows 577

A.2.2 Macintosh OS X and Linux 577

A.3 Using the Instrument I/O Assistant 580

A.4 Instrument Drivers 587

A.4.1 Developing Your Own Instrument Driver 593

A.5 Future of Instrument Drivers and Instrument Control 594

A.6 Summary 595

B Other LabVIEW Applications 597 B.1 Acquiring Data with the Sound Card 598 B.2 Managing Programs with the LabVIEW Project 598

B.3 Sharing Data with Shared Variables 600

B.4 LabVIEW Toolkits 602

B.5 Prototyping a Model-Based Control Solution 603

B.5.1 Developing a Plant Model 603

B.5.2 Control Design 604

B.5.3 Simulation 605

B.5.4 Deployment 606

Page 11: LabVIEW 8 Student Edition - gbv.de

XVI Contents

B.6 Using Multisim for Integrated Circuit Simulation and Verification 607

B.7 Summary 609

Index 611