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

Need help with encoder programming. Badly
http://www.robotc.net/forums/viewtopic.php?f=1&t=5546
Page 1 of 1

Author:  itsBenton [ Tue Feb 26, 2013 12:00 pm ]
Post subject:  Need help with encoder programming. Badly

Code:
#pragma config(Hubs,  S1, HTMotor,  none,     none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Motor,  mtr_S1_C1_1,     Left,          tmotorTetrix, PIDControl, reversed, encoder)
#pragma config(Motor,  mtr_S1_C1_2,     Right,         tmotorTetrix, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
  nMotorEncoder[Left] = 0;
  nMotorEncoder[Right] = 0;
 
   {
      nMotorEncoderTarget[Left] = 360;
      nMotorEncoderTarget[Right] = 360;
      motor[Left] = 70;
      motor[Right] = 70;
   }

      while(nMotorRunState[Left] != runStateIdle && nMotorRunState[Right] != runStateIdle)
   
      {
         nMotorEncoder[Left] = 0;
         nMotorEncoder[Right] = 0;
      }
}


this is the code and its just not working for me. PLEASE HELP

Author:  mightor [ Tue Feb 26, 2013 12:07 pm ]
Post subject:  Re: Need help with encoder programming. Badly

Hi Benton,

How about you add a little explanation about what you're looking to achieve. None of us are psychic and even if we were, we'd never let on.

So how about you write a little post about what you've tried, what you're seeing and what you think might be the issues.

= Xander

Author:  itsBenton [ Tue Feb 26, 2013 12:17 pm ]
Post subject:  Re: Need help with encoder programming. Badly

well, im looking for the robot to drive forward till the IR seeker reads 5. (i have not put in the IR yet). If it does not read 5, continue. if it does read 5, Make a 90 degree turn to the left and then lift our arm for this years competition. Then the robot will drive forward and place the ring on the post. (again, i have not programmed that far yet)

Author:  Coder A [ Tue Feb 26, 2013 12:45 pm ]
Post subject:  Re: Need help with encoder programming. Badly

Your code never finishes as the encoders are constantly being reset, and never reach 360 so they can stop. First you will want to change both !='s to =='s in the while statement.

Author:  itsBenton [ Tue Feb 26, 2013 12:50 pm ]
Post subject:  Re: Need help with encoder programming. Badly

Coder A wrote:
Your code never finishes as the encoders are constantly being reset, and never reach 360 so they can stop. First you will want to change both !='s to =='s in the while statement.


for every video or thing ive seen, it says !=

Author:  mightor [ Tue Feb 26, 2013 1:12 pm ]
Post subject:  Re: Need help with encoder programming. Badly

Why do you reset the motor encoders in your while loop?

= Xander

Author:  Coder A [ Tue Feb 26, 2013 3:12 pm ]
Post subject:  Re: Need help with encoder programming. Badly

If you want to keep your loop the way it is, take the current commands out of it and place them right after it. That will also work.

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