View unanswered posts | View active topics It is currently Thu Aug 21, 2014 4:41 am






Reply to topic  [ 5 posts ] 
Two encoder questions 
Author Message
Rookie

Joined: Mon Feb 06, 2012 5:32 pm
Posts: 6
Post Two encoder questions
I am currently in the middle of implementing encoders on our team's robot. I have a few questions, though:
First, how useful are the encoders? Let's say I want our robot to drive straight for 10 feet. What would the differences be between the accuracy/precision of a bot that uses encoders vs. a bot that doesn't?


Second, is it really worth it to use more than one encoder? I noticed that the typical encoder code for running two motors goes something like:
- reset encoder values and set encoder target
- power on both motors
- wait until one of the encoders reaches a certain value
- stop both motors
What's interesting is that really, only one of the encoders is used -- the one that stops first. Doesn't this sort of defeat the purpose of the encoders? Or is it generally accepted that both motors run at nearly the same rate since they are subject to the same conditions?
So, how would our accuracy/precision compare if my team just used an encoder on ONE side, and stopped both motors when that encoder reached the target?


Sun Feb 26, 2012 5:41 pm
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: Two encoder questions
Well, motor speed is very dependent on a variety of variables, including battery power, friction in the mechanics, surface of the field...ect. Simply running the motor for a period of time to get to your destination (usually called dead reckoning) is liable to produce different results each time any of those variables is changed. Encoders let you make sure that the wheels turn the right amount each time. As for whether you want one or two encoders, the code that you mentioned is a very basic technique for using encoders that isn't too accurate. To get more precise results, you can use a feedback loop to vary the motor powers of the individual wheels so that there is minimal straying from a straight path. Two encoders also help you turn more precisely (although a gyroscope might be better for that task).

_________________
sudo rm -rf /


Sun Feb 26, 2012 7:07 pm
Profile
Rookie

Joined: Mon Feb 06, 2012 5:32 pm
Posts: 6
Post Re: Two encoder questions
Thanks! So do you think it would be worth it to implement two encoders instead of one? Of all our autonomous modes, the longest distance we will ever ever drive is about 9 feet, and the most we will turn is about 180º.

If we use two encoders, it sounds like we should definitely use a feedback loop like the one you mentioned. I have been searching and I can't find anything on that, though. Do you have any sample code, or a link to a place that has sample code dealing with that?


Sun Feb 26, 2012 8:49 pm
Profile
Moderator
Moderator
User avatar

Joined: Tue Sep 14, 2010 9:19 pm
Posts: 496
Post Re: Two encoder questions
I don't know your financial situation, or how precise your autonomous needs to be, so I can't comment on if it's "worth it" for you. For information on the feedback loop, look up PID (which stands for Proportional Integral Derivative) on these forums. There is a large volume of threads explaining it already.

_________________
sudo rm -rf /


Sun Feb 26, 2012 8:53 pm
Profile
Rookie

Joined: Wed Jul 21, 2010 11:23 pm
Posts: 39
Post Re: Two encoder questions
Whether two encoders will help you depends on how you plan to use them. If you simply wait for either one to hit the target value, one encoder is likely sufficient. However, running two motors at the same power level doesn't guarantee the robot will drive straight. Mounting an encoder on each drive motor will allow you to use PID control to adjust the power level(s) such that both encoders clock up at the same rate until either or both reach the target value.

All that said, the same effect but with better results can be achieved using one encoder and a Gyro sensor to detect deviance from straight and using that to adjust power levels in an appropriate fashion. The Gyro reading isn't affected by wheel slip on the mat, whereas the motor encoders can't detect that if it happens.


Mon Feb 27, 2012 4:24 pm
Profile
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.