Bluetooth with NXC

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
thegenie
Posts: 8
Joined: 16 Jul 2011, 20:05

Bluetooth with NXC

Post 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! : )
mcsummation
Posts: 220
Joined: 23 Jan 2012, 17:07
Location: Round Rock, TX

Re: Bluetooth with NXC

Post by mcsummation »

You might get some ideas based on things I posted at http://jisum.com/Mindstorms/Bluetooth/.
tabbycatrobots
Posts: 100
Joined: 27 Dec 2010, 19:10

Re: Bluetooth with NXC

Post 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.
tabbycatrobots
Posts: 100
Joined: 27 Dec 2010, 19:10

Re: Bluetooth with NXC

Post 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.
Attachments
Ty_Dncr_31_BT_Related_Files.zip
BT connection and sync code.
(21.13 KiB) Downloaded 357 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest