|
Page 1 of 1
|
[ 7 posts ] |
|
Author |
Message |
rail33
Rookie
Joined: Fri May 02, 2008 8:06 pm Posts: 2
|
 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 |
|
 |
starwarslegokid
Moderator
Joined: Wed Jan 31, 2007 3:39 am Posts: 299 Location: San Diego, California. USA
|
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
_________________Mmmm Legos B-) My Robot Projects: http://www.freewebs.com/robotprojects/
|
Sat May 17, 2008 6:51 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
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 |
|
 |
Ford Prefect
Guru
Joined: Sat Mar 01, 2008 12:52 pm Posts: 1030
|
no:
synchBC; master=B, slave=C ! 
_________________ 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 |
|
 |
starwarslegokid
Moderator
Joined: Wed Jan 31, 2007 3:39 am Posts: 299 Location: San Diego, California. USA
|
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 |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
Scott,
Confusion is a permanent state of mind for me.
Huh? What?
|
Thu May 29, 2008 3:36 pm |
|
 |
starwarslegokid
Moderator
Joined: Wed Jan 31, 2007 3:39 am Posts: 299 Location: San Diego, California. USA
|
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 |
|
|
|
Page 1 of 1
|
[ 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
|
|