Unformatted text preview:

ME 224 Lab 2 ME224 Lab 2 1 Introduction The main objective of this lab is to familiarize you with LabVIEW as a programming language and teach you the skills you need to complete the rest of the experiments At the end of this lab you should be able to create simple programs with LabVIEW and use them and the USB 6009 data acquisition card to take readings and create output 2 Some notes on programming Programming a computer should be a simple and straightforward task if you happen to know what you want to do and you know the language you are using inside and out so you can tell the computer what to do and you know the details of how the computer does what it does In reality programming can be frustrating at best To make matters worse you will probably use a different language for every new project you tackle I chose LabVIEW for this course because it is often used in industry it is geared specifically to instrumentation applications and it is fairly simple to learn Even so you need the same skills to use LabVIEW that you would use for any other real programming language actually LabVIEW is just a pretty wrapper for the C language The most important thing you need to write a computer program is to know what you want to do Usually this means writing down an outline or a list of goals and creating a few flow charts or lines of pseudo code Even professional programmers don t attempt to write a piece of software off the top of their head If you know what you want to do then it is a relatively straightforward task to learn the syntax of a new programming language or the inner workings of a new computer system Or better yet you can outsource the programming to someone who can do it better 3 Number Systems To work with I O devices and with assembly language programs it is necessary to go back and forth among representations of numbers in decimal base 10 hexadecimal base 16 and binary base 2 Regardless of what you use in your program most programming languages allow you to specify numbers in all of these formats the computer internally represents all numbers and characters in binary This internal conversion to binary is usually not important to the user but it becomes so when connecting I O devices to the computer Then a binary representation directly corresponds to signal levels on the IO lines Hexadecimal numbers are a convenient shorthand notation for long binary numbers When a decimal number is written down for example 348 what is indicated is that there are 3 hundreds 4 tens and 8 ones A hexadecimal number with the characters 1234 represents 0X1234 3 2 1 0 1 16 2 16 3 16 4 16 In the example above notice that the exponent of the base in the equation represents each digits place in the number Here hexadecimal numbers are indicated by a 0X sign preceding the number Each of the characters 1 2 3 4 in the equation above could have been any character from 0 to 15 Likewise as you know each 1 ME 224 Lab 2 place in a decimal number could be any character from 0 to 9 In hexadecimal to represent a 10 A is used To represent 11 B is used etc as shown in table 1 For example 15C 1 162 5 161 12 160 1 256 5 16 12 1 348 decimal A number will be preceded by a 0b sign to indicate that the number which follows is a binary representation Thus 0b0101 0 23 1 22 0 21 1 20 Table 1 Correspondence between binary hexadecimal and decimal numbers Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 4 A basic LabVIEW program LabVIEW was created specifically to speed up and ease the process of writing programs for instrumentation There are two parts to a LabVIEW program or Virtual Instrument vi These two parts are the Diagram and the Instrument Panel The Instrument Panel is where you create and view all user interface aspects of a vi The Diagram Panel is where the internal control of the program is performed Activity 2 1 Objective Complete a practical demonstration of converting decimal numbers to binary and vice versa Procedure 1 Log in to the computer at your workstation and start up LabVIEW Start Programs National Instruments LabVIEW 8 0 2 ME 224 Lab 2 2 In the Getting Started window under New click Blank vi Now you will see two windows the Front Panel window and the window that was discussed above previously You can switch between them using the keyboard Ctrl E or menu Window Diagram Panel 3 Build LabVIEW program 2 1 shown in the appendix Notice the program has two parts one for the front panel and one for the diagram Start with the front panel portion as follows 4 Turn on the controls palette by selecting it from the menu View Show controls palette the control palette will appear Now click on the icon All Controls 5 Pick the Boolean button from the controls panel button names appear as you move the mouse across them Then pick the Green Round Light In the future this will be specified as Modern Boolean Round LED 6 Your mouse icon will turn into a hand Place the Round LED somewhere in the control panel by clicking the left mouse button once when the mouse icon is over the position you want to place the button 7 When you place the control its name Boolean will be highlighted Change the name to Bit 0 by immediately typing on the keyboard You can change the name in the future by selecting the Tools palette from the menu View Show tools palette and the selecting the edit text tool and using it to select the name you want to change 8 Create 3 additional Round LED controls the same way or alternately by holding down the ctrl key while you click and drag the existing control ctrl click drag will duplicate an existing control Name these controls Bit 1 Bit 2 and Bit 3 respectively 9 Now from the controls palette select Modern Numeric Numeric Indicator Place it on the front panel Name it result 10 Switch to the Block Diagram Window and continue building LabVIEW program 2 1 a 11 Turn on the functions palette if it is not visible View Show Functions Palette 12 From the Function palette add a Numeric Numeric Constant Numeric Multiply and a Boolean Boolean to 0 1 Wire the constant to one of the multiply inputs and the output of the conversion to the other input on the multiply Select the whole group and ctrl click drag three copies so that you have four groups total 3 ME …


View Full Document

NU MECH_ENG 224 - ME224 Lab 2

Download ME224 Lab 2
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view ME224 Lab 2 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view ME224 Lab 2 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?