Loading...
Saturday, August 18, 2012

Lab .1 (a) - Beginning LabVIEW Programming

1.Create an application which reads the current time from the computer, and pops up a simple dialog box with the time information.

a.Create new LabVIEW application. Go to the Block Diagram, and show the Functions Palette.

b.On the Functions Palette put a copy of the function “Get Date/Time in Seconds” (under “Time and Dialog”) onto your diagram. Also get a copy of the function “Format Date/Time String” from the same palette. Connect them up to create a text formatted string with the current date and time.

c.Under “String” get the string concatenation function. Concatenate the previous text string, containing the current date and time, to the end of a new text string constant containing the words “The current date and time is: ”.

d.Create a Single Button Dialog Box (a function under “Time and Dialog”). Use the text string from part (1c) as the text for the Dialog Box. Use another text string constant to make a name, “Thanks”, for the title of the dialog box button.

e.When you run the program, it should pop-up a single dialog box which says “The Current date and time is: XXXX" where XXXX is the current date and time. Clicking on the “Thanks” button will close the dialog box. Demonstrate the program to the TA.


2. Create an application which reads a text string from the Control Panel, and sends the text string to a text string display as well as to a dialog box.

a. Create a new LabVIEW application. Go to the Front Panel, and add a String Control and a String Indicator to the panel. Rename the String Control as “Input”. Rename the String Indicator as “Output”.
b. On the Block Diagram, wire the String Control to the String Indicator. Go back to the Front Pane, type some text into each input area (different text data in each). Run the program. Which input text changes? Which text stays the same?
c. On the Front Panel add a single LED Indicator (under “Boolean”). On the Block Diagram add a “Two-Button Dialog”. Connect the return value from the dialog box (“T?”) to the LED Indicator. Pass the string from the “Input” String Control to the name of the dialog box, but do it so that all characters are capital letters. Do this by sending the string from the string control through the “To Upper Case” function in the String Palette. The output from this function is then sent to the dialog box name input. Save the application at this point, you may lose the LabVIEW application if you click on the wrong “run” button in part (2d).
d. Test by entering some lower case data into the “Input” area on the Front Panel, then running the program using the “Run Once” button. DO NOT use the continuous run mode of LabVIEW. The dialog box should appear with the text string in upper case. If you click on “OK” the LED should turn on. If you click on “Cancel” the LED should turn off.
e. Be sure you have saved the application. After having saved the application, try hitting the “Continuous Run” button. What happens? Is there any way to stop the program?
f. Hit Ctrl-Alt-Delete to bring up the Windows Task Manager, select LabVIEW, and then select End Task. This is the only way to stop the process. Restart LabVIEW and reload your saved program. Do not run it.
g. We will now fix this lockup problem. In general, you should always test your software to make sure somebody cannot lock up the system by pressing the wrong run button. To fix the problem, you need to stop the program when the person clicks on one of the dialog box buttons. Go to the Block Diagram. In the Functions Palette, look in “Application Control” for a stop sign. Put the stop sign on the Block Diagram and connect the input to the Boolean output from the dialog box. The stop sign will stop the program if it receives a true; the program keeps running if the stop sign receives a false. Save the program, then try to
run in both run-once mode and in continuous mode. The program should exit nicely when you click on the correct dialog box button (OK).
3. Create a Boolean-to-decimal converter, and identify the difference between I8 and U8 integers.
a. Create a new LabVIEW application. Place eight vertical toggle switches in a roughly straight horizontal line on the Front Panel. Select all eight switches with a selection box. Use “Distribute Objects” and “Horizontal Center” to distribute the switches evenly in the line, then use the “Align Objects” to align all the switches on their vertical centers. The result should have all the switches neatly aligned and evenly spaced.
b. Rename the switch titles, from left to right , as “128”, “64”, “32”, “16”, “8”, “4”, “2”, and “1”.
c. Go to the Block Diagram. Align the eight Boolean outputs as you did for the switches in part (3a).
d. We will take these individual bits from the switches and concatenate them together to form a single byte. Each switch will then control the value of a different bit of the byte. To form the byte, use the “Build Array” function from the Functions Palette in the Block Diagram. Drop one of these objects into your Diagram. Add seven more inputs by placing the arrow tool into the left hand side of this function, then right-clicking with your mouse to select the “Add Input” function. Add seven more inputs so the total number of inputs is eight.
e. Wire the switch outputs, in sequential order, to the inputs of the build array. Note that the bottom-most input of the array will be the leftmost bit, the one corresponding to the 128's bit; the topmost input will be the rightmost bit, corresponding to the 1's bit.
f. Convert this array into a number using the “Boolean array to number” function under "Numeric", submenu "Conversion"
g. On the Front Panel, add a Digital Indicator (under "Numeric").
h. Go to the Block Diagram. You now need to set the type of data to be displayed by the numeric control. Point to the Numeric Indicator (in yellow, says “DBL”), right click and select submenu “Representation”. This is currently set to “DBL” meaning double precision floating point. Change this to “U8” meaning unsigned byte.
i. Run the program from the Front Panel, and click the switches to different states. Verify that the numeric output is the proper sum of the individual bit values. In particular, see what happens when you click the 128 switch on and off. What is the biggest number you can get? What is the smallest?
j. Now go to the Block Diagram, and change the data type from “U8” to “I8” meaning signed byte.
k. Run the program from the Front Panel, and click the switches to different states. Verify that the numeric output is the proper sum of the individual bit values. In particular, see what happens when you click the 128 switch on and off. What is the biggest number you can get? What is the smallest?
l. In (3h), if one changed U8 to U16 or U32, would it make any difference? What would the minimum/maximum that could be displayed be as the eight switches were toggled?
m. In (3k), if one changed U8 to I16 or I32, would it make any difference? What would the minimum/maximum that could be displayed be as the eight switches were toggled?


0 comments:

Post a Comment

 
TOP