ROBOTC.net forums
http://robotc.net/forums/

nMotorEncoderTarget Issues
http://robotc.net/forums/viewtopic.php?f=66&t=6028
Page 1 of 1

Author:  StJamesSchool [ Tue Jun 25, 2013 9:57 am ]
Post subject:  nMotorEncoderTarget Issues

Hello fellow programmers! :D

In the nMotorEncoderTarget videos that are part of the RobotC curriculum, it says that the time (if "too much") should NOT effect the program that is running. It should stop at the target if the math is correct. Although we have confirmed that the mathematical part of the programming is correct, when we gave it extra time to make sure it ran the program fully, it still continued and passed the line. Why is the extra time effecting the outcome of the preset distance for the robot?

Thanks again!

Author:  JohnWatson [ Tue Jun 25, 2013 10:14 am ]
Post subject:  Re: nMotorEncoderTarget Issues

Hello,

Would you be able to post the code using the [code] tags? There may be another piece of code that is making the robot continue moving further than it is supposed to, but we'll need to see the code to determine if this is the case or not.

Thank you in advance!

Author:  StJamesSchool [ Tue Jun 25, 2013 10:38 am ]
Post subject:  Re: nMotorEncoderTarget Issues

Thank you for your response! Here is an example of one of our student's programming. He followed all of the mathematical steps correctly and we double checked for him, yet he still went over the line. Lessening the time to the exact time needed would completely go against the entire purpose of this lesson.


Code:
task main()
{
   wait1Msec(1000);   //allow time to move hand away from orange button//

   nMotorEncoder[motorB]=0;         //clear encoder B//
   nMotorEncoder[motorC]=0;         //clear encoder C//

   nMotorEncoderTarget[motorB]=9356.4;    // distance in degrees to be calculated//
   nMotorEncoderTarget[motorC]=9356.4;    // distance in degrees to be calculated//

   motor[motorB]= 50;       //set motorB power//
   motor[motorC]= 50;       //set motorC power//
   wait1Msec(30000);        //set sufficient(or more) time to go distance//
}


Thanks for your help!

Author:  JohnWatson [ Tue Jun 25, 2013 12:19 pm ]
Post subject:  Re: nMotorEncoderTarget Issues

StJamesSchool wrote:
Code:
task main()
{
   wait1Msec(1000);   //allow time to move hand away from orange button//

   nMotorEncoder[motorB]=0;         //clear encoder B//
   nMotorEncoder[motorC]=0;         //clear encoder C//

   nMotorEncoderTarget[motorB]=9356.4;    // distance in degrees to be calculated//
   nMotorEncoderTarget[motorC]=9356.4;    // distance in degrees to be calculated//

   motor[motorB]= 50;       //set motorB power//
   motor[motorC]= 50;       //set motorC power//
   wait1Msec(30000);        //set sufficient(or more) time to go distance//
}


The program looks solid and should work on a physical robot; the reason you are running into this issue is because the 'nMotorEncoderTarget' and 'nMotorSync' commands are unfortunately not supported in Robot Virtual Worlds at this time. However, the nMotorEncoder command is and can be used to control the robot's movement using encoders. For more information on this subject, please see this thread: viewtopic.php?f=55&t=5238&

Author:  StJamesSchool [ Wed Jun 26, 2013 9:49 am ]
Post subject:  Re: nMotorEncoderTarget Issues

Thanks again!

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/