Page 1 of 1
Syncing the NXT motors
Posted: 06 Apr 2011, 23:26
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
Re: Syncing the NXT motors
Posted: 07 Apr 2011, 02:05
by themindstormman
have you tried using move instead of motor blocks?
Re: Syncing the NXT motors
Posted: 07 Apr 2011, 02:26
by nxtreme
Re: Syncing the NXT motors
Posted: 07 Apr 2011, 02:54
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
Re: Syncing the NXT motors
Posted: 07 Apr 2011, 03:25
by themindstormman
they automatically sink the 2 motors
Re: Syncing the NXT motors
Posted: 07 Apr 2011, 04:32
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.
Re: Syncing the NXT motors
Posted: 07 Apr 2011, 12:34
by jojoguy14
OK, so maybe it's just misaligned tires or something. Thanks for all the quick replies!
jojoguy10
Re: Syncing the NXT motors
Posted: 07 Apr 2011, 12:43
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.
Re: Syncing the NXT motors
Posted: 07 Apr 2011, 13:49
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
Re: Syncing the NXT motors
Posted: 07 Apr 2011, 23:30
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.