Bluetooth - Jerky Movement

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
causticwolf
Posts: 2
Joined: 20 Nov 2012, 02:06

Bluetooth - Jerky Movement

Post by causticwolf »

Hello everyone,
I built a mobile arm with two NXTs, and I'm using Bluetooth to send the arm-controlling NXT commands from the driving (master) NXT. I'm controlling the whole thing with a PSP-Nx connected to the driving NXT. The arm was moving somewhat jerkily, and when I looked at the data being sent, every ~1/2 second it receives a 0 for no reason, causing the motors to brake very briefly.

Something I tried:
Check if the received # is a 0
-- If it isn't 0, set a variable with the number, then in a separate loop have a motor block read the variable
-- If it is 0, don't set the variable with the number

This works somewhat, but Bluetooth is too slow to receive a very low number, so it moves with >30 power, enough to keep the arm moving. Any ideas for a solution?
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Bluetooth - Jerky Movement

Post by HaWe »

in fact, at least theoretically, there would be a solution to deliver us from evil Lego BT protocol...
:twisted:
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Bluetooth - Jerky Movement

Post by mattallen37 »

Can you post your program?
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
causticwolf
Posts: 2
Joined: 20 Nov 2012, 02:06

Re: Bluetooth - Jerky Movement

Post by causticwolf »

I just discovered something kind of interesting. I was curious as to how long the whole send loop took to execute, so I programmed it to display how long it took in hopes of creating the same delay in the slave program. When I tested it, the jerkiness was completely gone with no modifications to the display program. Maybe there's some kind of a magic number for Bluetooth loops? The whole loop took 87-88ms to execute. I did the same thing to the loop in the slave program, and it takes 105ms with a 100ms delay programmed in. Maybe there's some kind of relation to these numbers? This seems like something that should be explored further. I attached the programs here for anyone interested. The only special block you need is the PSP-Nx Lean block (for the PS2 controller)

Edit:
Okay, I just did something that messed that whole thing up. I forgot to fix a couple blocks related to sending the open-close claw motor commands, and the jerkiness is back. The loop now takes 177-179ms to execute. Maybe the problem has something to do with the master loop taking longer than the slave loop? Or maybe the slave NXT just can't handle information coming into three mailboxes at once...

This is really interesting; I'm gonna keep experimenting and see what happens.

Another edit:
I changed the delay on the slave loop so it runs at 180ms exactly, and the jerkiness is gone. It definitely seems to be caused by the master loop taking longer than the slave loop. This is weird because it seems like this problem should be caused by the master being faster than the slave, and the slave gets overloaded with messages.

Programs:
MobileArm-MASTER.rbt
Program for the master NXT
(1.8 MiB) Downloaded 271 times
MobileArm-SLAVE.rbt
Program for the slave NXT
(962.31 KiB) Downloaded 257 times
hassenplug
Posts: 346
Joined: 27 Sep 2010, 03:05
Contact:

Re: Bluetooth - Jerky Movement

Post by hassenplug »

The problem here is pretty simple, but not obvious. You need to check the mailbox to see if a new message has arrived. If the message received flag is false, DO NOT read the mailbox or set the motor.

The slave keeps reading values out of the mailboxes. Because it's reading faster than the messages are arriving, it empties the mailbox, and starts reading zeros. When that happens, it sets the motor speed to zero.

Steve
---> Link to lots of MINDSTORMS stuff under my picture --->
Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests