Cheap, easy DIY optical encoder (Attiny + 3D printing)
Looking for a way to make yourself a very simple encoder? Well look no further because here is a tutorial for one!
BEFORE YOU BEGIN
Attiny reads analog data from IR receiver and counts how many ticks have passed. It then outputs the count number in two-bit binary, which you can then read with another micro controller.
1.) If your main micro controller is to slow to count every encoder tick and run the main program at the same time, this is a perfect solution. The Attiny part in this case actually represents a buffer for encoder ticks.
2.) If you don’t want to use the whole Arduino for counting Encoder ticks, this is a much cheaper solution!
As usual, cheap and high quality are two things that don’t usually exist together.
The highest quality I tried was 40 steps per rotation. It could probably also work for higher number, but I would rather buy one for much higher resolution. This encoder is NOT incremental, it simply counts ticks on one channel, because sometimes that is all what I need.
Note also that this encoder will NOT work well with (paper) printed encoder wheels. I 3D print them or make them from aluminium foil. (Picture at the end of tutorial)
– Attiny 85
– 8 leg chip socket (for attiny)
– IR LED (5mm)
– IR transistor reciever (3mm)
– 3D printed parts
– 10k and 1k resistors
If you are doing this for the first time, I suggest making a circuit on a protoboard like this and test it.
The picture above may also serve as a guide on how to solder the components when making a sensor.
IMPORTANT: Not all IR receiver transistors have the same polarity. Testing the circuit on protoboard, before soldering, will result in lower frustration and less headaches!
And finally a video on how to assemble it!
Obviously you can solder it, so the whole thing looks better as in the video.
Again, this sensor does NOT work the best with printed encoder wheels, so you will have to 3D print one with wholes or make it from aluminium foil as on the picture below. Both ways produce good results.
I used this encoder with a project Robert and it was pretty reliable, but I would’t bet my life on it…