Laboratory Two. Basic Programming in LabVIEW Programming Structure

Similar documents
EET 310 Programming Tools

Lab 3: Introduction to Data Acquisition Cards

Introduction to LabVIEW

LabVIEW Lesson 5 Clusters

Exercise 10: Basic LabVIEW Programming

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

Lab 4 - Data Acquisition

Introduction to LabVIEW for Control Design & Simulation Ricardo Dunia (NI), Eric Dean (NI), and Dr. Thomas Edgar (UT)

Introduction to MS WINDOWS XP

User Guide to LabVIEW & APT

First Bytes Programming Lab 2

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

Creating tables of contents and figures in Word 2013

DSP Laboratory: Analog to Digital and Digital to Analog Conversion

After going through this lesson you would be able to:

Advanced Programming with LEGO NXT MindStorms

Cell Phone Vibration Experiment

Introduction to Windows

Introduction to Visio 2003 By Kristin Davis Information Technology Lab School of Information The University of Texas at Austin Summer 2005

Windows XP Pro: Basics 1

1. Installing The Monitoring Software

Sample Table. Columns. Column 1 Column 2 Column 3 Row 1 Cell 1 Cell 2 Cell 3 Row 2 Cell 4 Cell 5 Cell 6 Row 3 Cell 7 Cell 8 Cell 9.

Getting Started on the Computer With Mouseaerobics! Windows XP

Servo Motors (SensorDAQ only) Evaluation copy. Vernier Digital Control Unit (DCU) LabQuest or LabPro power supply

Welcome! Want to find out more? Follow this tutorial, then launch Part 1 to get started.

Statgraphics Getting started

Working with sections in Word

WebFOCUS BI Portal: S.I.M.P.L.E. as can be

6 USING WINDOWS XP 6.1 INTRODUCTION

Beckhoff TwinCAT. Configuring the TwinCAT I/O System

Excel Level Two. Introduction. Contents. Exploring Formulas. Entering Formulas

Lab 2: MS ACCESS Tables

STEP 7 MICRO/WIN TUTORIAL. Step-1: How to open Step 7 Micro/WIN

CHAPTER 11: Flip Flops

Introduction to OpenOffice Writer 2.0 Jessica Kubik Information Technology Lab School of Information University of Texas at Austin Fall 2005

CATIA Basic Concepts TABLE OF CONTENTS

Data Acquisition Using NI-DAQmx

Advanced Presentation Features and Animation

Excel Tutorial. Bio 150B Excel Tutorial 1

Sample. LabVIEW TM Core 1 Course Manual. Course Software Version 2010 August 2010 Edition Part Number B-01

Hands-onIntroduction todataacquisition

MICROSOFT WORD TUTORIAL

Module 1. 4 Login-Send Message to Teacher

TabletWorks Help Index 1

Data Acquisition in LabVIEW

Operating Systems. and Windows

TestManager Administration Guide

User Tutorial on Changing Frame Size, Window Size, and Screen Resolution for The Original Version of The Cancer-Rates.Info/NJ Application

INTRODUCTION TO COMPUTER CONCEPTS CSIT 100 LAB: MICROSOFT POWERPOINT

Creating Database Tables in Microsoft SQL Server

Access Control and Audit Trail Software

Windows 8.1 Tips and Tricks

Navios Quick Reference

EPM2000 LabVIEW Building Applications Instructions

Centre for Learning and Academic Development. IT Training. File Management. Windows Vista. Version 1.0

X-Trade Brokers Dom Maklerski S.A. XTB Expert Builder. Tutorial. Michał Zabielski

Lab 1: Full Adder 0.0

ezsystem elab16m Project 1F: Alarm System (Full Project description)

Introduction to Microsoft Access 2003

Lab View with crio Tutorial. Control System Design Feb. 14, 2006

BLOCK OCCUPANCY DETECTOR WITH SEMAPHORE OPERATION BOD1/DAP4-BR

Working with the Multi Cam Mode in EDIUS

Aurasma: Creating from Web

Introduction to Microsoft Word 2003

Kodu Curriculum: Getting Started with Keyboard and Mouse

OPERATING INSTRUCTIONS Nikon TiE Deconvolution Microscope CCRB 1-220G

3. Locate the different selections of Styles from the Home Tab, Styles Group

Using Flow Control with the HEAD Recorder

Visual Logic Instructions and Assignments

Agenda2. User Manual. Agenda2 User Manual Copyright Bobsoft 1 of 34

CREATE A 3D MOVIE IN DIRECTOR

Section 1: Ribbon Customization

AODA Mouse Pointer Visibility

Excel 2007 Basic knowledge

Twido Simulator - Online Help Scope What's in this Part? Twido Simulator Overview What's in this Chapter? How to Use Twido Simulator

To Begin Customize Office

Using WINK to create custom animated tutorials

The very basic basics of PowerPoint XP

Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick Reference Guide

Working with SmartArt

Creating a table of contents quickly in Word

RFQ Builder Software. RFQ Builder User Guide Version 4.5. Table of Contents. RFQ Builder Overview

Creating Stop Motion Animation in Corel VideoStudio Pro

ios 9 Accessibility Switch Control - The Missing User Guide Updated 09/15/15

Using the JNIOR with the GDC Digital Cinema Server. Last Updated November 30, 2012

mdm-mp3 minidirector with MP3 Player

Using Microsoft Project 2000

Getting Started with the LabVIEW Embedded Module for ARM Microcontrollers 1.0 For the Keil MCB2300

Case study: how to use cutoff conditions in a FRA frequency scan?

WA Manager Alarming System Management Software Windows 98, NT, XP, 2000 User Guide

**If the box does not automatically pop up, see the next page.

How To Use The Powerpoint 3.5 On A Computer With A Powerpoint 2.5 (Powerpoint) On A Pc Or Macbook 2.2 (Powerstation) On An Iphone Or Ipad (Powerplane)

RX-6 Six In - One Out All in One Receive Antenna Switch Local and Remote Control System RX6ACI User Manual Version 2.1

Introduction to LabVIEW Design Patterns

Check out our website!

Tutorial 13: Object Animation

LabVIEW Day 6: Saving Files and Making Sub vis

The goal is to program the PLC and HMI to count with the following behaviors:

Tutorial for Basic Editing in Adobe Premiere Pro CS5

How to Make the Most of Excel Spreadsheets

Transcription:

M.E. 401 Mechatronics Laboratory Two Basic Programming in LabVIEW Programming Structure Required Materials Hardware P.C. Multi-Function data acquisition board One LED Software Measurement and Automation explorer (MAX) LabVIEW Study Material Course Text LabVIEW Manual Purpose The following tutorial will continue the introduction to LabVIEW, with particular focus on loops and conditional statements. Introduction Loops and conditional statements are vital components of even the most basic programming applications. The four structures we will focus on in this tutorial are the Sequence, Case, For Loop, and While Loop. The Sequence Structure allows the user to specify an ordered set of events. This structure is created graphically as a series of frames that are executed in a desired order. Sequence structures can be either Flat or Stacked. These structures are almost identical, having film strip-like borders, and they execute the same way, from first to last in order. We will almost always use the Flat Sequence structure because all of the code is visible and it is much easier to keep track of dataflow inputs and outputs.

The Case Structure is similar to the if and else statements found in traditional textbased programming languages. The case structure is used to test if certain conditions are satisfied, most commonly using true and false statements. In addition to Boolean inputs, the case structure does allow for numeric and string inputs so that more than two frames can be utilized. This structure can be nested to test for a variety of outcomes, but remember that if you wire an output in one frame, you must wire the output from all subdiagram frames in the case structure. You can toggle between subdiagrams using the arrows at the top of the frame. The For Loop iterates a specified number of times, executing the desired commands during the process. Two details require particular attention. First, the count terminal (seen as N in the diagram window) determines the number of iterations. Once this value is available, the iterations begin at zero. For example, ten iterations are seen as N=0, 1, 2...,9. Second, the i in For Loop is the iteration terminal and returns the current iteration index. In Lab 1 we saw that the While Loop structure repeats its commands until the appropriate test condition fails. In LabVIEW, the While Loop evaluates the test condition at the end of the loop so that the loop is always executed at least one time. The one-time execution is an important characteristic to be aware of, as we do not wish to damage any hardware that we are using through exposure to an unexpected high voltage. The While Loop contains a Conditional Terminal that expects a Boolean (T/F) input. The While Loop repeats while false by default and will Stop if TRUE. (You can change the terminal to have it loop while true by selecting Continue if True from the pop-up menu). Note: Remove structures, don t just delete them! Using the delete key will delete the contents of the structure, too. Whenever you want to remove a structure be sure to use the right-click pop-up menu and select Remove While Loop or Remove For Loop. This will remove the structure, but leave all the other code on the block diagram. Part 1: Create VI Purpose: Design a virtual instrument (VI) that when powered ON, sends a series of pulses through the digital channel to the LED. Overview: A Case Structure should be used as a test to determine if the power to the instrument is ON or OFF. If the power is ON (Case is TRUE) use a While Loop to execute commands. Place a sequence in the while loop that alternately supplies and terminates the power to the LED causing the LED to pulsate. If the power to the VI is OFF (Case is FALSE) the LED should not be powered and the light will remain OFF in this case.

Lab Procedure: 1. Create a new VI with an On-Off switch in LABView as was done in Lab 1. 2. Configure a digital output channel a. Create a Digital Channel as in lab 1 using DAQmx Create Virtual Channel.vi and place on the left side of the block diagram. b. Add a control to select the appropriate line you want to control. Move to the Block Diagram and configure the internal components of your VI. 3. Create Case Structure a. Right Click in the block diagram to bring up the Functions Panel, and select Case Structure from the Structures subpalette. Click and drag cursor in the block diagram to place and size the structure. (Create Virtual Channel and Boolean Control should be outside and to the left of your case structure) b. Wire the Boolean Control to the Case Structure by attaching the T/Fbox to the case selector on the case structure frame. located c. Configure a Flat Sequence Structure i. Inside the True frame of the case structure, add a Flat Sequence Structure from the Structures subpalette of the Functions menu. The Flat Sequence Structure will be used to: ii. Right Click on the Flat Sequence border frame and select Add Frame After. You should have two movie frames inside the Case Structure. You will use these frames to set up the True-False conditions that will be used to turn the LED on and off in sequence. iii. Inside the first Flat Sequence Frame, add DAQmx Write. Right Click on the Arrow, Select Type=>Digital=>Single Channel=>Single Sample=>Boolean (1line). iv. Right Click on the DAQmx Write Data terminal and select Create Constant. Toggle Constant to TRUE in the first frame.

v. Following the same procedure, add DAQmx Write to the second frame in the sequence. Toggle the Constant to FALSE in frame 2. 4. Configure Time Constants In order to control the amount of time the LED stays on or off in each frame, we will add time constants. a. Right Click in the block diagram to bring up the Functions Panel and select Timing=>Wait (ms). Place one Wait (ms) in each frame of the Flat Sequence structure, Right Click on the wait milliseconds (left-hand) terminal and Create=>Constant. Set the constant to 500 by double clicking in each frame. Your Block Diagram should look something like this so far While Loop: executing commands until a condition is TRUE. When the power to the instrument is ON (Boolean TRUE) the VI will send a series of pulses to the digitally connected LED. To accomplish this task, we make use of a While Loop that executes the commands within its window until a condition is TRUE. The condition we will use is a certain number of iterations. 5. Configure the While Loop a. Add a While Loop and place it outside of the Case Structure. The Boolean Control should be inside the While Loop, but outside the Case Structure. 6. Add Numeric Control to the While Loop a. On the Front Panel, add a Numeric Control, rename it Number of Pulses to be Executed. b. On the Block Diagram, move Number of Pulses to be Executed inside the While Loop between the Condition and Iteration terminals of the While Loop.

c. Right Click in the block diagram and select Comparison=>Greater Than or Equal?and place it inside the While Loop next to the Number of Pulses to be Executed control. d. Configure the Numeric Control i. Wire the Loop Iteration terminal of the While Loop (i) to the x terminal (top input) of the Greater Than or Equal? function. Wire the Number of Pulses to be Executed terminal to the y terminal (bottom input) of the Greater Than or Equal? function. Wire the Greater Than or Equal? output terminal to the Conditional terminal of the While Loop. 7. Create an Iteration Incicator a. Create an indicator on the front panel that shows the number of iterations that have been executed. i. Right click on the Iteration terminal of the While Loop and select Create=>Indicator. Rename the indicator on the front panel to read Pulses Executed. 8. Wire the DAQmx Digital Channel terminals. a. Wire the Task and Error output from Create Virtual Channel to the input of DAQmx Write in frame 1 of the sequence. Similarly, wire the output of DAQmx Write in frame 1 to the input in frame 2. b. Add DAQmx Clear Task.vi to the outside-right of the While Loop in the Block Diagram. Wire the task and error output of DAQmx Write in the second frame to DAQmx Clear Task. Check your work by making sure that there are connection tunnels passing through each of the While Loop, Case Structure, and Sequence Structure. The tunnels, or data entry and exit terminals, on the right-hand side of each structure will have white centers because the FALSE case has not been wired yet. c. Toggle case structure to FALSE. Wire Create Virtual Channel task and error out terminals to Clear Task VIs task and error in terminals by spanning the empty Case Structure. You should now be ready to run your program. Set the Number of Pulses to be Executed to 5. Press the Power button to the ON position. Select the digital line you are using. Press the Run button. Change the number Pulses to be Executed, run your program and count pulses. (If you turn the highlight execution button in block diagram to on, it will take a while for the LED to response)

Questions: Did your LED pulse? How many pulses did you count, and how many iterations were executed? Explain why. Given that the iteration terminal counts iterations starting at zero, how can you modify your program to accurately reflect the desired and executed number of pulses, rather than iterations? Plot the diagram you designed, make a few explanations under your plot regarding how your code works (you may need to think about how the while loop works) Here is what your Iteration and Conditional terminal might look like in order to solve this problem, using numeric and comparison subpalettes (since the first iteration is zero, add 1 to the number of iterations, and subtract 1 from the Number of Pulses to be Executed). Here is an image of Part 1 Front Panel and Block Diagram

Your report should follow the format described below: 1. Lab title 2. Hardware and Software 3. Objective 4. Descriptions of the problems you have experienced and how you solved them 5. Solutions to all the questions (will start with a bullet in the lab transcripts). Note that brief explanations or descriptions after each plot are required. 6. Plots that need to be printed out (will start with a bullet in lab transcripts) have to be attached with lab reports. Plots should be created by selecting File - Print - Next - icon, description, panel and diagram - Print options, which will also include your lab records such as time or date, etc. 7. Summary or conclusion