Will spinning a small DC motor work effectively as a rotational speed sensor (by producing voltage)?

I'm trying to measure the rotation of a shaft (driven by a trackball) on a shoestring budget. I came up with the idea of using a small DC motor I have on hand to generate a rotational speed based voltage. I came across information on resolvers, however I don't particularly care about the position of the shaft, just the speed and direction.

I'm planning on placing diodes on each terminal of the DC motor to direct the output to 2 different input pins on an ADC (depending on spin direction) and connect the correct terminal to ground.

Depending on the output voltage, I'll also plan on either putting in place a voltage divider or do some zenier diode clipping to prevent voltage spikes.

Is there anything I'm overlooking? It all sounds correct in theory to me, but damnit Jim, I'm a programmer, not an electrical engineer!

I'd rather not fry a microcontroller.

  • \$\begingroup\$ you can indeed measure the back EMF to detect the speed, but you should do some calibration first to work out what speed generates what voltage \$\endgroup\$
    – KyranF
    Commented Jun 19, 2015 at 23:02

2 Answers 2


Well, you can - in principle - but....

Any regular brushed DC motor can be used as a tachometer. The problem is that the tachometer really does work (more or less) like a motor in reverse. So, if the no-load speed of a DC motor is 1000 rpm with 5 volts applied, when used as a tachometer the output voltage will be about 5 volts at 1000 rpm. As you might guess, you're not likely to find a motor which will give you useful output voltages when driven by a trackball. Very low-speed motors usually have a gear train between the motor and the output shaft, and this is essentially impossible to drive backwards.

I'd recommend you make your own optical encoder if you're really on a tight budget. You make a disk out of some thin material (heavy paper might do), punch a bunch if holes around the rim, and attach it to your shaft. Now get a photointerrupter

enter image description here

and set it up to look through the holes. Actually, this is probably the way the trackball works.

If you've got a few bucks, make life easier on yourself and buy a ready-made encoder. Try Digikey for examples of either.

  • \$\begingroup\$ I hadn't thought of the problem that way, re:necessary RPM to produce useful voltage. I'll look into making an optical encoder after some experiments. \$\endgroup\$ Commented Jun 20, 2015 at 0:28
  • \$\begingroup\$ My trackball application is a bit unique in that I'm using a 3" steel bearing (as trackball) rolling on a 1/4" rubberised steel shaft. Going on the basis of needing a high enough RPM, I went and calculated that I'm getting 12 shaft revolutions per 360-degree rotation of the ball. I can do a full rotation of the ball in about 1 second, which gives me 720 RPM. I need to figure how many RPM I get with small ball rotations though. If it doesn't work, I'll go the encoder route. \$\endgroup\$ Commented Jun 20, 2015 at 0:38
  • \$\begingroup\$ What you need to worry about is not how fast you can spin the ball, but how slow you might want to. \$\endgroup\$ Commented Jun 20, 2015 at 0:39
  • \$\begingroup\$ Given the potential for needing to move the ball very slowly, it's looking like an encoder with a large diameter disk is the best option. More interrupts per turn. \$\endgroup\$ Commented Jun 20, 2015 at 0:56

Small stepper motors, like those found in old floppy disk drive for the head movement, are nice encoders. They produce two signals 90 degrees out of phase, which can be easily counted with an up/down counter.

Now both steppers or DC motors needs some torque to rotate, and coupling the trackball to a motor is not simple, and makes the trackball very uncomfortable.

I'd investigate another solution: Take one of those optical mice, tear it apart, and make it 'look' at the trackball. No friction! Those optical mice are very cheap, and are very precise. And no problems with slow speeds. Ideal would be just under the ball, so the movements would be just the inverse of the operators'.

Those optical mice are really a great invention...

  • \$\begingroup\$ +2 for stepper motor and optical mouse idea \$\endgroup\$
    – tomnexus
    Commented Jun 20, 2015 at 5:21
  • \$\begingroup\$ Actually, optical mice (the current standard) don't work that way. Instead, they have a little optical chip which looks at the pad and deduces motion from that. You must be thinking of the old style, which had their disadvantages. Whatever you want to say about optical units, at least you no longer have to worry about cleaning mouse balls. \$\endgroup\$ Commented Jun 20, 2015 at 11:47
  • \$\begingroup\$ I actually have a couple stepper motors on hand. I'll give that a go too. \$\endgroup\$ Commented Jun 22, 2015 at 20:43
  • \$\begingroup\$ @WhatRoughBeast. Yes, I was actually thinking about using one of the current optical mice as a movement detector for a trackball. Should work very well, I'd think. In fact, I believe there are some Logitech trackballs which work optically. The old -mechanical- ones where just a headache (both mechanical trackballs and mice). \$\endgroup\$
    – jcoppens
    Commented Jun 22, 2015 at 22:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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