# Sensors for differential drive

I have the following chassis along with an Arduino and a motor shield.

I'm in the process of developing a tracking mechanism for use with differential drive.

Normally, a photo reflector can be placed adjacent to the wheel that will reflect when each spoke passes through therefore allowing code to be written that will accurately measure each wheels position.

The problem I have is that you cannot see the wheels from inside the chassis, only small holes for the driveshaft. Placing sensors on the outside would look ridiculous and a wall crash would cause havoc.

Would I be able to use a photo reflector on the gears (as shown) if I accurately placed it to count each spoke on the gear itself? I'm a bit hesitant though because even a small bump could misalign the sensor - again causing havoc.

So does any one have an idea on how to track the wheel movements?

• Is the goal of the tracking to determine how far you've travelled, or something more simple like making sure both motors turn at the same rate? – Ian Jan 30 '13 at 15:13
• Is there anywhere inside, that can measure the rotation of the gear wheels? – Andrew Jan 30 '13 at 16:43
• @Ian, it's to measure distance, direction and use it for autonomous driving. – Marko Jan 30 '13 at 19:40
• @Andrew there is room but not a whole lot. I'm now looking at this option as well. Basically I could put a sticker like on this link and measure that? letsmakerobots.com/node/24031 – Marko Jan 30 '13 at 19:42
• If you want to go the hack it yourself route, the first part of my answer to Building a controllable “knob” might be of use. – Mark Booth Jan 30 '13 at 20:21

I put together encoders for this exact chassis. Rather than reflecting ones, I used slot ones. I thought I could work off the hole in the white gear, but it turns out the plastic is pretty transparent to IR, so I ended up using some black electical tape (high tech, I know) to make opaque regions on the gear.

After building two encoders, I discovered there's a similar product online: LightBeam OptoInterrupter Module

For my first robot, I’m just using a rough encoder, with 4 counts per wheel revolution. Here's my description from my blog:

In looking in the chassis, there’s not a lot of room. As a result, I decided I’d use a small transmissive sensor, rather than a reflective sensor. Both have an IR emitter and an IR photo detector. For reflective units, they both face the same direction, and the detector measure IR reflected back to the sensor. For a transmissive or interrupt sensor, the two units are separated by a gap, and the detector picks up IR passing through the gap. So far, so good.

I ended up using Vishay transmissive optical sensors (model TCST1202) I purchased from DigiKey. I wired them up based on the circuit posted by Aniss1001 in the “Homemade wheel encoder“ thread on the Arduino forum.

I built the circuit on a prototyping breadboard for testing and got a surprise. The circuit worked fine, but the gear is transparent to IR! It turns out that nylon and most plastics used for inexpensive gears are pretty transparent to IR. I first tried creating an opaque section with a black marker, but while that worked on paper, it didn’t adhere well enough to the gear. I ended up using a piece of black tape. Once that worked, I cut some small circuit boards down to size and built the encoders, practicing my soldering skills.

I just used hot glue to mount the encoders. The encoder boards stick up above the chassis base, so I’m using standoffs to raise the plastic plate with the Romeo controller and other devices. Here’s a picture of one of the encoders before mounting,, and then mounted on the chassis:

Hope this helps!

• This definitely helps. Can't wait to finish work and go build it!! Accepting this, thank you so much! – Marko Jan 30 '13 at 22:42
• Just to confirm, because the gears are transparent, the IR light is able to pass through the white portion of the printed graphic but not the black? – Marko Jan 30 '13 at 23:13
• In my case, I didn't use a printed graphic but pieces of black tape, leaving only the white gear on the rest. Paper, depending on it's nature and thickness, will block some of the IR even if white (the encoder wheel patterns you've seen are for reflective sensors like you were originally thinking of). I don't know if a single layer of white paper (plus whatever adhesive you used) would block most of the IR. I played it safe by cutting strips of tape. – ViennaMike Jan 31 '13 at 0:35
• OK that I can test - just confirming that the IR signal DOES go through the gears and is picked up by the receiver. Even if I do print it out I could always cut the white portion out to make sure the signal goes through. – Marko Jan 31 '13 at 0:39
• Sorry for the confusion - I thought you were using one of these sensors but I've just checked the linked product and it seems that it's different. I was looking at this – Marko Jan 31 '13 at 2:00

Typically, tracking the position and orientation of a vehicle is not accomplished by looking at the wheels — it's done with navigation sensors. If you were attempting to have closed-loop control (i.e. servo control) of your motors then wheel-mounted position sensors might be appropriate. But if the goal is to support "autonomous driving", then I don't think position sensors will suffice.

Put simply, any non-flat terrain or slippage of the tracks would ruin your accuracy.

Instead, I would suggest one or more of the following navigation sensors:

• Compass
• GPS
• Acoustic or laser rangefinder
• Acoustic beacons and triangulation
• The bot will definitely have GPS at some stage but I am first looking at a simple means of navigating the bot and controlling direction using input from the encoders. If I can somehow use a Compass to do error detection and correction along with the GPS data then that would be the optimal solution. But I think encoders are a good 'starting point'. +1 – Marko Jan 30 '13 at 21:43
• I think "navigation" is a strong word for what you are attempting. Maybe "maneuvering" would be a better word, because you'll only be able to make rough estimates on your movements. To put it another way (by analogy): if navigation was illustration, then what you'll be able to do is blind contour drawing -- reminiscent, but not accurate. – Ian Feb 1 '13 at 16:12

One alternative to sensing the wheel movement is to actually track the vehicle movement over ground. I know that some people have done it using optical mouse sensors. The results will depend on the type of underground you are expecting. The upside is however that you track the actual vehicle movement, which is what you are really interested in.

• Nice idea @Jakob but the robot will be going over all sorts of terrain so an optical mouse sensor wouldn't work :( – Marko Jan 30 '13 at 8:31
• It's a shame the linked to board has been retired from the sparkfun catalog (and elsewhere too after a quick search). – Mark Booth Jan 30 '13 at 20:36

Are the wheels essentially hollow except for the spokes? If they were, it would seem to me like adding a small hole a little offset from the front axle (the wheel without gears) would be a good place to put a light detector. Of course that would not work too well in the dark.

Each spoke, or more properly tooth on the gear, while technically would be correct, as you indicated may be hard to accomplish due to size.

Does the non-gear wheels axle come into the chassis? Could you add an optical encoder there? Possibly by making the axle fixed to the wheel but pass through some sort of bearing.

I've never experimented with odometry with tracks, but I assume due to their increased slippage, you will have to deal with greater errors than plain wheels during turns. Have you considered that?

In any case, I think you are going to have to do some 'customization' to get what you want.

I could not find that chassis at Pololu. Is it an older model?

Ah I see now where it has been replaced. The newer chassis has encoders as an option.

• thanks for your elaborate answer. I haven't really given much thought to the slippage issue and am only starting out with robotics/electronics so I picked up this chassy from a local electronics store. The axle from the back wheels does come through so I could potentially add a closely spaced propeller? along with an IR photo reflector. Not entirely confident it would work but it may be worth a try. Another alternative I just thought of, can you see the small screw hole on the top RHS bumper? Would putting an IR sensor pointed at the tracks be able to pick up the treads? – Marko Jan 30 '13 at 7:15
• You want to add something like this, but there must be a less expensive version some where. – Spiked3 Jan 30 '13 at 17:30
• Pointing an IR sensor might work, but it would take some programming (and processor time) to accomplish. How much of the track motion is vibration versus movement? The programming would be much easier if you placed a hole that the track teeth alternately covered up then exposed, and detected just light through that hole. You still have to program some, but I would think it would be much less complicated. It is not going to be as accurate as a purpose built encoder, but should be ok for just learning. – Spiked3 Jan 30 '13 at 17:38
• I always plug LEGO when I can. LEGO Mindstorms are perfect for this kind of thing, and are \$250. Now that a new version has been announced for mid-year, probably less then \$250. Their motors include encoders. – Spiked3 Jan 30 '13 at 17:39