# how to find the DC motor turning angle using encoder?

I have a DC motor (MTR11_200) encoder rotating at 100 RPM with and encoder(EH_30_M) which sending 200 PPR how to fix the DC motor to turn at specific angle using this information?

• Standard DC motors are not suited to stop at a certain angle. You should us gearing or a stepper motor. Yes, it can be done but will require considerable! effort. – Oldfart May 22 '18 at 12:00
• @oldfart, OP's motor is 100 RPM so must already be geared down. Don't need stepper motors, if that was your thought, servos use DC motors by the ton - much cheaper, better torque, finer stop positioning. – TonyM May 22 '18 at 13:44

how to fix the DC motor to turn at specific angle using this information?

You develop a small control system. From the "neutral" position the demand to move can be translated into a demand to increment "so-many" pulses. So, you turn on the motor and count the pulses (digitally) and when the required pulse count is met, you turn off the motor. However, there may be overshoot so you will need to reverse your motor direction (possibly using a H bridge) to bring it back to the target position demanded.

This then becomes a problem that may be solved with a 3 term (PID) controller should the position continue to oscillate and there are many algorithms to solve this with usually the simplest being that as you approach the target count you slow down the speed of the motor.

• so for the required pulse count I should determine the time for the specific angular turn!! – Rucha May 22 '18 at 12:26
• Why rely on time when you have an encoder? Just count quadrature edges. – Reinderien May 22 '18 at 12:27
• You could do but that is prone to errors and is not what I'm suggesting. – Andy aka May 22 '18 at 12:27
• @Andyaka : i'm not getting what you exactly suggesting ?? 'coz to determine the angle I have to give a time period.. – Rucha May 22 '18 at 12:41
• "angle for linear motion" - I have no idea what you mean. The turns per rev are 100 so if you need to turn 180 degrees you count up to 50 and stop. – Andy aka May 22 '18 at 13:35

What you are asking about is known in this industry as a servo motor. The motors are often equipped with an encoder to the motor shaft if the control is one of a rotary one. (Note that there are plenty of servo motor applications where the encoder may be of a different type. For example for a linear actuator the motor turns a lead screw which in turn creates linear motion and a linear encoder monitors the linear position.

Servo motors are optimized in several ways to make them suitable for the application. One aspect is that they must be designed to tolerate being in a static position while current is applied to their windings. Servo motors also carefully specify their rotational inertia because this must be matched to the rotational inertia of the load to provide the most stable operation.

Another whole part of this field is the driver electronics used to operate servo motors. This is usually divided into two parts. A driver module translates control signals to the voltage and current required to drive the windings of the servo motor. The second part is the servo controller. This contains the PID algorithm to send commands to the driver module to make the servo motor go to a specific position or to run at a particular rotational velocity. The controllers are normally fully programmable so that they can be characterized to the motors, loads and the speeds at which the components of the system can accelerate and stabilize once at a position or velocity.

The input to the controller in operational mode will typically be in the form of initialization to find a home position and then commands to go to a particular position or run at a particular velocity. Normally this is all done in units of encoder pulses but some controllers have the capability to convert physical system units to encoder pulses on the fly as commands are fed to the controller.

• but this is not what m asking for!! .. I want to turn the DC motor to specific angle – Rucha May 22 '18 at 12:51
• Yes it is. Read paragraph three again. Please write with proper punctuation. Don't use "!! ..". It makes it difficult to read. If English is not your first language then please put this information into your user profile. – Transistor May 22 '18 at 14:20
• @Rucha - Get yourself one of these - amazon.com/Futaba-FUTM0031-S3003-Standard-Servo/dp/B0015H2V72/… - and learn how they work. Inside is a DC motor that drives a gear box. The gear box drives the output and a position detector which happens in this case to be a potentiometer. Is it possible you could actually use one of these for your application? They typically operate over an angular range of 180 degrees or a bit more. – Michael Karas May 22 '18 at 14:23

For example, you can convert pulses into angle, first. 200 increments equals to 360 degrees, or -100/99 pulses equals to -180/ approx. +180 degrees.

SetpiontPulses =(200/360)*Angle_degrees; // setpoint in pulses

You may use modulo function for calculation:

SP-PV = (SetpiontPulses - MeasuredPulses + 300)%200 - 100;

where % is a modulo operator. What you'll get is the shortest angle difference (setpoint-measured) expressed in pulses -100 to 99, total of 200 increments, as 0 is also a valid position.

You feed this difference into a PID controller. You would also need an encoder with zero marking and a counter module.

• what will be the value of the setpoint pulses in an equation? – Rucha May 22 '18 at 13:17
• but this can be applicable for only linear motion of the motor na!! – Rucha May 22 '18 at 13:18