Wednesday, September 16, 2009

Connecting to NXT on Windows 7 64 bit

For many reasons, it has been quite a long time since I last played with the NXT. At one point I was actually trying to sell mine as well as someone elses, because I just don't have too much time these days. However, because I once said I would write a library in C#.NET I had a bit of a look to see how far I'd actually gotten with it for old times sake. I tried to get all the software up and running, but because I was running Windows 7 RC x64 I had all sorts of problems. Hopefully this guide will help others using Windows 7 (or even Vista x64) in the future.

In this guide I will basically run through the steps of how to get the LEGO NXT software installed and how to connect the NXT brick to a PC running a 64 bit version of Windows 7. I will run through both getting the USB cable working as well as communicating through Bluetooth. A Bluetooth connection will basically appear as a number of Serial COM ports in the Bluetooth device settings. I can't give you support for other libraries and toolkits such as Microsoft Robotics Studio, leJOS, RobotC, etc... I simply haven't used them before!

0. My test system

Windows 7 Ultimate x64 build 7100
NIMBUS USB Bluetooth Dongle

LEGO NXT with USB cable

1. Delete any existing LEGO NXT Software, Drivers and Language Packs

Go to your Programs and Features in your Control Panel and remove any existing LEGO NXT software, NXT drivers and language packs. At this stage you shouldn't have Bluetooth or USB connected to your PC.

2. Prepare Software

First of all we will get all the files that we need in order to get everything working. 


The first thing you will need are some 64 bit drivers for the NXT USB cable. Go to the RobotC download website at http://www.robotc.net/content/lego_down/lego_down.html and download the "NXT - 64 bit operating system" zip file called "NXT_64bit_driver.zip".

The other thing you will need is a copy of the LEGO NXT CD. If you only want to get the USB cable working but you do not want to use the NXT-G Software that comes with the NXT you do not need the CD.

3. Install the NXT 64 bit Driver

Open up the
"NXT_64bit_driver.zip" file you just downloaded and run the "LegoMindstormsNXTdriver64.msi" that is inside it. Follow the prompts with default settings and default installation path.

If you now turn on your NXT brick and plug the USB cable into it and into the PC you should see Windows 7 trying to install the correct drivers. Once completed you should get the following message:


If you have a look in the Device Manager (in Control Panel > System) you should see the newly installed LEGO MINDSTORMS NXT item.

 

Make sure that the NXT is actually turned ON, because it does tend to switch itself off automatically without you noticing. 

If this did not work for you then all I can suggest is that you make sure all previous drivers and anything you have done up to this point is deleted and you start again. Note that the driver I am using here is only for 64 bit systems. The RobotC website also has a 32 bit driver you can try if needed if your system is a 32 bit system.

4. Install the LEGO NXT Software

You now obviously want to try to use the software that comes with the NXT to develop some programs or maybe you only need it to update the firmware and then you will use some other 3rd party library. In any case this is what you need to do to get it going. 

From experience I noticed that you can't just stick in the CD and run the auto launch setup, because it will appear to load but in reality it will only install the NXT Driver (which doesn't work anyway). You can see in the picture below that only the driver is in the list to be installed so something is definitely fishy!


Cancel out of any setup programs that may have already started. We do not want to take the standard route.

To get things going we will install two things manually, which would normally be taken care of by the autorun installer:
  • NXT Software (the actual development tool that will let you build NXT apps)
  • LEGO Mindstorms Language Pack
Open up the CD and go into Bin\LEGO MINDSTORMS NXT Software\NXT_LEGO_MS. Run the "Mindstorms.msi" file to being setup. Just follow the prompts and install the files to the default location. At the end of the setup process you may get an error message as follows:


As long as you have flash installed you should be fine. Just click OK and the installer will finish. 
Now navigate to Bin\Products\LEGO MINDSTORMS - English\LEGO_Eng on the CD. Run the "MidstormsEng.msi" file to start the installer. On the first screen click Next. I'm not sure what you will see now, but I can see that it is trying to install the files into G: drive:


This is wrong so we need to change this to the correct path. Click on Browse and navigate to "C:\Program Files (x86)\LEGO Software\". Your path should now point to the given directory:


You can now click Next and follow the remaining prompts to finish the installation. 

There is actually one more thing that you could install, but it is not necessary. The Meta Uninstaller program is simply a program that allows you to uninstall the LEGO software more easily and all at once. You can however just uninstall LEGO software at a later stage without having to use this program.

If everything was successful you should have the Minstorms logo on your desktop and in your start menu folder. The Programs and Features in the Control Panel should have these programs listed:



You can now launch the LEGO software by clicking on the Mindstorms shortcut on the desktop or start menu. If your installation was successful the Mindstorms software will start with no issues.

5. Test your USB Driver

To check that the USB cable driver that you installed earlier works fine you can either try to update the NXT Brick with the latest 1.05 firmware (available on the LEGO support website) or make a small sample program and try to load it. These steps will not be outline here as there is sufficient documentation and help available from LEGO.

6. Test Bluetooth

The final step in this guide is to ensure that Bluetooth is working as expected. When you plug in a USB Bluetooth dongle or use built in Bluetooth you should already have some icons showing up in your Device Manager. You should see something like this:


Make sure that your NXT Brick is powered up and Bluetooth has been enabled. In the Bluetooth menu you can use the search menu to scan for computers. Assuming your PC's Bluetooth adapter is up and running your NXT Brick should be able to locate it. If at any stage your NXT Brick/PC asks for a PIN just enter 1234 as a default in both the NXT Brick and the PC.

If the NXT Brick was successfully detected and installed as a device you should be able to see it in the Bluetooth devices window of your PC. Something similar to below:


Looking at the properties of the device and clicking on the Hardware tab should give you two serial ports. These are the serial ports (COM Ports) that you will be able to connect to using your own custom software. They are literally just seen as standard serial ports and will automatically transfer over Bluetooth. As follows:

 

The only difference is that your port numbers may not be exactly the same.

7. Final Remarks

Hopefully you should now have USB capabilities to be able to load your software onto the NXT Brick using the Mindstorms development software. If you wish to use a custom programming language or library you can also make use of the Bluetooth serial ports.

If you ever wish to uninstall the LEGO software it is a simple matter of going into your Programs and Features section of the Control Panel and uninstalling all LEGO NXT items.