Limit Switch vs Rotary Encoder

I have a DC motor which rotates between position A and position B. These positions define the complete range over which the motor will rotate over. In general, these positions are more than one full revolution apart.

Similar to a power window (but for rotary motion i.e. not linear), I need a way of rotating and stopping the motor when it reaches either position A or position B. I also need to know at which position the motor is in i.e. whether it is at A or B.

One idea I had was that given I know position A and position B initially, I can use an multi-turn incremental shaft encoder, using either position as an index/origin and measure the number of turns/distance between the two. Then, I simply need to rotate the motor between these two positions.

From research, I've found that a limit switch/snap action switch may also be able to do the job. I haven't been able to find much info on these.

Are limit switches suitable for this and/or is the encoder route less well/better suited to meet the requirements?

• The motor drives some mechanism, no? Maybe it would make more sense to attach limit switches to the mechanism instead of trying to attach them to the motor shaft. If there is no "mechanism," then what is the significance of positions A and B? (E.G., my garage door opener has a motor that turns more than a hundred revolutions between the "open" and "closed" positions. It is stopped by limit switches that are attached to the track in which the door's wheels run.) Commented Oct 30, 2023 at 13:41
• Yes, my use case is similar to a garage door. I've just realised actually that for my use case, I don't have access to the mechanism- the motor shaft is coupled to different mechanisms, where each mechanism generally has to travel a different distance between position A and B. Maybe I need some sort of shaft encoder then? Commented Oct 30, 2023 at 14:08
• Roughly how many revolutions apart are A and B? What sort of resolution is required? Commented Oct 30, 2023 at 14:18
• Max will be around 3 revolutions- if I need an encoder, I'll mount it to the output shaft (low speed, high torque). Resolution can be course i.e. few degrees. Commented Oct 30, 2023 at 14:30