# Motor angle sensing

For my project, I have a DC gear motor spinning but I need it to stop in the same orientation that it started in, I was trying to look at encoders that were connected to the back of the motor but those don’t seem to work for my situation. I was also thinking of using a stepper motor but didn’t know if there was a better/easier option.

Why not?

The vast majority of CNC and 3D machines use step motors, and they have great precision in returning to the same place when commanded to do so.

In your case I recommend using a step motor.

I need a motor encoder that will give back the angle of the motor shaft, and I can’t find any encoder that does that.

Do you have any recommendations to articles or videos that explain how I can set up a stepper motor to return to it’s original position with my Arduino?

You command a movement of "N" steps forward.
To return to the starting point, simply command "N" Steps movement backwards.

See if this tutorial meet your needs.

PS:
This tutorial use arduino Mega, but you can use arduino UNO, Mini, Nano, etc....

1 Like

Look for an absolute angle shaft encoder. They are very expensive.

Most people use much cheaper relative angle encoders, and some way of "homing" or setting the zero position on startup. Then just count encoder pulses to determine how far the shaft has turned since homing.

The exact same problem occurs with stepper motors.

1 Like

I may do this, but I should finish the video first and see if I have any questions.

Say I move the stepper motor from its original angle 500 steps. But I want to get it back to that original angle going in reverse only part of the way, and not 500 steps all the way back. Is there an equation to tell me the least amount of steps It will need to take to get back to that original angle?

Step motors are built to move at defined angles.
The most common is to find engines that need 200 steps to turn.
Then they rotate 1.8° (degrees) per step. 200 * 1.8 = 360°

Using this type of motor, if you turn 500 steps forward, you will make 2 and a half turns, (200 + 200 + 100), so if you go back just 100 steps, the motor will be in the same position as it started.

I hope I was clear in my explanation

1 Like

Yes, but it allows only 330 degrees of shaft rotation, and as an analog device, is not as accurate as a digital shaft encoder.

Hint: when posting links, remove the "?" and everything following, as that is your personal tracking information.

This is all you need to post: https://www.digikey.com/en/products/detail/bourns-inc./3382H-1-103/2080233

2 Likes

Ah so that is the big difference, I did not know the full links had personal tracking info on them, thank you for telling me how to shorten them, I deleted the post.

I must have gotten all caught up thinking about steps and not how they move in degrees, I fully understand now and I will probably use a stepper motor.

Thank you to everyone who helped!

I was thinking, what if I used a DC motor and a Hall effect magnetic sensor? The sensor could sense for a magnet connected to the motor shaft.

How precisely, within one degree, or...? What RPM? Both directions (forward and reverse)? Does it always start at the same position?

Between 1-2 degrees of accuracy would be best. The motor spins at around 200 RPM and then stops to go in reverse at a very slow speed maybe like 50 RPM which is when I will need it to stop on the right orientation. Then it will start the process all over again with spinning for a few seconds at 200 RPM then stopping and going in reverse. This will keep happening for probably 40 times in a row

A magnetic, Hall effect sensor with at least 12 counts per rev, like those commonly found on small gearmotors should work. What problem did you have with the first encoder you tried?

Thank you, I never tried an encoder because I didn’t not want to purchase an expensive absolute position encoder.