View unanswered posts | View active topics It is currently Fri Aug 01, 2014 11:01 am






Reply to topic  [ 2 posts ] 
Drive Straight code? 
Author Message
Rookie

Joined: Tue Nov 30, 2010 9:24 pm
Posts: 11
Post Drive Straight code?
Is there anybody with a drive straight code for robotc with encoders? my motors are unequally matched and im wondering if there is a way to use encoders to make sure they go the same speed. Any help would be appreciated :)


Tue Feb 01, 2011 4:46 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Drive Straight code?
You could do something like this:
Code:
int diff;
nMotorEncoder[leftMotor] = 0;
nMotorEncoder[rightmotor] = 0;
while (true)
{
    diff = (nMotorEncoder[rightMotor] - nMotorEncoder[leftMotor])/scaleFactor;
    motor[leftMotor] = 50 + diff;
    motor[rightMotor] = 50 - diff;
    wait1Msec(10);
}

Or you can use the built-in motorSync function. I don't have RobotC in front of me, so I don't remember the syntax.


Tue Feb 01, 2011 5:22 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.