LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Laptop to NXT to NXT Bluetooth Connectivity Problem

Vital Info

LabVIEW v10.0

Lego NXT Module

Lego NXT Firmware v1.29

 

Hello people, this should prove to be an entertaining problem!

 

Part of my university final year project involves the use of two LEGO Mindstorms devices and a laptop.  The laptop is running a program wittern in C++ that utilises the Bluetooth communication libraries created by Anders Søberg.  What I wish to achieve is to have the laptop send a message to the first NXT device, henceforth know as "A", which then passes the message to the second NXT device, henceforth know as "B".  So the Bluetooth network setup looks like this:

 

Laptop <-> "A" <-> "B"

 

Now last year, before starting my project, I created a couple of very simple VIs to ensure that this core component of my project worked.  I also ensured that "A" was connected to "B" on connection 1.  The laptop program would connect to A and send it a string.  "A" meanwhile would be constantly checking its mailbox to see if a message had been received.  Upon receiving the message "A" would display it on the screen and then pass it to "B" who, like "A", was constantly checking its mailbox for a response.  Once "B" got the message from "A" it displayed.  I ran this test several times and it worked.

 

I stress that point because a few months down the line I started on the full implementation phase of my project and I encountered a problem: the Bluetooth was responding erratically with my more complicated VIs.  So I did some troubleshooting and was completely unable to come up with definitive repeatable results.  Below are the tests I conducted.

 

Scenario

Expected Outcome

Actual Outcome

No devices connected

No programs running

Connect Laptop to NXT-A and send message

Connection established.

Connection established.

No devices connected

Run basic message display

Connect Laptop to NXT-A and send message

Connection established.

NXT-A displays message

 

Connection established.

Message displayed.

No devices connected

No programs running

Connect Laptop to NXT-B and send message

Connection established.

Connection established.

No devices connected

Run basic message display

Connect Laptop to NXT-B and send message

Connection established.

NXT-B displays message

 

Connection established.

Message displayed.

No programs running

Connect NXT-A to NXT-B

Connect Laptop to NXT-A and send message

Connection established.

Connection established most of the time, however this basic test has been repeated on numerous occasions with an occasional failure.

Run basic mail test program

Connect NXT-A to NXT-B

Connect Laptop to NXT-A and send message

Connection established.

NXT-A displays message

NXT-B displays message

Connection failed, communication port busy.  (This with the EXACT same setup as in the feasibility study)

Swap out NXT devices

Run basic mail test program

Connect NXT-A to NXT-B

Connect Laptop to NXT-A and send message

Test on all ports

Connection established.

NXT-A displays message

NXT-B displays message

Connection failed, communication port busy.

Swap out NXT devices

Flash Bluetooth firmware

Run basic mail test program

Connect NXT-A to NXT-B

Connect Laptop to NXT-A and send message

Test on all ports

Connection established.

NXT-A displays message

NXT-B displays message

Connection failed, communication port busy.

Swap out NXT devices

Change computer

Run basic mail test program

Connect NXT-A to NXT-B

Connect Laptop to NXT-A and send message

Test on all ports

Connection established.

NXT-A displays message

NXT-B displays message

Connection failed, communication port busy.

Swap out NXT devices

Change computer

No devices connected

Run basic message display

Connect Laptop to NXT-A and send message

Test on all ports

Connection established.

NXT-A displays message

 

Connection established.

Message displayed.

 

Please note that "basic message display" is referring to my initial programs from last year; the ones that worked, that are now no longer working with no code changes.  The error message "communication port busy" was the only message the Bluetooth libraries gave me.

 

As you can see I tried everything, even going so far as to swap out all the hardware components.  The real part that puzzles, the one part I cannot fathom is why, when "A" and "B" are not connected, I can connect to each one in turn with no issues, yet when I connect them both I receive that error.  You could say perhaps I was using the wrong port in my C++ program, but then why did it fail when I changed the connection number between "A" and "B"?  Aside from the assignation of connection to a number and the devices involved there is precious little I can actually do to control the connectivity, it is all done by the firmware.  Surely a network protocol is an interface, meaning if the laptop connects to A and can connect to B afterwards, there is no good reason they cannot be connected in a chain.  The LEGO Mindstorms devices are supposed to support 3-4 simultaneous connections!

 

To my mind it boils down to this one question: Why can the laptop connect to "A" or "B" with no problems when they are not connected, but fail when they are?

0 Kudos
Message 1 of 3
(3,655 Views)

*Bump*

 

This is a time sensitive problem, and I hope not a complex one.  I hand in my project at the end of the week and this lynch-pin is the only part that doesn't work; without it my project doesn't function.

 

If it helps garner interest I have build a gantry crane system, partially out of LEGO, that is controlled by the NXT devices.  The prgram running on the laptop is a chess game.  A player makes a move that is validated and then sent to the crane, the crane then moves the piece.  I even have a very simple AI so that the robot could play itself, but none of that makes a jot of difference if the lines of communication don't work!

 

I would greatly appreciate any input!

0 Kudos
Message 2 of 3
(3,624 Views)

After many people invested many hours of troubleshooting it came to light that because the NXTs are set up as master/slave devices they cannot be both at the same time, meaning that any "chaining" of devices is impossible.

 

Quite why the basic test program worked the first time around with the devices chained is, however, a complete mystery.

0 Kudos
Message 3 of 3
(3,569 Views)