2

I am currently trying to build a line follower robot that is designed to solve maze. This maze has a loop, thus it needs to know distance it already travelling (or at least I assume so, please let me know otherwise).

I am aware of a rotary encoder motor from Polulu (for example) but it's not available in my country and shipping price is too expensive.

So I need to find way around it. Should I use Stepper motor? Is there any other way? Thanks in advance.

  • 3
    @yabbadabba - comments under questions are for seeking clarification about the question. Not for stating that your answer is the best one. People will vote for answers that they think are good, including yours, if they merit such votes. Your comments have been deleted. – Nick Gammon Nov 6 '16 at 20:59
4

You can Use wheel encoders. You can even make your own wheel encoders with general parts like photoTransistor and lasor or led light. you can make your encoder or print it out in paper. The use little math to calculate the distance. It will give you measurement with good level of precision.

Basic principle: enter image description here

enter image description here

more information at

wheel Encoder

another encoder

|improve this answer|||||
  • If the OP make their own hand built encoder then how do they know how accurate it is? – Dat Han Bag Nov 5 '16 at 20:33
  • 2
    @yabbadabba, if the OP makes his own hand built encoder, he will know the number of openings in the wheel. He will be able to count the number of openings and measure the distance that the wheel travels, or simply perform the math of circumference equals pi times the diameter. – fred_dot_u Nov 6 '16 at 14:01
  • @fred_dot_u I think what your saying is likely to be true if he makes it with a CNC machine – Dat Han Bag Nov 6 '16 at 14:02
  • 2
    There's a fellow on YouTube (HomoFaciens) who makes amazing constructions with ordinary tools. His encoder wheel is cut out of sheet metal or cardboard depending on the device he's building. The slots are cut with scissors or metal shears and are mildly irregular, yet provide fractional control of the device. The founding principles of the physics of the encoder wheel care not about the sophistication of the construction. One can turn a bicycle wheel into an encoder, which happens to be how bicycle speedometers work! So many answers, so few characters. – fred_dot_u Nov 6 '16 at 19:46
  • @fred_dot_u " (HomoFaciens) who makes amazing constructions with ordinary tools"- sounds like he's got a rare talent – Dat Han Bag Nov 6 '16 at 21:59
1

You could add a rotary encoder to a motor yourself. Thought this is not as convenient as buying an all in one solution.

You can even build your own by making a disk with holes at regular intervals, and using an IR led, phototransistor pair on either side of the disk. You can even get all in one photo-interruptors. You could get them from an old computer-mouse. You might even be able to use the wheel/disk in it.

Another option is to add a magnet to the wheel, and a hall-effect sensor to the body. That way you can count the number of revolutions. (Though you probably want higher resolution than once per revolution).

|improve this answer|||||
  • how do you determine the accuracy of the hand built rotary encoder? – Dat Han Bag Nov 5 '16 at 16:40
  • 4
    @yabbadabba - the ultimate accuracy mostly comes from accurately knowing the distance traveled per revolution of the wheel, for example you can measure over long distances, but you have to worry about slipping and straightness of path. There can also be issues with regularity of spacing and eccentricity of the pattern relative to the shaft (or the wheel itself relative to the axle) but while those are serious concerns in say, a CNC machine tool, with moderate care they will probably not be problematic in a maze robot. – Chris Stratton Nov 5 '16 at 17:20
  • @ChrisStratton "probably not be problematic in a maze robot". Its not clear to me too-if it would definitely be a problem – Dat Han Bag Nov 5 '16 at 20:32
1

An optical encoder would be the best solution in my opinion. The next best thing would be to use a stepper motor. You can find plenty of stepper motors in old printers - which is good if the budget is tight.

The problem with a stepper motor is that you have no feedback on where the motor actually is. You drive it forward say 100 pulses, but without any feedback you have no idea if there was any slip or overrun. This is called open loop control.

However, both of these methods are measuring/driving the rotation of the motor. What happens if the wheel doesn't have enough grip and slips and does a sort of burnout. For this reason, I have seen some maze robots use an old mouse to measure the distance the robot has actually travelled. This was not necessarily very accurate over long distances but was a cheap way of measuring distance travelled.

|improve this answer|||||
  • If they go down the route of interfacing to USB mouse directly to ATMEGA then they need a USB host solution- this has already been done (mainly in software)-see courses.cit.cornell.edu/ee476/FinalProjects/s2007/… – Dat Han Bag Nov 6 '16 at 13:09
  • An old PS2 mouse is easier to interface to Arduino. There is documentation and library at playground.arduino.cc/ComponentLib/Ps2mouse – sa_leinad Nov 6 '16 at 15:19
  • Obviously that depends on if OP has ps2 mouse , USB mouse is more common. For the USB related link I gave the hardware part I would say are easier to get. – Dat Han Bag Nov 6 '16 at 15:34
  • 1
    @sa_leinad, your suggestion is sound. The type of mouse is not as important if one is willing to dissect to a board level. I've dissected a mouse to use the spoked wheel inside which has a properly aligned optical trigger pair, along with the plastic structure to keep things in place. Counting pulses and direction over a known course, with the appropriate math would serve as a useful distance measuring device. Discarded printers also contain linear and rotary encoders with opto-pairs, but harder to use in a robot! – fred_dot_u Nov 6 '16 at 23:28
  • 1
    @sa_leinad, the funny thing about your reply to my comment was that I was referring to the mouse wheel and was ambiguous in my description. I have three mouse wheels harvested with the circuit board and mouse housing. By keeping the parts together, it allows easy access for wiring and mechanical placement too. The unwanted portions can be cut free, reducing the size of the bundle to be installed, while the solder pads on the circuit boards facilitate the wiring. Your link is very supportive of the OP's purpose. – fred_dot_u Nov 7 '16 at 13:50
-4

SInce you mention cost is an issue. The cheapest way to do it is simply to track how much time the motor (which can be done by using arduino timer libraries)-is running for backwards or fowards in some direction. Given you know the speed of the robot it then using the formula

velocity=(distince in some direction from 2D vector)/(time motor is running for in that direction)

from which distance can be deduced. This assumes there is low error bound in this formula-and the velocity is constant-and the robot never leaves the flat floor--and so its accuracy would depend on the specifics of the question- Using a stepper motor would very much increase the accuracy-if it has enough steps then the error would be non-significant- using that formula. You may need to store-a non solved-internal map of the maze in an arduino sketch (for determining the direction and so on). You can use the same answer above for variable velocity given you know when the times of velocity change. would make if you give me more info I can give more of an answer.

|improve this answer|||||
  • 3
    Time based methods are extremely unreliable under load and with changes in battery level. Steppers are generally avoided in portable systems (especially for motive power) as they are heavy and need high drive voltages for good performance; with today's electronics and in an application not highly sensitive to backlash it is unclear that the historic simplicity advantage over closed loop encoder feedback still remains. – Chris Stratton Nov 5 '16 at 17:23
  • @ChrisStratton Actually time based methods are used in physics calculation everywhere. If they didnt know physics or the programming this would be a good opportunity to learn some new things like that. I know I didnt give a commonest answer-but I think it less boring for the OP instead of copying something. I was aware of what you point out which is why I added in a list of assumptions-I knew there were more but didnt have time to type them. – Dat Han Bag Nov 5 '16 at 20:24
  • @ChrisStratton Im thinking just about the cost-OP said he would maybe buy a stepper-so I consider that no cost. If the answer is a good answer for the OP-only they know that. The size of the stepper depends on the robot- how big it is. For the battery you would need a voltage regulator circuit and perhaps more code regarding computing the distance which involve the battery (e.g. dont computer after battery is used too much and so on). Battery life of course depends on chemistry. – Dat Han Bag Nov 5 '16 at 20:24
  • @ChrisStratton My answer was just a basic answer which the OP may tweak so its suits their exact problem-using time based methods is a valid answer -how accurate the idea can be depends on the implementation by the OP-the exact details which are not given. Maybe they could add a little feedback from a sensor to make it more accurate for example. – Dat Han Bag Nov 5 '16 at 20:24
  • 4
    Please don't post under the question that your answer is the best one. The way Stack Exchange works is that other users make that decision for themselves by voting for you. Of course, the answer with the most votes is not necessarily the best one for every user. Readers can evaluate each answer on its merits. – Nick Gammon Nov 6 '16 at 5:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.