Page 1 of 1

Bluetooth with NXC

Posted: 04 Feb 2013, 01:26
by thegenie
Remember my artillery project? Those test fires are done, the data points formed a nearly perfect line, and I'm on to programming the robot. The first thing I did was make a the subroutines for the trajectory calculator, move to absolute position, etc. Those all work flawlessly. Next, I tried making programs for a remote NXT for heading and distance input, and for the turret to move to the necessary position. Both programs work fine independently.

The bluetooth communication doesn't work though. I've done very little with BT in NXC so far, and that online NXC guide has been very helpful with understanding individual functions, but it's not helping me so much with say, waiting for a "ready" command from one robot or other subroutine-y things.

If someone could point me in the right direction on this, I would greatly appreciate it. Any other resources, sample code, or just tips would help me a lot. Thanks! : )

Re: Bluetooth with NXC

Posted: 04 Feb 2013, 04:27
by mcsummation
You might get some ideas based on things I posted at http://jisum.com/Mindstorms/Bluetooth/.

Re: Bluetooth with NXC

Posted: 04 Feb 2013, 18:00
by tabbycatrobots
I agree - I found getting BT to do something useful seems very complicated at first.
I posted some ideas and code in Mindstorms Software about a year ago, see my post
with topic <Pathfinding - BlueTooth - 4 NXTs - multiple queues>. I was trying to have
4 robot dancers all step off at the same time. There may be some ideas in this code to
help you synchronize your robots. I have since completed the dance code, and will
try to pull that together in a zip file later today and post.
The book "Creating Cool Mindstorms NXT Robots" by Daniele Benedettelli, has many
good BT ideas that helped me.

Re: Bluetooth with NXC

Posted: 04 Feb 2013, 20:56
by tabbycatrobots
Attached is a zip file of the BT related code that I'm currently using.
If you are trying to sync just 2 NXTs, the code in the functions:
ldr_duo_poll_and_sync(unsigned char dncr_role)
and
sprt_recv_poll_and_sync()
may have some ideas that will help. ldr (leader) is the BT master
and sprt (support) is the BT slave.
Off on a tangent - I find ldr making the BT connection to be very
reliable with 2 exceptions, 1. low batteries, 2. many people nearby
(within ~30 ft) with cell phones.