## convert rotary encoder input to mm

11 posts / 0 new
Author
Message

Hi , Is there a way that I can read the input of TR1 rotary encoder .and convert the represent the data in Milimeters (mm).

`mm = rotary_count * MAGIC_SCALE_FACTOR;`

Since you probably don't have MAGIC_SCALE_FACTOR defined yet, we'll all need more info.

If each detent on the represents X millimeters, then:

`dist = numberOfDetents * X;`

Regards,
Steve A.

The Board helps those that help themselves.

And of course, MAGIC_SCALE_FACTOR depends on the diameter of the wheel and any gearing...
/mike

I bet this is to see how far the wheel has turned by counting encoder pulses. Wheel circumference is pi x diameter. If the encoder has 12 pulses per rev, you can calc the mm per pulse.

Imagecraft compiler user

The easy way?

Move the thing some known distance, say 1 meter and count the pulses. Save this as SF.

Then, for any number of pulses, you can figure the distance in mm by multiplying by 1000 and dividing by SF.

(There's no accumulated error if your scale factor happens not to come out to a reasonable clicks/mm.)

The largest known prime number: 282589933-1

arpit007 wrote:
Hi , Is there a way that I can read the input of TR1 rotary encoder .and convert the represent the data in Milimeters (mm).
The rotary encoder has absolutely no idea what a millimeter is. It only knows that it has rotated some number of increments. The mechanics of what the encoder is connected to is where distance comes into play.

What is rotating along with the encoder? Without knowing this, there is no way to answer your question.

Is it a lead screw? Is it a belt or chain?

If it is a lead screw, what is the pitch?

If it is a belt or chain, what are the specs of the sprocket or pulley and the pitch of the belt or chain?

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away. Antoine de Saint-Exupery (1900 - 1944)

hii

i have a system in which i have to calculate the length in mm from the encoder pulse which is connected to  GEAR BOX  and after gear box there is a chain and that chain is moving a lead screw . so i want to know what are the parameters i need to consider for the length calculation

thank you

Isn't it just simple arithmetic? Think the spokes of a bicycle wheel....

Say the wheel has a diameter of 45cm and has 28 spokes. The 45cm diameter means the Pid circumference is 3.14 x 45 = 141.3 cm and if there are 28 spokes then the passage of one spoke represents 141.3 / 28 = 5.04cm of travel. If there's gearing involved then that will introduce further division/multiplication factor but this is basically just junior school maths.

Has that not all been covered in the preceding posts in this 7 year old thread ?

Top Tips:

1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...

maxsingh wrote:
i have a system in which i have to calculate the length in mm from the encoder pulse which is connected to  GEAR BOX  and after gear box there is a chain and that chain is moving a lead screw . so i want to know what are the parameters i need to consider for the length calculation

Sounds like you need a friend who is a mechanical engineer!

You will need to know for one turn of the gear box input shaft, how far did the lead screw follower move! Be as precise as possible with this measurement as any error will accumulate with each turn.

It may be better to turn the input 1000 turns and take the measurement of distance moved, then divide by 1000.

Good luck.

Jim

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get \$5 free gold/silver https://www.onegold.com/join/713...