View unanswered posts | View active topics It is currently Sun Jan 26, 2020 11:27 am

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
palm island- moving and turning
Author Message
Rookie

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

stop();

Sun Jul 07, 2013 4:12 pm
Moderator

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

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
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

Joined: Tue Oct 09, 2012 10:34 am
Posts: 192
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
 Code:while(nMotorEncoder[rightMotor] > -90)

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

Cheers,
--Ryan

_________________
Ryan Cahoon
RVW Software Developer

Sun Jul 07, 2013 8:48 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 4 posts ]

Who is online

Users browsing this forum: No registered users and 1 guest

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

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning