BT timing

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
mcsummation
Posts: 220
Joined: 23 Jan 2012, 17:07
Location: Round Rock, TX

BT timing

Post by mcsummation »

I'm working on a dIMU controlled Segway, based on code written by mattallen37, except that I am using Bluetooth instead of IR control. (I have a second NXT, but not the IR system.) I was working on the code that tunes the dIMU Konstants and had it working, except that when the Segway fell over it caused the Bluetooth messaging system to get out of sync. So, I put in a message for the Segway to tell the master it had fallen. Suddenly, the tuning code (master -> slave) quit working. What I found was: the code in the master that was doing a ReceiveRemoteNumber in a loop, looking for the "I've fallen" signal was looping so fast that the "wait for BT idle" before the send could never get an idle channel. I had a Wait(1) in the loop and that wasn't long enough. When I changed it to Wait(5) the Send could get an idle channel and send the tuning message out to the slave.

Yes, the two things were running in separate tasks.

This might explain some of the "lockup" cases we've seen with some of the other Bluetooth controlled robots.
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 0 guests