View unanswered posts | View active topics It is currently Sat Sep 19, 2020 12:43 pm

Reply to topic  [ 4 posts ] 
palm island- moving and turning 
Author Message

Joined: Thu Jun 27, 2013 9:25 pm
Posts: 4
Post 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;


Sun Jul 07, 2013 4:12 pm

Joined: Mon Oct 04, 2010 2:18 pm
Posts: 196
Post 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.

Sun Jul 07, 2013 4:44 pm
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: palm island- moving and turning
I see the problem... Look at your negatives.

A.K.A. inxt-generation
Self-proclaimed genius, and future world dominator.
My Brickshelf Folder
"Don't they teach recreational mathematics anymore?" - The Tenth Doctor
Bow down to Nikola Tesla, King of the Geek Gods.

Sun Jul 07, 2013 4:53 pm
Profile WWW
Site Admin
Site Admin
User avatar

Joined: Tue Oct 09, 2012 10:34 am
Posts: 192
Post 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


Ryan Cahoon
CMU Robotics Academy
RVW Software Developer

Robot Potato Head; Virtual NXT

Sun Jul 07, 2013 8:48 pm
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

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.