ROBOTC.net forums
http://robotc.net/forums/

Synchrounous Motor movement for EV3
http://robotc.net/forums/viewtopic.php?f=1&t=9858
Page 1 of 1

Author:  minaobe18 [ Thu Nov 20, 2014 1:19 pm ]
Post subject:  Synchrounous Motor movement for EV3

Hi,

I am attempting to get a robot to move autonomously throughout a maze. I have gotten the program to work, but my turns are not accurate and it throws the entire program off. I found the syntax for the setMotorSyncEncoder and setMotorSyncTime but there were no parameters listed in the documentation. How do I implement these functions? Also, will these two functions make the motors moves synchronously?

such as the moveMotorTarget below , the parameters are given so i filled them in to pertain to my code. I have no clue what should go inside the parenthesis to make the functions above work.
moveMotorTarget (motorB, ROTATION_PER_90_DEGREES, MAX_MOTOR_SPEED);

Please Help!

Author:  mightor [ Fri Nov 21, 2014 2:14 am ]
Post subject:  Re: Synchrounous Motor movement for EV3

They're not documented yet because we only added them in the last version. My apologies for that. You can sync two motors with this. An example:
Code:
#pragma config(Motor,  motorA,          LEFT,          tmotorEV3_Large, PIDControl, encoder)
#pragma config(Motor,  motorB,          RIGHT,         tmotorEV3_Large, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

// sync motor test
task main()
{
   setMotorSyncTime(LEFT, RIGHT, 0, 2000, 50);
   sleep(3000);
}

We included two test examples in the samples folder, which you can access via File->Open Sample Program. They reside in the "Miscellaneous" folder.

The prototypes for these functions are:
Code:
void setMotorSyncEncoder(tMotor nMotorOne, tMotor nMotorTwo, long nTurnRatio, long nEncoderCount, long nSignedPower);
void setMotorSyncTime(tMotor nMotorOne, tMotor nMotorTwo, long nTurnRatio, long nTimeMsec, long nSignedPower)


= Xander

Author:  minaobe18 [ Fri Nov 21, 2014 8:16 am ]
Post subject:  Re: Synchrounous Motor movement for EV3

Thanks Xander! I have one more question. Will this help me to achieve a more precise turn? I need to get as close to 90 degrees as possible. What value should be used for nTurnRatio to make turns possible?

Author:  mightor [ Fri Nov 21, 2014 8:21 am ]
Post subject:  Re: Synchrounous Motor movement for EV3

Well, the trouble with wheels is that they slip. If you want precise turns, you must use a gyro or compass :) That said, if your surface is not too slippery and your wheels are kept clean, it should be fairly OK.

= Xander

Author:  minaobe18 [ Fri Nov 21, 2014 11:03 am ]
Post subject:  Re: Synchrounous Motor movement for EV3

Ok thank you Xander!

Author:  techlane [ Wed Jan 28, 2015 3:07 pm ]
Post subject:  Re: Synchrounous Motor movement for EV3

I tried using the suggested code:

Quote:
#pragma config(Motor, motorA, LEFT, tmotorEV3_Large, PIDControl, encoder)
#pragma config(Motor, motorB, RIGHT, tmotorEV3_Large, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

// sync motor test
task main()
{
setMotorSyncTime(LEFT, RIGHT, 0, 2000, 50);
sleep(3000);
}


This worked great using a physical robot, but it didn't work on the virtual world. Any suggestions?

Author:  mightor [ Thu Jan 29, 2015 1:36 am ]
Post subject:  Re: Synchrounous Motor movement for EV3

You can split it up into two separate motor commands. You'll find that in the Virtual World that motors don't drift apart very much, if at all :)

= Xander

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/