homing and Limits in Linear System with Quadratic Optical Encoder

Hi all,
I require your help to find the solution on the next project.
It that has a quadrature optical encoder mounted on a stepper motor that carries an object connected to a toothed band in a one axis system
The need is as follows: When the arduino is turned on, a stepper motor controlled with an a4988 moves a toothed band which carries an object until that object encounters something in its path causing the motor to be unable to continue to rotate and the encoder does not show any change on a period of time. At that time you have one of the limits of the distance to be traveled in the future. From that point the stepper motor starts to turn in the opposite direction and the pings of the encoder must be counted, until the same happens at the other end, the engine brakes and there´s no change on the encoder for a period of time.
That way we know the distance limits that the object will be able to move and maybe subtract a ping or two at each end so that the displaced object does not physically touches that limit again and stop a ping before in any subsequent movement.
I think this way you can know the limits in a linear system no matter where our initial position is and most importantly without using limit switches, which for my taste are a thing of the past since we should be able to control the location of a system with an Encoder and some programming.
I´ll wait for your comments and hope that you can help me with the code.
Best regards.
i leave a picture example attached

most importantly without using limit switches, which for my taste are a thing of the past since we should be able to control the location of a system with an Encoder and some programming.

Well deliberately crashing a stepping motor into the end stops on each power up is not exactly good engineering. Some form of limit sensor is essential but it does not have to be a switch. A single opto interrupter, hall switch and magnet or capacitave sensor are all good options, and a lot simpler than an optical encoder.

You only need one end detector, as the limits of travel will not change.

Grumpy_Mike:
Well deliberately crashing a stepping motor into the end stops on each power up is not exactly good engineering.

It´s not like crashing exactly, since it will be a very slow speed when detecting limits. And the main problem about using other sensors is that i can´t attach any sensor to the moving object, this is why it has to be determined by the encoder.

Not sure if i explained all the process correctly. Let me know if you need more details.

i can´t attach any sensor to the moving object, this is why it has to be determined by the encoder.

You can put a spot of white typing corrector fluid on the belt and have a photo reflective sensor pick it up.

Not sure if i explained all the process correctly.

Yes you did thanks.

Slow or not it is still going to exert a mechanical strain on the motor and stretch the belt. In fact the belt will stretch and give the illusion that the end has not been reached when it has. Only when the stretch is sufficient to hold back the motor will you get your required information. This I consider a bad design.

1/ You disparage mechanical swirches, but microswitches are very repeatable and still widely used. Your mouse will have several.

2/ If you put steps into your motor and the encoder doesn't move, you know the belt has stopped. But note Grumpy_Mike's comments on the advisability of such an approach

Allan.

I've used the white dot/opto approach successfully.
Also possible to use hall-effect sensor and a moving magnet or vane.
Both could use an opaque part of your existing mechanism.
Choice comes down to the operating environment.