palm island- moving and turning
Page 1 of 1

Author:  farkuka27 [ Sun Jul 07, 2013 4:12 pm ]
Post subject:  palm island- moving and turning

i'm using the sample program for mission 2 of palm island and i'm not sure what i'm doing wrong on this turn, but it keeps turning in circles even though i set it to go 1/4 revolution before it stopped. that part of the code is below:

//Point turn to the right at half speed for 90 counts of the right motor encoder, and stop
while(nMotorEncoder[rightMotor] < 90)
motor[rightMotor] = -50;
motor[leftMotor] = 50;


Author:  parkway [ Sun Jul 07, 2013 4:44 pm ]
Post subject:  Re: palm island- moving and turning

Please use the code tags when posting your code; it makes it easier to see. Did you clear your encoders before you used them in the while loop? Also, don't forget that 90 encoder counts (the condition in your while loop) won't guarantee that your robot makes a 90 degree turn . It means that your right motor is going to turn 90 degrees. I hope that makes sense. Please feel free to post some more code and/or ask some more questions if you have them.

Author:  NeXT-Generation [ Sun Jul 07, 2013 4:53 pm ]
Post subject:  Re: palm island- moving and turning

I see the problem... Look at your negatives.

Author:  rcahoon [ Sun Jul 07, 2013 8:48 pm ]
Post subject:  Re: palm island- moving and turning

Hi farkuka,
I think the problem here is that the encoders produce signed values: if the motor turns forward, the encoder counts up, if the motor turns backwards, the encoder counts down. Since your code is making the right motor turn backwards, the right encoder will get more and more negative over time. Try changing your loop condition to
while(nMotorEncoder[rightMotor] > -90)

Also, make sure you zero your encoder values before you start a new movement:
nMotorEncoder[rightMotor] = 0


Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group