ENGR 1000, Introduction to Engineering Design

Similar documents
ENGR 1000, Introduction to Engineering Design

INTRODUCTION TO LABVIEW

NAME EET 2259 Lab 3 The Boolean Data Type

ECE 202 LAB 1 INTRODUCTION TO LABVIEW

Small rectangles (and sometimes squares like this

Homework Assignment 9 LabVIEW tutorial

PHYC 500: Introduction to LabView. Exercise 16 (v 1.2) Controlling hardware with DAQ device. M.P. Hasselbeck, University of New Mexico

TECH 3821 Lab #2 Relay Driver with Computer Control

NI LabView READ THIS DOCUMENT CAREFULLY AND FOLLOW THE INSTRIUCTIONS IN THE EXERCISES

Computer Interfacing Using LabView

Hands-on Lab 1: LabVIEW NI-DAQ Basics 1

Layers (Just the Basics) By Jerry Koons

Lab 4 - Data Acquisition

LabView instrumentoinnissa, 55492, 3op Labview in instrumentation

LABVIEW LAB SKILLS ACTIVITY 1 PROGRAMING ENVIRONMENT

Part 1. Creating an Array of Controls or Indicators

WEEK NO. 12 MICROSOFT EXCEL 2007

LabVIEW. Table of Contents. Lesson 1. Pre-reqs/Technical Skills Basic computer use

PHYC 500: Introduction to LabView. Exercise 1 (v 1.3) M.P. Hasselbeck, University of New Mexico

Introduction to LabVIEW

Windows XP. A Quick Tour of Windows XP Features

FRC LabVIEW Sub vi Example

EZware Quick Start Guide

1. Right-click the worksheet tab you want to rename. The worksheet menu appears. 2. Select Rename.

Above Threshold Warning of Temperature Data

Linear Control Systems LABORATORY

A. Front Panel Design Lesson 4 Implementing a VI

Introduction to Labview and Temperature Measurement

Road Traffic Collisions Tableau Dashboard Answering Key Questions General

EXERCISE 1-IDENTIFY COMPUTER S DRIVES (YOUR STORAGE

Anatomy of a Window (Windows 7, Office 2010)

Excel Tables and Pivot Tables

PowerPoint Introduction

PHY 351/651 LABORATORY 1 Introduction to LabVIEW

Dept. of Electrical, Computer and Biomedical Engineering. Data Acquisition Systems and the NI LabVIEW environment

Application State Machine

Virtual Instrumentation With LabVIEW

University of Pennsylvania. Department of Electrical and Systems Engineering. ESE Undergraduate Laboratory. Introduction to LabView

ME 224: EXPERIMENTAL ENGINEERING. Lecture 2

Barchard Introduction to SPSS Marks

Introduction to National Instruments LabVIEW and Data Acquisition (DAQ)

Lab 1: Getting familiar with LabVIEW: Part I

Using Windows 7 Explorer By Len Nasman, Bristol Village Computer Club

Introduction. Slide Basics. PowerPoint 2010 Slide Basics. Video: Slide Basics in PowerPoint About Slides. Page 1

DW DIGs Model Windows Tricks

GEORGIA INSTITUTE OF TECHNOLOGY School of Electrical and Computer Engineering ECE 2020 Fall 2017 Lab #1: Digital Logic Module

Basic Data Acquisition with LabVIEW

Lesson 4 Implementing a VI

Virtual Instrumentation With LabVIEW

HYPERSTUDIO TOOLS. THE GRAPHIC TOOL Use this tool to select graphics to edit. SPRAY PAINT CAN Scatter lots of tiny dots with this tool.

Project Example Using LookoutDirect as an OPC Client

User Guide. General Navigation

ni.com Preparing for the CLAD Exam

The data acquisition components, and their relationship to each other, are shown below.

Read Temperature Data

Learning to use the drawing tools

WELCOME TO LabVIEW 1

Excel 2010: Getting Started with Excel

Interactive Powerpoint. Jessica Stenzel Hunter Singleton

IntelliTools Classroom Suite on Tech-Mod Computers

User s Guide

Introduction to Personal Computing

The PCC CIS etutorial to Windows

the NXT-G programming environment

Introduction to LabVIEW

Introduction to Mercury

Shift Register: Exercise # 1: Shift Register Example VI. 1. Build the following front panel. Figure (8.1): Shift register exercise front panel

COS 116 The Computational Universe Laboratory 8: Digital Logic II

ROBOLAB Tutorial MAE 1170, Fall 2009

Barchard Introduction to SPSS Marks

Robolab. Table of Contents. St. Mary s School, Panama. Robotics. Ch. 5: Robolab, by: Ernesto E. Angulo J.

PowerPoint Introduction. Video: Slide Basics. Understanding slides and slide layouts. Slide Basics

Using Excel 2001 to Create a Data Table 11 of 29

1. The PowerPoint Window

Appendix E: Software

Computer Essentials Session 1 Lesson Plan

Arrows and Watermark

Copyright 2018 MakeUseOf. All Rights Reserved.

Changing Button Images in Microsoft Office

REQUIRED MATERIALS Epiphany-DAQ board Wire Jumpers Switch LED Resistors Breadboard Multimeter (if needed)

Program and Graphical User Interface Design

EE261 Computer Project 1: Using Mentor Graphics for Digital Simulation

Training Kit for HP 1660/70 Series Logic Analyzers

Lesson 4 Page Styles

Lab Exercise 2: Data Acquisition with NI LabVIEW

Introduction to LabVIEW Exercise-1

Excel 2016 Basics for Mac

Click Here to Begin OS X. Welcome to the OS X Basics Learning Module.

ME 365 EXPERIMENT 3 INTRODUCTION TO LABVIEW

LabVIEW Experiment 1 Light Sensor Calibration Using Arduino Data Acquisition (Arduino DAQ)

LabVIEW programming I

BE/EE189 Design and Construction of Biodevices Lecture 1. BE/EE189 Design and Construction of Biodevices - Caltech

TUTORIAL #2 HIERARCHICAL DESIGNS AND TEST FIXTURES

An Animated Scene. Pick a color for the street. Then use the Paint can to fill the lower part of the page with grass.

Lesson 6 Adding Graphics

Lesson 1 Introduction to LabVIEW. TOPICS LabVIEW Environment Front Panel Block Diagram Dataflow Programming LabVIEW Help and Manuals Debugging a VI

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller

Learn the three palettes. Learn how data is passed in LabVIEW. Create a subvi using two different methods.

Part 2 Add Frame, Arrow, Painted Text.

Ch En 475: Introduction to Instrumentation and Signal Processing with Labview

Transcription:

ENGR 1000, Introduction to Engineering Design Unit 2: Data Acquisition and Control Technology Lesson 2.2: Programming Line Inputs with Boolean Values Hardware: 12 VDC power supply Several lengths of wire NI-USB 6008 Device with USB cable Digital I/O Interface Board for the NI-USB 6008 Device Traffic light Objectives: Work effectively in a cooperative learning environment. Explain the function of arrays with the use of the DAQ Assistant s digital lines. Connect NI USB-6008 device, the Digital I/O Interface, and switches to read digital inputs. Write a simple program in LabVIEW to control inputs and outputs using the following new commands: DAQ Assistant (digital port input) Case Structure (Boolean) Case Structure (Numeric) Index Array Boolean Indicator Boolean Array to Number Numeric Indicator 1

Data Acquisition and Control Hardware Wiring Digital Inputs As discussed in the previous lesson, the right side of the NI USB-6008 device provides connection to 12 digital input/output (DIO) channels. For this lesson, we will add port 1 to our programming experience. Port 1 consists of four channels (P0.0-3) that default as inputs set high. We will program the lines of port 1 as inputs and invert them in order to read the press of a button as high. The bottom four channels of the digital I/O interface board are circuits for reading inputs to the NI USB-6008. These circuits allow an electronic single from the USB-6008 device to travel through a remote switch and indicate a digital high when the switch is closed. In addition, a yellow LED will light indicating a closed circuit or high channel. Connecting digital inputs to the system is very easy after completing the previous lesson on programming digital outputs. All previous connections will be the same including: the connection of the USB-6008 device to the USB port of the computer; the GND and +5V wires from the USB-6008 device to the digital I/O interface; the external power supply to the digital I/O interface; and, the traffic lights to the output channels of the digital I/O interface (see picture below). For safety concerns, remember to unplug the NI USB-6008 device and the external power supply from its 120 VAC source when making these connections. The additional connections are for wiring the digital inputs. For this lesson, we will connect the two toggle-style push-button switches to channels P1.0 and P1.3. To begin, connect a wire from channel P1.0 on the USB-6008 device to the USB/DI terminal on the first input channel of the digital I/O interface. Connect a second wire from P1.3 of the NI device to the USB/DI terminal on the second input channel of the interface. On the right side of the digital I/O interface, at terminals IN1 and IN2, connect two toggle-style pushbutton switches. See the picture below. 2

Programming LabVIEW Port Inputs Using Numeric Values A Word on Arrays The DAQ Assistant has been designed to be relatively easy to configure and to be functional with other National Instruments data acquisition and control devices. Although the DAQ Assistant is easy to configure, it can be confusing for first time programmers. The initial confusion resides in the DAQ Assistant s use of arrays, sometimes using numeric values and other times using Boolean values. The most important thing to understand about the DAQ Assistant is the way it is set up to communicate. Whether it is used as an input or output device, the digital side of the instrument requires the use of an array. To visualize this, think of an array as a series of something for example, the following series of numbers: 48243. If you look at all these numbers together, it looks like one large number. However, if we separate them in boxes with the least significant number on top, it looks like an array of individual numbers. 3 0 th element 4 1 st element 2 2 nd element 8 3 rd element 4 4 th element Each separate number represents an element in the array. The first element in this array is the 0 th element, which holds the value of 3. The 8 in this array is the 3 rd element. In this lesson, we will use a command called Index Array which will return the value of one single element in an array. This command will be used often in later lessons. When the DAQ Assistant is set up for the NI USB-6008, an array is made. With only one NI USB-6008 device connected, this array can have anywhere from zero to twelve elements. Each element represents what is referred to as a channel. As a result, the digital side of the NI USB-6008 device can have up to 12 channels. A channel can be either a port or a line of the digital side of the instrument, depending on how it is set up. If set up using ports, the values will be numeric; if set up as lines, the values will be Boolean. Thus far, we have used only the line capability. This causes the input or output of the DAQ to be an array of Boolean values instead of numeric values. If only one line is used, it becomes the first channel, or the 0 th element in the array. If additional lines are used, there would be two or more elements in the array. Each element represents the Boolean value of the corresponding line value. (Beware here because the element number does not necessarily represent the physical line. For instance in this lesson we will set up P1.3 as the second input line. This will make the array index for this value 1 and not 3.) In this lesson, we will continue using lines as channels and use Boolean values to read inputs and control outputs. To avoid complex Boolean conditions we will introduce a Boolean Array to Number command that will change our Boolean array into a numeric value. 3

Programming a Single Input Example 1 The first program will perform the following sequence after an input switch is activated: Conditions Switch 1 is high Switch 1 is low Traffic Light Sequence turn on the red and green lamps for 1/2 second turn on the yellow lamp for 1/2 second repeat the sequence (Note: program the sequence so all lamps are off when the stop button is selected) All lamps are off Wire the red lamp of the traffic light to port 0 line 0, the yellow lamp to port 0 line 1, and the green lamp to port 0 line 2. Wire a toggle switch to port 1 line 0. We will begin programming with a While Loop as our base structure or the outer most structure. To begin, insert a While Loop in the Block Diagram. See the previous lesson if unsure of the procedure. Programming a DAQ Assistant as a Digital Port Input In the last lesson, the DAQ Assistant was used to interface the software with the hardware outputs. The same command, with a different configuration, will be used to interface the software with the hardware inputs. The primary difference between a digital output and a digital input is how the line or channel is addressed. When programming outputs, a value is sent to the port to turn channels on or off. When programming inputs, a value is read from the port that indicates its status telling us which channels are high or low. Using the Functions Palette, navigate to the DAQ Assistant command and place inside the While Loop. The location of the DAQ Assistant can be viewed in the diagram below. The DAQ Assistant command will initialize, and the Create New Express Task window will open. Select and open the Digital I/O submenu from the list of options on the right. Select Line Input from the submenu. Select port1/line0 and port1/3 from the Supported Physical Channels and select Finish. (To select multiple lines, hold down the ctrl key while using the mouse to select the different lines.) The DAQ Assistant window will open. This time, check the Invert Line box for both lines. (In the upper left box of the DAQ Assistant window select DigitalIn0 and select the box, then select DigitalIn1 and check the box for that line as well.) The configuration should also have 1 Sample (On Demand) selected. To finish the configuration, select OK in the lower right corner. The DAQ Assistant will take a moment to configure. To help with the interpretation of your program, change the name of the DAQ Assistant following the procedure described in the previous lesson. This time name it P1.0,3 IN, identifying it as an input controlling port 1, lines 0 and 3. 4

Isolating Port 1 Line 0 (P1.0) as an Input The DAQ Assistant is capable of utilizing an array of values, but for our example we will only be using the 0 th element. As a result, we must first isolate the line we configured in P1.0,3 IN (P1). from the array of potential lines. This will be accomplished by using the Index Array command. Begin by opening the Programming menu on the Functions Palette and selecting the Array submenu. Select the Index Array command and place to the lower right of P1. Wire the data bar of P1 to the array node of the Index Array. Create a numeric constant for the Index Array by hovering over the index node, right clicking, and selecting Create and Constant from the submenu. Keep the value 0 of the Numeric Constant to select the first element/channel, or the first line configured from the array of potential lines. Create a Boolean Indicator in the Front Panel A Boolean Indicator will be used to display the value of the line we have configured for our input. The value will be displayed on the Front Panel for the convenience of the operator as an LED. The binary equivalent of this LED's value is representative of the status of the line, 0 or 1, low or high, off or on. To program a Boolean Indicator, hover over the element node of the Index Array command, right click and select Create and Indicator in the submenu. This will place an indicator icon in the Block Diagram and an indicator on the Front Panel. The indicator placed on the Front Panel may not be initially obvious. You may need to look behind menus or scroll to find it. After locating the indicator, drag it to a more convenient location (e.g., below the stop button). Finally, change the name of the indicator in the Front Panel to be more descriptive of its function. Double click on the name and type in P1.0 IN. Both the Front Panel and Block Diagram should look similar to the diagrams below. 5

Running the Program The program can be run by selecting the Run arrow on the Front Panel s tool bar. The virtual indicator will monitor status of port 1 (input 1), and its value (0 or 1/false or true/low or high/off or on) will change as the switch is toggled. Stop the program by pressing the stop button associated with the While Loop. This would be a good time to name and begin saving your program. Programming a Case Structure for a Boolean Input A case structure is similar to a flat or sequence structure, previously programmed, in that there are two frames, called cases for a case structure, with sub diagrams placed inside. The difference is that the content of a single case is run only when its value is equal to the input value of the structure. We will be using a Boolean Case Structure. To insert a Case Structure, open the Programming menu on the Functions Palette and select the Structures submenu. Select the Case Structure and insert it within the While Loop using a left click and drag technique. Wire the output of the Index Array to the selector terminal (question mark) of the Case Structure. Your program should look similar to the graphic below. Programming the Digital Outputs The rest of the program will utilize programming commands and techniques previously taught. See the previous lesson if unsure of the procedures. 6

In Case 1 of the Case Structure, create the following stacked sequence, frames 0-2. frame 0 turn on red & green lamp for 1/2 second frame 1 turn on yellow lamp for 1/2 second frame 2 turn off all lamps (at the speed of light or the speed of your computer s processor, whichever is faster) In Case 0, Default of the Case Structure, turn off all outputs using the DAQ Assistant as shown on the right. Running and Debugging a Program Run the program and toggle the input switch to activate the programmed light sequence. While the program is running, select the Highlight Execution (light bulb) command from the tool bar of the Block Diagram. This will slow the execution of the program and show the logic values as the program steps through the nodes. This is very helpful when debugging a program. To turn off this feature, select the Highlight Execution command again. Once you have determined your program is running successfully, you should save it. Programming Multiple Inputs Example 2 The second program we will write will use a numeric case structure to perform multiple sequences based on the status of two input switches. The two sequences are as follows: 7

Conditions Switch 1 is high & Switch 2 is low Switch 1 is low & Switch 2 is high Switches 1 & 2 are low Traffic Light Sequence turn on the red and green lamps for 1/2 second turn on the yellow lamp for 1/2 second repeat the sequence turn on the red, yellow, and green lamps for 1 second turn off all lamps for 1/2 second repeat the sequence all lamps are off Wire the red lamp of the traffic light to port 0 line 0, the yellow lamp to port 0 line 1, and the green lamp to port 0 line 2. Wire two toggle switches, the first to port 1 line 0, and the second to port 1 line 3. Note: In order to save time, the wiring of the traffic light and the programming of the sequence for the first switch are the same as in example 1 of this lesson. Renaming and Saving a Program To begin, save the program in example 1 under a different name since it will be easier to modify the program used in example 1. From the Front Panel s menu bar, select File and the Save As command. The Save As window will appear. Keep the Copy option selected and also select Open Additional Copy. With both of these options selected, select Continue in the lower right corner of the window. On the next screen, rename the program and select OK. Both programs will be opened in LabVIEW; close the original program so as not to alter it. Changing a Boolean Array to a number Now that we have two switches our logic is more complicated than just true or false. This addition makes the Boolean Case Structure incompatible with what we want to accomplish. To adjust we will change our Boolean Array to a number using the Boolean Array to Number command and then change our Boolean Case Structure to a Numeric Case Structure. This will enable us to have more than two cases in our Case Structure. Before we add the command we must first make room for it. High light the Index Array command along with the Numeric Constant and the Boolean Indicator by using a click and drag to form a box around these commands. While they are highlighted press the Del key. To program a Boolean Array to Number command, navigate to the Programming menu and select the Boolean submenu. Select the Boolean Array to Number command and place it to the right of P1. It might wire automatically, but if it doesn't wire the Data bar of P1 to the left side of the command. Programming a Numeric indicator On the left side of the Boolean Array to Number command, right click and select Create and Indicator in the submenu. This will place an indicator icon in the Block Diagram 8

and an indicator on the Front Panel. The indicator placed on the Front Panel may not be initially obvious. You may need to look behind menus or scroll to find it. After locating the indicator, drag it to a more convenient location (e.g., below the stop button). Finally, change the name of the indicator in the Front Panel to be more descriptive of its function. Double click on the name and type in P1.0,3 IN. Changing the Boolean Case Structure to a Numeric Case Structure To change the case structure the only thing that needs to be done is to wire the right side of the Boolean Array to Number command to the selector (?) box on the Case Structure. Notice that the True case changed to a 1 case and the False case changed to a 0,default case. Both the Front Panel and Block Diagram should look similar to the diagrams below. Adding another Case to the Structure The final procedure will be to add a case after case 1. This is similar to duplicating frames in a stacked sequence. Right click on the border of case 1 and select Add Case After. Change the numeric value of the new case to 2 since this will represent the decimal equivalent of the Boolean value of switch 2 (P1.3). Complete the program by adding a Stacked Sequence Structure, DAQ Assistant with Boolean Constants, and Wait (ms) commands to case 2. Follow the procedure described in programming example 1 of this lesson. Case 2 should look similar to the graphics below. In our example program, we are only using three of the four possible cases with two switches (cases 0, 1, & 2). As the program is written now, when both switches are 9

pressed, the program runs the default case since the decimal equivalent of both switches would be 3 and we do not have a case equal to the value 3. An additional case could be developed for this program. If we had 3 switches, we would have a possibility of eight cases from the various combinations of switches. Another switch wired would represent the decimal value 4, and one more wired would represent the decimal value 8. We could build different cases by simply adding the decimal values of the various switches. Team Assignment As a team, write a program to perform the following sequences depending on the conditions of two toggle switches. Wire the traffic light and toggle switches as directed below. Conditions Switch 1 is high & Switch 2 is low Switch 1 is low & Switch 2 is high Switches 1 & 2 are high Switches 1 & 2 are low Traffic Light Sequence turn on the green lamp for 3 seconds turn on the yellow lamp for 1 second turn on the red lamp for 4 seconds repeat the sequence turn on the red lamp for 1 second turn off all lamps for 1 second repeat the sequence turn on the yellow lamp for 1 second turn off all lamps for 1 second repeat the sequence all lamps are off Wire the red lamp of the traffic light to port 0 line 0, the yellow lamp to port 0 line 2, and the green lamp to port 0 line 4. Wire switch 1 to port 1 line 1 and switch 2 to port 1 line 2. Save your program on a removable storage device under the name HW2-2T# (use your team number in place of the # symbol). Have the next person representing your team turn in your team assignment at the beginning of the next lab. Each person in your team should be able to perform this assignment and the lesson s objectives independently. Each of you will have an opportunity to demonstrate your knowledge independently on a quiz. A team is successful when all members are able to demonstrate the objectives. Have fun with the control technology and helping each other learn the material. 10