Syncing the NXT motors

Discussion specific to the intelligent brick, sensors, motors, and more.
Post Reply
jojoguy14
Posts: 155
Joined: 29 Sep 2010, 12:49
Contact:

Syncing the NXT motors

Post by jojoguy14 »

Hello everyone,

I help coach an FLL team and we're having problems with our motors. Some of them are faster/slower than others. I know that this is bound to happen, but I thought there was a way to re-sync them to each other. They're using NXT-G, so I can't use the OnFwdSync() from NXC.

Is there a way to re-sync two motors to each other?

jojoguy10
Creator of LEGO-X TechN'XT! (http://lego-x.com http://techn-xt.blogspot.com)
Known as jojoguy10
themindstormman
Posts: 94
Joined: 01 Apr 2011, 22:46
Contact:

Re: Syncing the NXT motors

Post by themindstormman »

have you tried using move instead of motor blocks?
Themindstormman3141
Website admin of themindstormman3141.com
NXT FOR ALL
nxtreme
Posts: 246
Joined: 29 Sep 2010, 03:53
Location: 192.168.1.2

Re: Syncing the NXT motors

Post by nxtreme »

One King to rule them all, One King to find them,
One King to bring them all and in the darkness bind them
On Earth where Shadows lie.
jojoguy14
Posts: 155
Joined: 29 Sep 2010, 12:49
Contact:

Re: Syncing the NXT motors

Post by jojoguy14 »

Thanks! This looks like a good idea!
themindstormman wrote:have you tried using move instead of motor blocks?
Why would that work better?

jojoguy10
Creator of LEGO-X TechN'XT! (http://lego-x.com http://techn-xt.blogspot.com)
Known as jojoguy10
themindstormman
Posts: 94
Joined: 01 Apr 2011, 22:46
Contact:

Re: Syncing the NXT motors

Post by themindstormman »

they automatically sink the 2 motors
Themindstormman3141
Website admin of themindstormman3141.com
NXT FOR ALL
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: Syncing the NXT motors

Post by muntoo »

themindstormman wrote:they automatically sink the 2 motors
I don't think that the OP wants to turn his robot into the Titanic... ;)

Yes, the Move Block will handle all the syncing for you; you just need to set the direction/ratios of the two motors.
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
jojoguy14
Posts: 155
Joined: 29 Sep 2010, 12:49
Contact:

Re: Syncing the NXT motors

Post by jojoguy14 »

OK, so maybe it's just misaligned tires or something. Thanks for all the quick replies!

jojoguy10
Creator of LEGO-X TechN'XT! (http://lego-x.com http://techn-xt.blogspot.com)
Known as jojoguy10
milluzaj
Posts: 31
Joined: 28 Sep 2010, 22:15

Re: Syncing the NXT motors

Post by milluzaj »

It might be a good learning exercise to make a myblock to sync the motors. I know the myblock I have made with my FLL team to sync motors works better than the move bock. It also taught my FLL team a lot about how motor control really works.
Blog: 08milluz.wordpress.com
LMS Shuttle: facebook.com/lmsshuttle
jojoguy14
Posts: 155
Joined: 29 Sep 2010, 12:49
Contact:

Re: Syncing the NXT motors

Post by jojoguy14 »

milluzaj wrote:It might be a good learning exercise to make a myblock to sync the motors. I know the myblock I have made with my FLL team to sync motors works better than the move bock. It also taught my FLL team a lot about how motor control really works.
Do you think you can give me an overview of how you did that? Or is it like confidential :-)

jojoguy10
Creator of LEGO-X TechN'XT! (http://lego-x.com http://techn-xt.blogspot.com)
Known as jojoguy10
muntoo
Posts: 834
Joined: 01 Oct 2010, 02:54
Location: Your Worst Nightmare
Contact:

Re: Syncing the NXT motors

Post by muntoo »

Pseudo code:

Code: Select all

VARIABLES:
    // Start values
    Number motorBstart
    Number motorCstart

    // The distance you want the motors to travel in degrees
    Number distB = 360
    Number distC = 720

    // The distance in degrees remaining to go for each motor
    Number distLeftB
    Number distLeftC

    // Power (%) for each motor
    Number powerB
    Number powerC

    Number BASE_POWER = 50

Code: Select all

PROGRAM:

motorBstart = Rotation_Count (or whatever) of Motor B
motorCstart = Rotation_Count (or whatever) of Motor C

LOOP BEGIN
    distLeftB = distB - (Rotation_Count_of_B - motorBstart)
    distLeftC = distC - (Rotation_Count_of_C - motorCstart)

    // This part can vary with what you want exactly
    // It can be as complicated as you can make it, and it'll never really be "perfect", IMHO
    powerB = (100 * distLeftC / distC) - (100 * distLeftB / distB) + BASE_POWER
    powerC = (100 * distLeftB / distB) - (100 * distLeftC / distC) + BASE_POWER

    // NOTICE: Asking to move the motor differently while it's still moving will overwrite the previous commands;
    // It'll stop listening to those, and re-correct its power/degrees to go forward by
    Move Motor B Forward by distLeftB with the Power of powerB
    Move Motor C Forward by distLeftC with the Power of powerC
LOOP END
You'll need to use data wires, and the motorBstart and motorCstart variables are necessary. The others can be done without variables, although if it were me, I'd make it easier on myself and use variables.

For Rotation_Count_of_B and Rotation_Count_of_C, use the degrees data wire output of the Motor Rotation Count/"Sensor" blocks.
Image

Commit to LEGO Mindstorms Robotics Stack Exchange:
bit.ly/MindstormsSE


Commit to LEGO Stack Exchange: bit.ly/Area51LEGOcommit
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests