View unanswered posts | View active topics It is currently Sat Aug 30, 2014 10:30 am






Reply to topic  [ 7 posts ] 
Need help with encoder programming. Badly 
Author Message
Rookie

Joined: Wed Feb 06, 2013 6:39 pm
Posts: 6
Post 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


Tue Feb 26, 2013 12:00 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3199
Location: Rotterdam, The Netherlands
Post 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

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Tue Feb 26, 2013 12:07 pm
Profile WWW
Rookie

Joined: Wed Feb 06, 2013 6:39 pm
Posts: 6
Post 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)


Tue Feb 26, 2013 12:17 pm
Profile
Moderator
Moderator

Joined: Thu Jan 03, 2013 5:10 pm
Posts: 198
Location: The plateau north of the Ohio River Valley, also known as Cave Country.
Post 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.

_________________
I'm not a robot! I'm british! ~ quote from an asparagus
I am not a robot! I am a unicorn! ~ quote from a robot


Tue Feb 26, 2013 12:45 pm
Profile
Rookie

Joined: Wed Feb 06, 2013 6:39 pm
Posts: 6
Post 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 !=


Tue Feb 26, 2013 12:50 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3199
Location: Rotterdam, The Netherlands
Post Re: Need help with encoder programming. Badly
Why do you reset the motor encoders in your while loop?

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Tue Feb 26, 2013 1:12 pm
Profile WWW
Moderator
Moderator

Joined: Thu Jan 03, 2013 5:10 pm
Posts: 198
Location: The plateau north of the Ohio River Valley, also known as Cave Country.
Post 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.

_________________
I'm not a robot! I'm british! ~ quote from an asparagus
I am not a robot! I am a unicorn! ~ quote from a robot


Tue Feb 26, 2013 3:12 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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.