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 motorsWhat'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

magicode

Moderator

Joined: Tue Sep 14, 2010 9:19 pmPosts: 496

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

gus

Rookie

Joined: Mon Feb 06, 2012 5:32 pmPosts: 6

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

magicode

Moderator

Joined: Tue Sep 14, 2010 9:19 pmPosts: 496

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

ronmcrae

Rookie

Joined: Wed Jul 21, 2010 11:23 pmPosts: 39

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.

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum