Motor using Encoder as Limit Switch?

So our team wants to use an encoder as a limit switch. Meaning we want to stop a motor from going so far forward, and prevent from going too far backward while still being able to move anywhere in between. The issue is that none of our programmers have enough experience with using encoders nor the know how to make them function as limit switches. Any suggestions on how to do this?


I probably wouldn’t do that if it’s a critical mechanical stop involving multiple revolutions.

An incremental encoder will tell you how far you’ve moved, but it won’t know where the device was when it started.
An absolute encoder will tell you where in a single rotation you are, but for multiple rotation devices it also won’t know where it started.

Both of them forget where they are when the robot is turned off.

A true limit switch is really absolute. It knows exactly where the mechanical thingy is when a mechanical limit switch is engaged.

When you read an encoder, you get a value that represents how far it has turned. You can use that value to enforce minimum and maximum travel on your motor. When the encoder is above a certain value, don’t let the motor travel any farther forward. When it’s below a certain value, don’t let the motor travel any farther backward.

But if you don’t guarantee that you’re always starting up the robot with the motor in the same position, the encoder value won’t always represent a consistent position.

Thanks for the input Mark and Alan. The mechanism it is on is a table that can be elevated by a motor for the shooter. We have limit-switches in place, but a couple of our mentors would feel more comfortable with having an encoder control the max and min movement.

A better sensor for that would be a potentiometer, 10-turn maybe, but geared to match the full range of travel desired.
A pot gives you an absolute position.

I’ll bring that up tomorrow and see if I can sell them on the idea of that.

Thank you.

Mechanical switched that detect the min and max position will be far better of a solution. Just position the switch such that…

  1. It does not get damaged if the motor exceeds its position (e.g., to the side, not ‘blocking’ thr path)

  2. Put hard stops so that if it does exceed the limits, it won’t break, but stop.

In fact, no matter the method, #2 is always a good idea.