View unanswered posts | View active topics It is currently Fri Aug 29, 2014 12:20 pm






Reply to topic  [ 7 posts ] 
Motor Synchronization 
Author Message
Rookie

Joined: Fri May 02, 2008 8:06 pm
Posts: 2
Post Motor Synchronization
In programming motor synchronization, I find myself typing the following code (or a variation of it) every time I want motors B and C to go straight:

nSyncedMotors = synchBC;
nSyncedTurnRatio = 100;

motor[motorB] = 50;
wait1Msec(4000);

Is it necessary to use the above code EVERY time I want the robot to go straight, or is there a way to type the code only ONCE and make it apply to all of the code that follows it?

Thanks,

rail33


Sat May 17, 2008 4:30 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Jan 31, 2007 3:39 am
Posts: 299
Location: San Diego, California. USA
Post 
Hi rail33

You only need to write the nSyncedMotors and nSyncedTurnRatio once, and it will be remembered through the rest of the code. Here is a code snip it I just put together for you. Let me know if this helps B-)

Scott

Code:
task main()
{

nSyncedMotors = synchBC;  // Motor ‘C' (slave) is slaved to motor ‘B’ (master)... (edited by tfriez)
nSyncedTurnRatio = 100;  // Move in a straight line

while (true)
{
motor[motorB] = 50;
wait1Msec(4000);
motor[motorB] = -50;
wait1Msec(4000);
motor[motorB] = 100;
wait1Msec(4000);
motor[motorB] = -100;
wait1Msec(4000);
motor[motorB] = 0;
wait1Msec(4000);
}

}

_________________
Mmmm Legos B-)

My Robot Projects:
http://www.freewebs.com/robotprojects/


Sat May 17, 2008 6:51 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3196
Location: Rotterdam, The Netherlands
Post 
Starwarskid,

Shouldn't you be controlling the speed of the motors through motorC, not B? Either that or change the nSyncedMotors = synchAC, to synchAB.

Regards,
Xander


Thu May 29, 2008 5:59 am
Profile WWW
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post 
no:
synchBC; master=B, slave=C ! :wink:

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Thu May 29, 2008 6:36 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Jan 31, 2007 3:39 am
Posts: 299
Location: San Diego, California. USA
Post 
It looks like I had a typo, but it is correct now. Sorry for the confusion B-)

Scott

_________________
Mmmm Legos B-)

My Robot Projects:
http://www.freewebs.com/robotprojects/


Thu May 29, 2008 3:05 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3196
Location: Rotterdam, The Netherlands
Post 
starwarslegokid wrote:
It looks like I had a typo, but it is correct now. Sorry for the confusion B-)

Scott

Scott,

Confusion is a permanent state of mind for me.

Huh? What?


Thu May 29, 2008 3:36 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Jan 31, 2007 3:39 am
Posts: 299
Location: San Diego, California. USA
Post 
lol, you came to the right place then :-) feel free to ask any questions, and good luck.

Scott

_________________
Mmmm Legos B-)

My Robot Projects:
http://www.freewebs.com/robotprojects/


Thu May 29, 2008 3:38 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.