I'm facing a weird request. I have to build a sort of "encoder", to detect the direction and the rotation speed of a black/white wheel at 150 mm from my PCB. In the past I did a lot of this things using a couple of IR leds and receivers and worked very well but I was very close to the encoder surface (few mm).

I can draw the wheel as I want. The diameter should be about 200 to 400 mm and I can paint just one half black and one white (or put a more reflective material) to have 2 readings on each complete turn. Better, even if not mandatory to divide it in more sectors to improve accuracy, reading multiple times per turn.

The rotation speed goes from 0 rpm to max 60 rpm, in both directions. A 7-bit resolution, that is 128 steps, it's enough about the speed estimation.

As said before, my idea was to place two IR led/detector on my PCB separated by some distance (i.e. 20 mm). Then I measure the time needed for the "white" part to activate both sensors.

With such a distance this doesn't work due to the angle of the receivers that detect the incoming white section quite at the same time. I tried to put on a tube to reduce the angle, but with no acceptable results.

Any other idea about how to fix this system or propose a different one?


Forgot to say anything about the environment. It's indoor, no direct sunlight. But there are other lights in the nearby that might change colors or even flash. For this reason I tried to use a carrier (the common 38 kHz) to be able to filter out the noises.

For safety constraints I cannot use laser at all.

  • \$\begingroup\$ Any environment variables that might have an effect? Sunlight? \$\endgroup\$
    – Jeroen3
    Oct 27, 2017 at 5:43
  • \$\begingroup\$ At that distance you'll probably have to go for something vision-based. \$\endgroup\$ Oct 27, 2017 at 6:00
  • \$\begingroup\$ Lenses work better than tubes, but they also cost more. \$\endgroup\$
    – gbarry
    Oct 27, 2017 at 6:03
  • \$\begingroup\$ @Jeroen3 you're right, I forgot to mention. I'm updating the question. \$\endgroup\$
    – Mark
    Oct 27, 2017 at 6:50
  • \$\begingroup\$ Putting tubes (as you mentioned) is not a bad approach. I would say, make tubes long enough, so the light is colimated in such a way that can be seen only from the semicircle for each receiver. Spreading the receivers apart may help. Of course, this will increase noise due to the reduced signal. Use additional light source to illuminate the circle. \$\endgroup\$
    – Nazar
    Oct 27, 2017 at 12:29

2 Answers 2


Use two different sets of markings on your disk with two different detectors, one aimed at each set.

The first set is simply a regular pattern of light and dark bands, which give you the rotational speed of the disc by measuring the frequency of the signal from the detector. Put this around the outside of the disc for maximum accuracy and resolution.

Then, closer to the centre, put a pattern of pairs of bands, one of which is, say, twice the width of the other, with a gap between the pairs that is larger than the whole pair. The detector aimed at this pattern will return a shorter pulse followed a longer one if the disc rotates in one direction and the opposite in the other.

With a 400mm disc to play with you ought to be able to get the different detectors far enough apart with relatively simple masking.

With enough processing capability, you may even be able to put the bands closer together and use a well focussed single sensor, then extract both patterns from the signal it picks up.

You may even be able to combine the patterns in this case such that you have maybe ten even bands then a thin one and a thick one. The frequency will be unchanged but a periodic variation will give you the direction. Vehicle engine systems use techniques like this to provide timing and location of Top Dead Centre (though they obviously don't worry about direction).

  • \$\begingroup\$ Interesting solution. When you say "well focused" you're talking about putting on some lenses? \$\endgroup\$
    – Mark
    Oct 27, 2017 at 16:21
  • 1
    \$\begingroup\$ Not necessarily, I'd try just a tube to start with and see how it goes. Put a bright LED in the tube first and it'll give you an idea of the area it's looking at. \$\endgroup\$
    – Finbarr
    Oct 28, 2017 at 17:11

You can do much better optically - if you have to reject a little lot of variable room lighting it gets more difficult.

In rough order of difficulty..

  • tinted filter on receiver (in a tube) and monochromatic light source

  • retro-reflective surface

  • laser light source creating a bright area on the disk (you can make it a bit out of focus is if it has a collimating lens

  • lens on receiver as well as filter, roughly focused on disk where light source hits (maybe a pocket telescope)

  • high frequency modulation of the light source and synchronous demodulation

At 150mm you might try the first three to start with.

You have the option to measure frequency or period and calculate frequency (which is proportional to RPM).

  • \$\begingroup\$ Good hints. Unfortunately I cannot use lasers. I didn't think about filter (my receiver has a notable sensitivity between 880 and 1050 nm) but I would give it a try. \$\endgroup\$
    – Mark
    Oct 27, 2017 at 7:13
  • 1
    \$\begingroup\$ @Mark The advantage of lasers is a parallel beam of specific wavelength, it does not need to be in visible range, nor does it need to be very powerful with the correct receiver filters. \$\endgroup\$
    – Jeroen3
    Oct 27, 2017 at 9:35
  • 1
    \$\begingroup\$ Class 1 lasers (eg. modules) are safe and if you use a red laser module, being visible. you can tell where the beam is going. I don't think you need a Class 4 metal-cutting laser. eg. this \$\endgroup\$ Oct 27, 2017 at 10:25
  • \$\begingroup\$ I understand, but this is a constraint I cannot change. No matter how safe the laser could really be. \$\endgroup\$
    – Mark
    Oct 27, 2017 at 15:06

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.