Objective
To create a program which will display a given text on the NXT brick display.
Final Program
Launch LabVIEW;
either from the icon on the Desktop,
(or)
from the Start Menu-> All Programs -> National Instruments -> LabVIEW 8.6 -> LabVIEW
LabVIEW is pretty big and takes some time to load.
Figure : Choosing Blank VI from the New Section.
From the New section on the Files side of the Getting Started window select Blank VI. This would open up two windows, the Front Panel and the Block Diagram window. (Read Chapter 1 from the book to understand more about the two windows.)
The Block Diagram window is where we create our programs.
Figure : Block Diagram Window
On the block diagram window, we place a series of blocks to perform the necessary functions. To introduce the blocks that are used, we need the Functions Palette. The Functions Palette can be brought up by two ways
Figure : Functions Palette from View Menu
Figure : Functions Palette by right clicking within Block Diagram. The pin (circled in red) is to be clicked to keep the window on.
The NXT Toolkit is in the Addons submenu of the Function Palette. This toolkit contains all the blocks that we need to program the NXT.
Figure : Selecting the NXT Toolkit from the Addons submenu on the Functions Palette
Within the Toolkit sub menu (pin it again, to keep just the NXT Toolkit window on) choose Structures and select While Loop. Once you select this, the cursor changes to a loop. Now left click, hold and drag to create a while loop. (Read pg 7-9 of the book on while loops)
Figure : Selecting While Loop
Figure : While loop
Creating the Loop Constant
Move the cursor over the Loop Condition box (the box with the big red circle) and when the little spool of wire appears, right click and in the menu that appears, select Create Constant. Once you click this a False constant button will show up, wired to the Loop Condition. The constant has two parts to it a shaded T and a blocked F. This type of constant is called the Boolean. Clicking on the green rectangle will change the selection to a T. Make sure the selection is F.
Figure : Creating a Constant
Figure : Complete While Loop with the False Constant
The first block that we are going to place is the Display Text block.
In the Functions Palette, go to Addons -> NXT Toolkit -> NXT Library -> Display . Here select the Display Text block by clicking on it with the left mouse button.
Figure : Selecting the Display Text block
Now, move the cursor to within the While Loop on the Block Diagram. Place it toward the side of the loop by clicking the left mouse button again, as show in figure.
Figure : Display Text block inside the While Loop
On rolling mouse over the Display Text block, you will see that there are a few terminals on the sides of the block. The terminals and the block itself is explained in the Context Help, which can be displayed by Ctrl+H (or) on the Block Diagram window, go to Help -> Show Context Help. The Context Help for the Display Text can be seen when you mouse over the block.
Figure : Context Help for Display Text block
Creating String Constant : Hello, World
Now, move over the Text terminal on the block and you will see that the cursor changes to a spool of wire cursor. Right click here and in the drop-down menu that appears, go to Create -> Constant. A pink block will appear as shown, and within this type "Hello, World". The program is now complete.
Figure : Completed Program
Now to save the program, go to File -> Save As. A new window, the Name the VI window will open up. Here, go to the folder into which you want to save the program and save the program with a suitable name.
Figure : Saving the Program
To use the program on the NXT brick, we need to download the program using a special tool called the NXT Terminal. Go to the Tools pulldown menu, and select NXT Module-> NXT Terminal. Make sure your NXT is connected to the computer by the USB cable.
Figure : Opening NXT Terminal
In the title bar of the NXT Terminal window, you should see NXT:NXT. The first NXT is to indicate just that this is the NXT Terminal and the second NXT is actually the name of the NXT brick that is connected. NXT is the default name for all NXT's. The Status should be Idle which means that the NXT is connected, but is not running any programs. If the NXT is switched off, it would show Status : Not Connected.
Figure : The two statuses of the NXT Terminal. Make sure the first one is the status when you download the file.
To download and run the program on the NXT, select Compile, Download, and Run on the NXT Terminal and in a few seconds, your NXT will beep and display the text "Hello, World" as shown.
Figure : Compile, Download and Run
Figure : Hello World on the NXT
To end the program, press the gray button below the orange button on the NXT brick. This button is the Stop button on the NXT.