View unanswered posts | View active topics It is currently Mon Feb 08, 2016 7:28 pm

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Turning using encoders
Author Message
Rookie

Joined: Tue Jun 18, 2013 6:04 pm
Posts: 29
Turning using encoders
Referencing Wednesday's class, since there was no wait programmed when making a turn using the encoders, how does the robot know how far to turn?
Chris

Sun Jun 23, 2013 6:10 pm
Moderator

Joined: Mon Oct 04, 2010 2:18 pm
Posts: 196
Re: Turning using encoders
The robot will know how far to turn using the encoder values, just as if it was going straight. Take a look at the code below:
 Code:task main (){//Clear the encoders   nMotorEncoder[motorB] = 0;   nMotorEncoder[motorC] = 0;   while(nMotorEncoder[motorB] < 150)//turn left until encoder value reaches 150   {      motor[motorB] = 20;      motor[motorC] = -20;      }   motor[motorB] = 50; //move forward   motor[motorC] = 50;   wait1Msec(4000);}

The condition inside of our while loop is motorB reaching an encoder count of 150. As long as that condition is correct,
the robot will make a point turn left. As soon as the condition is no longer true, the loop breaks and the robot moves forward.

The robot moves proportionally, so if at an encoder count of 150, the robot makes a 45 degree turn, you can double your encoder
value and it should make a 90 degree turn. Experiment with it, and see what happens.

Sun Jun 23, 2013 7:28 pm
Rookie

Joined: Tue Jun 18, 2013 6:04 pm
Posts: 29
Re: Turning using encoders
Hi Parkway,
Thanks for responding. Please excuse my thickheadedness, but how does 150 = a 45 degree turn?

Sun Jun 23, 2013 9:07 pm
Moderator

Joined: Mon Oct 04, 2010 2:18 pm
Posts: 196
Re: Turning using encoders
No problem. Remember, encoder values are degrees that the wheel is rotating. 45 degrees is the amount that the robot is turning. Try to think of it in these terms: in a left point turn, the left wheel is going backwards and the right wheel is moving forwards. You can go here to see a picture of what I mean:

http://www.robotc.net/support/nxt/MindstormsWebHelp/index.htm#page=robot_algebra/robot_movements/Robot%20Movements.htm

So, what you are really trying to figure out is "How many encoder counts (degrees) does my right wheel need rotate in order for my robot to make a 45 degree, left turn?"'

Keep in mind, I'm not saying that is the correct amount of encoder counts. You may have to play around with the values until you find the correct ones. I hope that clears it up for you.

Sun Jun 23, 2013 9:31 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    2014 Robotics Academy Summer of Learning    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