# Building an open loop controller for a simple DC motor position problem

In order to identify the dynamics of my DC motor, I am trying to command it with Xcos using the Arduino tool box. The problem that I am facing is how to give the motor an input command such that I get some given angle position as output. I can only control the input voltage to the motor via PWM.

I have been thinking about converting the angle to voltage but I can't figure it out. Can somebody help me?

You would need to construct a model of the motor's performance, and use that model to solve for the input that would give you the output you wanted.

In the simplest case, you could measure the motor's acceleration and deceleration -- the position of the motor over time -- and end up with 2 functions. Then you'd find the right amount of time to spend applying voltage so that the predicted position (after coming to a stop) is closest to your target position.

In graphical terms, you'd have a velocity-vs-time graph of acceleration that slopes up, and a velocity-vs-time graph of deceleration that slopes down. If you overlay them, they should cross. Now slide the deceleration graph left or right until the area underneath the 2 lines is equal to the position that you want. The point where they intersect indicates the time where you should stop applying voltage.

Without a position sensor, the quality of your result is only as good as the quality of your model.

• I do have an encoder for position and velocity in the motor.Sorry but i don t see the why i should measure velocity,acceleration and deceleration – ChiPlusPlus Feb 4 '15 at 22:12
• If you have an encoder for position and velocity, then why do you want to do open loop control instead of closed loop control? – Ian Feb 5 '15 at 16:05

Why do you want to go for an open-loop approach when you have position and velocity feedback at your disposal? In fact, only closed-loop controllers can provide desirable properties such as convergence, robustness, resilience to uncertainties in the model.

There is no static relation between voltage and angle position, simply because at steady-state a constant voltage yields a constant motor speed. Therefore, it's only how you vary the voltage over time that has influence in terms of final angle position (the integral of the speed), as Ian has tried to explain.

Under some wide conditions the relation between the voltage and the position can be described by a transfer function with two real poles: one in the origin and one negative pole accounting for the mechanical response of the motor (we can neglect the fastest electrical pole). The transfer function is simple and can be suitably identified by injecting special voltage waveforms (e.g. step-wise, train of pulses, chirps) and measuring back the position profiles.

Once the model is found, you have then to come up with a methodology to shape the input voltage $V$ in order to reach for the target position $\theta_d$.

In closed-loop it is very easy to select $V=PID(\theta_d-\theta)$, where $\theta$ is the position read from the encoder and $PID(\cdot)$ stands for the Proportional-Integral-Derivative control function, which ensures converge towards $\theta_d$ for a given set of control gains, so as robustness of the control action against variation of model parameters. In its simplest form, $PID(\cdot)$ can be just a multiplication by a coefficient $K$. In short, you are pretty sure that you reach the target.

By contrast, in open-loop you need to design a sort of input shaping of the voltage with resort to e.g. trapezoidal waveforms or other graphical methods (see Ian's answer), given the target to attain. Importantly, you have no guarantee that you will get on the target at the end, because of the uncertainties in the model that open-loop cannot compensate for.

• In fact ,i was trying to do that to identify 'the plant'.Since it is easier to identify velocity in closed loop ,i am gonna try this.Thank you for your answer. – ChiPlusPlus Feb 5 '15 at 7:42
• Beware of closed-loop identification: you must pay attention to that, since it differs significantly from open-loop identification. See for example this answer. – Ugo Pattacini Feb 5 '15 at 12:31