Arduino and measure distance (stepper)

Hi,

I'm a newbie to Arduino, but an interesting project came up and now I try to accomplish.

I need a way to measure the distance of a guided track - say I have a aluminum track with a toothed rack and the following facts is included.

  1. The toothed rack distance may change from use cases
  2. The Arduino must run the full track when initializing to measure the distance
  3. In each end a STOP contact will be activated
  4. The distance must be used for calculation in the next process of the code

My idea was to apply a stepper with a toothed wheel where I know the circumference - and then count the turns. But then I end up with a maybe not finished turn in the end, and what then?

So the short question - how do i measure i distance mechanical and not with ultrasound etc.?
And how do I use the calculation in the code for further processing?

Thanks in advance.

// Kristian

A stepper motor will usually divide down a single rotation into 200 steps so would 1.8 degrees still be to much margin of error?

Rotary encoder on track wheel will also work.

@Riva: That could be a possible solution. Can you explain more about, how I count the steps then in the code?

@Raschemmel: Please explain more. :slight_smile:

Thanks.

HyperGeil:
That could be a possible solution. Can you explain more about, how I count the steps then in the code?

The code would need to generate stepping pulses for a stepper motor (see here) so a simple answer would be to count the total number of steps you generate between start/end points. If you know one revolution moves the track say 500mm then each step must be moving it 2.5mm (500/200). You could also use gearing to increase the stepper torque and it's accuracy. To be precise about the job you should also have some form of feedback like a continuous rotation potentiometer or shaft encoder so you know the stepper did move the track and did not slip or stall.

@Raschemmel: Please explain more. smiley

https://www.google.com/search?q=rotary+shaft+encoder&rlz=1C1GPCK_enUS504US504&espv=210&es_sm=93&tbm=isch&tbo=u&source=univ&sa=X&ei=dYwoU_O7GYv0oAT1h4HoBw&ved=0CGMQsAQ&biw=799&bih=451