View unanswered posts | View active topics It is currently Fri Sep 04, 2015 4:11 am






Reply to topic  [ 8 posts ] 
Using Bluetooth with 3 NXT bricks 
Author Message
Rookie

Joined: Thu Apr 03, 2014 11:15 pm
Posts: 2
Post Using Bluetooth with 3 NXT bricks
We're working on a cool underwater robot project where we use three NXT bricks - two for sensors and one for main processing and motor control. The two sensor bricks (slaves) capture sensor data and should send it to the master continuously. The master processes the data and decides what actions to take.

We understand the master-slave concept and we have paired and established contacts correctly, but can only get the master to talk to one brick, not both. We read that the master must send a message to each slave before the slave can respond. But can't find any examples or even functions for the master message. Does anybody know what function(s) would work? Also, do we need to include "btConnect" and "btDisconnect" in the code?


Mon Dec 15, 2014 8:22 pm
Profile
Rookie

Joined: Wed Dec 03, 2014 5:57 pm
Posts: 16
Post Re: Using Bluetooth with 3 NXT bricks
I have a library of functions that I put together to reliably connect 4 NXTs, but it
is coded in NXC. I used NXC for my NXTs, and use RobotC for my EV3. If this
will help you, I can email the files to you. It is a lot of code to post online.
You may be able to translate my NXC code to RobotC, or at least see the sequence
of calls. It took me about a month to get it to reliably connect 4 NXTs. And even
then sometimes, like at Brickfair, when there are dozens (100s) of people around with
cell phones, it would time out if I tried to connect more than 2 NXTs. Are there many
other BT devices near your NXTs? The other thing I did that seemed to increase
reliability, was to always send a 32 value, not other data types. Oh, just to clarify,
I had one master and 3 slaves.


Mon Dec 15, 2014 10:09 pm
Profile
Rookie

Joined: Wed Mar 26, 2014 12:39 pm
Posts: 7
Post Re: Using Bluetooth with 3 NXT bricks
I actually doubt that 1 NXT BT master can connect to more than 1 NXT BT slave by RobotC... :-/ (CMIIW)


Tue Dec 16, 2014 2:34 pm
Profile
Rookie

Joined: Wed Dec 03, 2014 5:57 pm
Posts: 16
Post Re: Using Bluetooth with 3 NXT bricks
Can RobotC use multiple BT channels? Assuming it is possible for RobotC to connect
to multiple NXTs (I'm still learning RobotC), here are a couple more ideas.
Are you using different BT channels for each slave? In NXC, I had the master connect to
a slave on channel 0, then after testing the connection, they would use a unique channel for
each slave. And there are some good BT coding ideas in these 2 books. They are about
NXC, but they may give you some ideas.
Creating Cool Mindstorms NXT Robots by Daniele Benedettelli
LEGO Mindstorms NXT Power Programming Robotics In C by John C. Hansen


Tue Dec 16, 2014 3:17 pm
Profile
Rookie

Joined: Wed Mar 26, 2014 12:39 pm
Posts: 7
Post Re: Using Bluetooth with 3 NXT bricks
AFAIK, as I already wrote, not possible for RobotC


Tue Dec 16, 2014 3:26 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: Using Bluetooth with 3 NXT bricks
It actually is possible in ROBOTC to have multiple NXTs connected to a master brick. Each of the slaves will be connected to the master on their port 0, and the master will be connected to each slave on port 1, 2, or 3. You can see a complete list of the NXT Bluetooth commands at http://help.robotc.net/WebHelpMindstorms/index.htm#Topics/Function_Library_-_LEGO_NXT/Bluetooth_-_NXT.htm%3FTocPath%3DCommand%2520Library%2520-%2520LEGO%2520NXT%7CText-Based%2520ROBOTC%7C_____6. I think the most relevant ones for reading and writing data to multiple NXTs would be cCmdMessageWriteToBluetooth and cCmdMessageRead. I don't believe that you need to use btConnect and btDisconnect in the program to make it work, as long as you connect up all the bricks under the Bluetooth section of the NXT's menu ahead of time. However, I haven't really used robot-to-robot Bluetooth much with ROBOTC, so I can't be certain.

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Wed Dec 17, 2014 1:06 am
Profile
Rookie

Joined: Wed Mar 26, 2014 12:39 pm
Posts: 7
Post Re: Using Bluetooth with 3 NXT bricks
ok, I stand corrected!
Quote:
The ROBOTC BT messaging has been optimized for a single slave connection on the master.
...
ROBOTC also allows for multiple slave support, but a description of this is beyond the scope of this tutorial.


Wed Dec 17, 2014 5:48 am
Profile
Rookie

Joined: Thu Apr 03, 2014 11:15 pm
Posts: 2
Post Re: Using Bluetooth with 3 NXT bricks
Thanks Burning Lights. We'll give it a try and let you know...


Tue Dec 30, 2014 12:59 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.