View unanswered posts | View active topics It is currently Tue Jul 29, 2014 1:02 pm






Reply to topic  [ 5 posts ] 
Motor Encoders 
Author Message
Rookie

Joined: Thu May 03, 2012 2:55 pm
Posts: 2
Post Motor Encoders
OK I'm trying to learn how to use the motor encoders but everything i have tried has failed.

Can someone tell me how to program them cause everything i try the motor doesn't move at all or it will just keep going and never stop.

even a link would help, but an expert would really be great.

any tips would be helpful.
thanks :)


Thu May 03, 2012 5:19 pm
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Motor Encoders
What do you want to do with them? Can you post some of the code you've tried? Are you using the latest version of RobotC (3.08) and the latest firmware (9.12)?

P.S. Notice my rank (beneath the username) :mrgreen:

_________________
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.


Thu May 03, 2012 5:30 pm
Profile WWW
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: Motor Encoders
You need to give us more information. What platform are you using? Mindstorms or Vex? If you've tried code post it here as NeXTGeneration suggested. Take a look at the tutorials provided.
VEX: http://www.robotc.net/education/curriculum/vex/
Mindstorms: http://www.robotc.net/education/curriculum/nxt/

_________________
sudo rm -rf /


Thu May 03, 2012 7:32 pm
Profile
Rookie

Joined: Thu May 03, 2012 2:55 pm
Posts: 2
Post Re: Motor Encoders
i am using mindstorms

Code:
task main()
{

nMotorEncoder[motorD] = 0;  // Reset encoder
nMotorEncoderTarget[motorD] =1440; // Sets target to one full rotation

while(nMotorRunState[motorD] < 1440)
  {
    motor[motorD] = 75;
  // Wait until encoder value is reached.
}
motor[motorD] = 0;
}



from what i have read this should only be 1 rotation of the motor but it just goes and doesnt stop


Fri May 04, 2012 10:25 am
Profile
Senior Roboticist
User avatar

Joined: Wed Sep 28, 2011 10:13 pm
Posts: 630
Location: If I told you, I'd have to kill you.
Post Re: Motor Encoders
It looks to me like your using the Hi-Technic motor controller, right? I've no experience with this, but I think that the same rules that apply to MindStorms motors apply to these.

Try this code:
Code:
task main()
{
   nMotorEncoder[motorD] = 0;  // Reset encoder
   nMotorEncoderTarget[motorD] =1440; // Sets target to one full rotation

   while(nMotorRunState[motorD] != runStateIdle)
   {
      motor[motorD] = 75;
      // Wait until encoder value is reached.
   }
  motor[motorD] = 0;
}


And this:

Code:
task main()
{
   nMotorEncoder[motorD] = 0;  // Reset encoder

   while(nMotorEncoder[motorD] <= 1440)
   {
      motor[motorD] = 75;
      // Wait until encoder value is reached.
   }
  motor[motorD] = 0;
}


You see, the problem with your original code is that the nMotorRunState[] doesn't use a number as a condition. If you want to use a number, then just read the encoder value like in my second sample. If you use nMotorRunState[], then wait for it to be equal to runStateIdle.

Do either of these work?

_________________
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.


Fri May 04, 2012 10:41 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 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.