Rotary Encoder Project Help

I would like to use a rotary encoder to count rotations of a shaft. I have not purchased an encoder, because I would like to find one that would work for my application and would be easy to program with my micro-controller. I already have an arduino uno.

The shaft that is rotating (that I would like to keep track of rotations) will be moving a collar up and down, because the rod is threaded. I have calculated that 1 rotation will be 1/8th of an inch vertically. I would like to display on an LCD screen the amount of vertical distance the collar has traveled. So I would like the rotary encoder to sense (for example) 3 turns clockwise equals 3/8th of an inch on the display. Then if the rod turns the other way I would like it to subtract from the accumulated value.

This is my first experience with arduino and a rotary encoder. So I was wonder if you all would have any advice on the hardware and program ability to perform this project.

I know there is a lot of code already performed out there. However I was wondering if someone could help me with getting started on a specific encoder and code that would work for this application. Any help would be appreciated. Thank you!

How big is the shaft?
Is the end accessible?
You can find "open center" rotary encoders,
http://www.digikey.com/product-search/en/sensors-transducers/encoders/1966131?k=rotary+encoder+open+center&FV=fff4001e%2Cfff80033&mnonly=0&newproducts=0&ColumnSort=0&page=1&quantity=0&ptm=0&fid=0&pageSize=25
I'm not sure how that would mate with shaft, guess it would depend on far down the threads go.

Another option is to mount a magnet on the end of the shaft and use an encoder that senses the magnet turning to detect rotation
http://www.digikey.com/product-search/en/sensors-transducers/encoders/1966131?k=rotary+encoder&pv545=265&FV=fff4001e%2Cfff80033&mnonly=0&newproducts=0&ColumnSort=0&page=1&quantity=0&ptm=0&fid=0&pageSize=25

Or make up your own optical system with an arm (or set of arms) that extends from the shaft whose passing interrupts an optical sensor.

Or a magnet (or set of magnets) on the shaft whose passing triggers a hall sensor.

Am sure there are other options also.

Another magnet solution at this topic:
https://forum.arduino.cc/index.php?topic=393481.msg2708723#msg2708723

Hi,
do not use rotary encoder for this purpose or any other mechanical system. They have very limited life and severe contact bouncing. Go for optical or hall effect sensor. There are optical rotary encoders but they cost a lot, but If you can find an old ball type mouse you'll find everything you need inside for free :wink:

Are you going to control the shaft rotation whit microcontroler or just display the position?

What kind of distance resolution do you want? How fast will your shaft be rotating? Generally speaking, you most likely want the highest pulses per revolution count you can afford.

I would use a flexible shaft coupling to attach it to the shaft. And i would also use a zeroing limit switch to re-zero your count in a known position to reduce your tolerance stacking over time.

I made one for my metal lathe--To track the RPM and position of the spindle. It's really quite simple; a disk with slots milled in the edge which is mounted on the spindle. The slotted edge passes through the gap of an optical slot sensor. The slot sensor (commercially available; I got mine from Sayal) is nothing but an optical isolator with the LED and detector separated by .1" or so to allow the disk to go between them. To get direction information use 2 sensors both detecting the slots but mounted so that first one, then a bit later the other detects the slot. This way you infer direction by which detector first "sees" the slot. The disk itself is a CD disk with the slots milled in the edge and the centre bored out to fit the shaft. A DVD disk won't work because it falls apart when you cut away the edges.

The software is even simpler: Use the modulo function to generate a tick every .1 sec (for example) and count the pulses between ticks then use a bit of arithmetic to calculate RPM. For position, count pulses.

This is the story in a nutshell. The details should not be hard but have to be adapted to your particular system.