View unanswered posts | View active topics It is currently Thu Jul 31, 2014 4:11 am






Reply to topic  [ 4 posts ] 
Encoders are Inaccurate? 
Author Message
Rookie

Joined: Sun Feb 27, 2011 3:41 pm
Posts: 20
Post Encoders are Inaccurate?
Hello guys,

It is my first time posting in this forum. I am from FTC Team Unlimited 0001. We were wondering if it is just us who has trouble with the DC Motor Encoders. Whenever we make an autonomous and finish, our encoder always acts up the next time and we need to tweak it a little again (by like 3 inches). Is there a way to get super accurate readings each time? Here's how i do it...
Code:


float convert(float inches)
{
  //In this part, you convert the inches to encoder rotations and you return that value//
  return (inches* 140);
}

//You can use this function to move the robot a set amount of inches with a set speed//
void goInches(float inches, int speed)
{
  //reset the encoders...
  nMotorEncoder[RightDrive] = 0;
  //start up the motors...
  motor[LeftDrive] = speed;
  motor[RightDrive] = speed;
  //you go move until you reach the desired amount of encoder counts...
  while (abs(nMotorEncoder[RightDrive]) < (convert(inches)) || abs(nMotorEncoder[LeftDrive]) < (convert(inches))){ }
  //You stop the motors after the while loop...
  motor[LeftDrive] = 0;
  motor[RightDrive] = 0;
  wait1Msec (1000);
}


Now, we are using two encoders and it is still being bad. Before we also tried with one encoder.


Sun Feb 27, 2011 3:46 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Encoders are Inaccurate?
rkrishnan2012 wrote:
our encoder always acts up the next time and we need to tweak it a little again (by like 3 inches).

Don't know what you meant by acting up and have to tweak it again, but your algorithm is not accurate to start with. First, you only reset the right encoder at the beginning, but you did not reset the left one. Secondly, even if you applied equal power to both wheels, the wheels are not running at the same rate, so your robot will probably not going straight and will most likely overshoot because you won't stop until both encoders traveled at least x inches. You may consider using some of the RobotC bult-in facilities such as Sync the wheels or even PID control drive. There are many threads about this in this forum. You can search for them.


Sun Feb 27, 2011 11:36 pm
Profile
Rookie

Joined: Wed Feb 18, 2009 4:06 pm
Posts: 12
Post Re: Encoders are Inaccurate?
We have seen the exact same behavior. My own theory is that sometimes it takes a long time for the zeroing of the encoder to take place (I don't have any idea why this should happen?). So if you look at your program, you reset the encoder and immediately start the motors. The encoder may not really reset until the motor has been running for some time.

Insert a delay after reseting the encoder (250 msec?). Also instead of reseting the encoder, you could just read it's current value and use that as the starting reference.

We haven't had time to figuire this out, so I would be curious with regard to your fix.


Mon Feb 28, 2011 6:02 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3165
Location: Rotterdam, The Netherlands
Post Re: Encoders are Inaccurate?
I will often add a 100-200ms delay after resetting the tachos. When they're reset, it's not immediate due to a few internal things that need to be reset as well.

- 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 Mar 01, 2011 2:12 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 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.