DIY optical rotary encoder for geared motors

Posted: January 18, 2011 in Electronics, Tutorials
Tags: , , , ,

One of the most important things in robotics is to accurately sense and control the rotation of a motor. One way to do this is to use stepper motors but they’re bulky, have very less torque and speed. Another is to buy a motor with quad encoders which work on the basis of hall effect, they give a very high resolution of about 10000-20000 counts/rotation but they’re very expensive. In this tutorial I’m going to show you how to build a very simple attachment to any geared motor to measure the angular rotation. This is my first video tutorial, so feedback is appreciated.

Things you’ll need:
1. Geared motor.
2. IR LED and detector
3. Aluminum strips
4. Super glue
5. Drilling machine with 5.5mm drill bit
6. Electronic components(refer circuit)

Its very difficult to make anything stick on the back end of the shaft since its only a few mm long, thats why I decided to extend it using solder to give the disc a better grip. The reason I took out the armature is because I couldn’t file it properly and it almost melted the plastic casing when I was soldering but if you’re careful you might not need to remove it. The encoder disc is just a piece of paper with alternate quadrants of a circle printed with white and black. You can use any image editing software to make the design and take a print out.

Circuit –

You can try to build the circuit without the transistor, I’d built two encoders, one of them worked without it but the other did not, so test it and see if it works for you.

I’ve built encoders before and I usually mounted them on the bot itself and i put the encoder disc on the wheel itself so I used to get a very low resolution, and another problem with that was they would misalign within a few hours, so I decided to build a sturdier one, hence the aluminum strips. After you superglue everything, measure the voltage difference between black and white and bend the aluminum strips till you get a difference of atleast 2V and if you have a glue gun, glue the two strips together so that they can’t move. This way you’ll have a very sturdy encoder and you’ll never have to calibrate it again. Set the potentiometer to a voltage mid-way between the lowest and highest voltage measured.

Calculation of angular resolution –
On the CRO I got a frequency of 430Hz. In one time period there are two transitions, so that’s two counts every cycle. That means it gives out 860 pulses every second, and if you have a geared motor of 120rpm, that’s two rotations per second. So that gives you a count of 430 per rotation which is way more than a stepper motor and you can easily double it by dividing the circle into 8 parts.
So every count gives you an angle of 360/430 = 0.8372 degrees.

You can now give the output to a microcontroller and control the rotation of the motor very accurately.

Hope you enjoyed the tutorial. If you have any questions or comments, please leave them below.

Comments
  1. Niranjan says:

    Awesome!!I liked the concept !! Keep going!!

  2. Mark says:

    What resistors did you use for R2, R3? Love the tutorial, exactly what I was looking for!

    • amithmv says:

      Thanks. R3 was 47K and R2 depends on the IR detector you use, it can be anywhere from 10K to 30M, you’ll just have to see what value gives the best result.

  3. kartikms says:

    Nice post. Found it very useful, as I am currently working on an optical encoder with (2^20) counts per revolution 🙂 Nice to know the fundamental concept behind it.

  4. i saw a Oscilloscope, do you have your own?

  5. st says:

    I didnt find 47k for R3.what resistor can i use?

  6. Jon says:

    Can you provide a parts list for the circuit? It’d be awesome to be able to just put the list into digikey and get what we need for it!

  7. antonio says:

    I like your work,yor explainations are simple.

  8. devraj says:

    i am trying to build this project. i need to use microcontroller for measuring the speed. Can u please guide me how to interface it to get the result on lcd display.

  9. John says:

    Flemingetq Says:

    Great project. I have build a a pole pole DC motor. Machined all post for armature ect. I am also in need of making and optical encoder to measure the RPM’s of the motor and display on a LCD screen youing Ardunio programming. And ideas would be great.

  10. Osama says:

    Hi amithmv thank you for this tutorial
    if you please i need the final circuit for this project and components , and how connected please i need quickly
    this is my email if you want send the circuit : spook2012@gmail.com
    and thank you once more

  11. jose l says:

    then I recommend putting the disc (white and black) in the engine instead of the rim

  12. nishant says:

    how is one supposed to write code for it? any suggestions?

  13. Kishore Garapati says:

    Thanks for the great tutorial….. Nice concept and nice explanation

  14. […] This blog post describes an optical resistor quadrature encoder. […]

  15. can you also show the circuit that u have made on the breadboard?

  16. please mail the circuit of breadboard on raheenkhalid10@gmail.com at your earilest convience. thankyou.

Leave a comment