When the Fantom driver was released, I was somewhat disappointed that LEGO released only a low-level interface. Indeed, within a few weeks several high-level wrappers were created by the community — such as NXT#, iCommander, Ruby-NXT, SimpleNXT etc. Yet there was still no high-level VI library for LabVIEW that allowed easy PC control over Bluetooth (BT) or USB.
Now, with the release of the NXT LabVIEW Toolkit from NI, this vacancy has been filled. The NXT Toolkit has three major components: a set of VIs that can be compiled into NXT code and run on-brick, a set of support VIs that allow creating new NXT-G Blocks, and a set of VI wrapping Fantom into higher-level graphical programming library for NXT control on PC (and Mac).
As a first glance into the Toolkit’s DirectCommand (DC) VIs library, let’s look at a simple example:
This code plays a tone on a remote NXT. It first searches for an NXT with name “NXT”. Once found it creates an “NXTObject”, needed for all other commands that interacts with the particular NXT unit. After playing a tone, it destroys the NXTObject (as one allways should do) and exits. Notice how similar this is to NXT-G and RoboLab programming (not very surprising, as both are based on LabVIEW…). Error handling is done in the “LabVIEW way”, by passing Error data cluster from a VI “error in” and out from an “error out” threading the program. This error wires are useful not only to pass error codes, but they also control program flow, since one block awaits the previous block to terminate based on the error wire. To see this, let’s look underneath the PlayTone VI:
As one can see, the actual “action” is in the middle “fantom direct” VI which call to the driver DLLs.
So, what VIs does the NXTToolkit DC library include? Here’s a list of the VIs sorted by menus:
Connection
Find NXT
Scan for NXTs
Create NXTObject
Destroy NXTObject
Get NXT Info
Bluetooth Is Paired
Pair Bluetooth
Unpair Bluetooth
Input
Read Touch Sensor
Read Sound Sensor
Read Light Sensor
Read Ultrasound Sensor
DC.Read Sensor Value
Get Input Values
Set Input Mode and Type
Clear Input Value
Lowspeed Read
Lowspeed Write
Get Lowspeed Status
Output
Motor Unlimited
Motor Stop
Get Output Values
Set Output State
Reset Motor Position Sound
Play Sound File
Play Tone
Stop Sound File I/O
Download File
Upload File
Delete File
List Files
Defragment Files
BT Messages
Message Write
Read Message
Program Execution
Start Program
Stop Program
Get Current Program Name
Utilities
Keep Alive
Rename NXT
Get VISA resouce string
Get Battery Level
Get Device Info
Get Firmware Version
Advanced
Read IOMap
Write IOMap
The name of most VIs already explains their function. Furthermore, each VI has a fairly detailed “Context Help” (press Ctrl+H to see it) automatically shown when the mouse hovers over the VI.
What are the main advantages of using LabVIEW? Well, for starters, it is a simple to use graphical programming language. The toolkit VIs come from the same source (National Instruments) that develops NXT-G, so they probably know what they’re doing. Furthermore, you have the full power of LabVIEW, including all types of structures (loops, for loops, case switches etc.) and it is very easy to make impressive user interfaces. LabVIEW has a rich collection of “controls” like text boxes, dials, sliders, listboxes etc. and is very easy to use after a relatively steep learing curve.
Where to get hold of a LabVIEW copy? This is indeed a difficult question at the present time. LabVIEW Basic version and Full version are much too expansive for most NXT hobbyists. There is a Student version, but this is not available to the genral audience. Personally, I hope NI plans to release some “Mindstorms LabVIEW” version (possibly with more limited functionality then student version) and market it through LEGO for the rest of us. The NI guys I talked to during the beta testing stages of the toolkit promised I “will not be disappointed” by their answer to this question, but didn’t reveal it…

