You are on page 1of 6

Bress

book

May 29, 2013

18:8

Contents

Preface Introduction 1 LabVIEW Basics
1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 Anatomy of a VI A Simple Example: Hello World.vi Controls, Indicators, and Wires Dataflow A More Substantial Example: Clean Up Folder.vi Arrays and Clusters Creating Sub-VIs Case Structures The Standard Sub-VI Pattern with Error Handling

xi xiii 1
3 3 4 8 11 13 17 20 24 25 27 27 34 35 39

1.16 Passing Data by Reference 1.17 File I/O 1.18 The Simulated Data Acquisition VI 1.19 Loop Timing 1.20 The Data Over Limit sub-VI 1.21 The Create Log String sub-VI 1.22 Absolute and Relative File Paths 1.23 The Append To Log File Sub-VI 1.24 Property Nodes and Invoke Nodes 1.25 Developing the Simulated Data Acquisition VI 1.26 Elements of LabVIEW Style

42 43 48 49 51 52 53 54 56 57 59

1.10 The Move Or Delete Sub-VI 1.11 The Right File Type Sub-VI 1.12 Loops 1.13 Shift Registers and Feedback Nodes 1.14 Error Handling 1.15 Developing the Clean Up Folder VI

2 Functional Specifications
2.1 The Multitest VI 2.2 State Transition Diagram for the Multitest VI 2.3 The Car Wash Controller 2.4 State Transition Diagrams for the Car Wash Controller

61
61 62 63 66 v

9 Determine the States Plan the State Transitions Create the State Constant Build the Front Panel Add the Main Loop and Case Structure Add an Error or Stop Check Develop Individual States Develop the Initialize State 133 134 134 135 135 139 142 142 5 Action Engines 5.3 Traffic Light Controller Exercises 7.3 Outputs of the Car Wash Timer 117 6.4 Security System Controller Exercises 125 125 126 127 129 3.8 8.2 Boiler Controller Exercises 7.4 Boiler Controller Exercises 68 68 6.7 The Reset Timer Function of the Car Wash Timer 6.3 Example: Creating a Counter 5.4 Building a State Machine From Scratch: The Multitest VI 90 90 92 96 97 8 The Classic State Machine Car Wash Controller 132 8.6 The Timecheck Action of the Car Wash Timer 6.12 Develop the Car Wash States 6.1 Car Wash Controller Exercises 3.4 The State Variable Method 106 106 110 111 5.1 Anatomy of an Action Engine 5.2 State Machine Structure 4.1 State Machine Elements 4.Bress book May 29.5 8.13 Develop the Shutdown State 151 9 Problem Set 3 9. 2013 18:8 vi Contents 3 Problem Set 1 3.10 Develop the Wait State 8.6 8.5 Car Wash 2 Controller Exercises 86 4 Classic State Machines 4.1 Car Wash 2 Controller Exercises 7.5 State Variables of the Car Wash Timer 6.2 Inputs of the Car Wash Timer 115 116 116 Develop the Unlock Selector State 145 145 146 147 8.8 The Kernel of the Car Wash Timer 118 118 120 8.1 The Functions of the Car Wash Timer 6.1 8.2 Traffic Light Controller Exercises Security System Controller Exercises 152 152 152 121 .4 Icon and Front Panel of the Car Wash Timer 117 6.3 Security System Controller Exercises 3.11 Develop the Lock Selector State 8.9 Providing Storage for the Car Wash Timer 123 3.4 8.2 8.2 Feedback Node Action Engines 107 6 The Car Wash Timer 6.2 Traffic Light Controller Exercises 68 71 74 7 Problem Set 2 7.3 8.3 Placing Elements in the State Machine 4.7 8.1 9.

1 Traffic Light Controller Exercises 12.3 Boiler Controller Exercises 16.4 Car Wash 2 Exercises 182 182 182 182 183 13 Queued State Machines 13.2 Anatomy of an Event Structure 10.6 Example: Building an Event-Driven State Machine 167 168 168 170 171 175 175 15 Data Acquisition with the Multitest VI 15.2 Security System Controller Exercises 12.3 The Car Wash States 197 199 201 206 10 Event-Driven State Machines 10.1 Event Structures 10.2 The STOP Button 178 178 180 16 Problem Set 5 16.3 9.3 Functional Specification 15.1 Documentation 17.2 Style 17.4 Car Wash 2 Exercises 16.2 Security System Controller Exercises 16.3 Boiler Controller Exercises 12.3 By-Value versus By-Reference 13.1 The Power of Queues 13.4 Boiler Controller Exercises Car Wash 2 Exercises 166 166 vii 14 The Queued Car Wash Controller 14.4 Event Structure Quirks and Caveats 10.2 Queue Functions 13.4 State Transition Diagram 15.1 Adding the Event Structure to the Wait State 11. 2013 18:8 Contents 9.2 Data Acquisition in LabVIEW 212 11 The Event-Driven Car Wash Controller 11.5 Building the DAQ Task 15.1 Traffic Light Controller Exercises 16.5 Event Structure Guidelines 10.1 Strain Gages and Bridge Circuits 15.4 Building a Queued Event-Driven State Machine 184 185 185 188 191 17 Preparing for the CLD Exam 17.5 DAQ State Machine Exercises 224 224 224 225 225 226 12 Problem Set 4 12.5 Time Management 17.6 Practicing for the Exam 231 232 234 235 236 237 238 .2 Examining the Queued Car Wash Controller 14.4 Preparing for the CLD Exam 17.Bress book May 29.3 Configuring an Event Structure 10.3 Functionality 17.6 Developing the Multitest Data Acquisition VI 210 210 212 212 214 217 15.1 Building a Non-Square Icon 14.

4 Implementing the Car Wash Controller with Arguments 278 281 25.Bress book May 29.1 LabVIEW Objects and Classes 298 302 24 Problem Set 9 24.3 Developing a Generic Cycle State 21.1 DAQ State Machine Exercises 22.7 Disadvantages of Using Strings 20.4 Passing Arguments Using Strings 20.4 Security System Controller Exercises 22.1 Traffic Light Controller Exercises 24.8 Improving the String-Based State Machine 239 246 254 255 257 257 260 260 263 266 268 22.10 The Factory Method 25.7 21. 2013 18:8 viii Contents 18 Problem Set 6 19 Problem Set 7 20 State Machines with Arguments 20.3 Passing Arguments Using Clusters 20.6 The String-Based Multitest VI 20.1 Inheritance and Composition Creating the Cycle Class Data Member Access Sub-VIs Dynamic Dispatch Sub-VIs Static Dispatch Sub-VIs Access Scope The Completed Cycle Class Creating the Child Classes Developing Override VIs 316 318 320 321 324 327 329 331 332 333 338 21 Car Wash Controller with Arguments 21.6 25.9 25.13 Why Bother with Classes? 25.6 Car Wash 2 Controller Exercises 288 289 294 23 Data Encapsulation 23.2 Car Wash Controller Exercises 22.3 Car Wash 2 Controller Exercises 313 313 313 314 25 Inheritance and Composition 25.2 25.11 Dynamic Loading of Classes 342 345 347 .5 Boiler Controller Exercises 22.8 22 Problem Set 8 22.5 Designing Parsing Sub-VIs 20.1 The Data Highway 20.2 Developing Parsing Routines for the Car Wash Controller 276 21.2 Boiler Controller Exercises 24.1 Car Wash Controller with Time and Cycle Arguments 274 275 25.2 Using Arguments to Pass Information 20.5 25.3 Traffic Light Controller Exercises 287 287 287 288 25.3 25.12 The Car Wash Controller with Inheritance and Composition 25.4 25.

2 The Producer–Consumer Architecture 27.3 The Producer–Consumer (Events) Architecture 27. 2013 18:8 Contents ix 26 Problem Set 10 26.4 438 438 439 439 440 440 440 441 442 443 385 Event-Driven State Machine 438 28 Combatting Race Conditions 28.2 Traffic Light Controller Exercises 26.5 Using the Switched Queue 29.3 Boiler Controller Exercises 348 348 351 353 29 Extending the Language 29.4 Switched Queue Method Sub-VIs 29.2 The Producer–Consumer Car Wash Controller 28.6 The Pros and Cons 411 412 414 27 Producer–Consumer State Machines 27.1 The Switched Queue Class 29.6 Value(Signalling) or User Events? 27.2 Data Value References 29.1 Stopping Parallel Loops 27.10 Where to Go from Here 402 404 408 A Sample CLD Exam— Traffic Light Controller B Sample CLD Exam— Security System 444 446 .1 The Classic State Machine Queued State Machine State Machines with Arguments State Machines with Classes Producer–Consumer State Machines Coupling Selecting an Architecture How Can You Improve? 31.1 Security System Controller Exercises 30.1 Guarding Against Race Conditions 28.5 Producer–Consumer Pattern with User Events 27.4 Car Wash Race Condition 28.5 Semaphores and the Producer–Consumer Car Wash Controller 28.4 User Events 27.3 Data Accessor Methods of the Switched Queue Class 29.2 Car Wash 2 Exercises 429 429 437 31 Wrapping It Up 31.2 31.6 31.9 400 401 31.7 31.3 31.Bress book May 29.7 Error Handling in the Producer–Consumer Architecture 418 419 426 427 368 369 371 372 377 383 385 30 Problem Set 11 30.7 Living with the Race Condition 387 393 397 31.5 31.1 Car Wash 2 Exercises 26.3 The Producer–Consumer Car Wash Controller with User Events 28.8 31.6 Breaking the Deadlock 28.

Bress book May 29. 2013 18:8 x Contents C Sample CLD Exam— Boiler Controller D Sample CLD Exam— Car Wash Controller 2 E Sample CLD Exam— Sprinkler Controller F Sample CLD Exam— ATM Controller G Problem Set 1 Solutions H Problem Set 2 Solutions I Problem Set 3 Solutions J Problem Set 4 Solutions 449 454 458 463 469 493 502 K Problem Set 5 Solutions L Problem Set 6 Solutions M Problem Set 7 Solutions N Problem Set 8 Solutions O Problem Set 9 Solutions P Problem Set 10 Solutions Q Problem Set 11 Solutions Index 529 535 556 570 592 622 634 678 696 .