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.
The toothed rack distance may change from use cases
The Arduino must run the full track when initializing to measure the distance
In each end a STOP contact will be activated
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?
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.