You are on page 1of 6

Document Type: Tutorial NI Supported: Yes Publish Date: Dec 13, 2010

Modeling DC Motor Position


Overview This tutorial shows how to represent the differential equation model for the position of a DC motor, using LabVIEW and the LabVIEW Control Design and Simulation Module. These tutorials are based on the Control Tutorials developed by Professor Dawn Tilbury of the Mechanical Engineering department at the University of Michigan and Professor Bill Messner of the Department of Mechanical Engineering at Carnegie Mellon University and were developed with their permission.

Controls Tutorials Menu

Motor Position PID Control

Table of Contents 1. 2. 3. 4. 5. 6. 7. 8. Physical Setup System Equations Transfer Function State-Space Model Design Requirements State-Space Model in LabVIEW Transfer Function in LabVIEW Result

Physical Setup A common actuator in control systems is the DC motor. It directly provides rotary motion and, coupled with wheels or drums and cables, can provide transitional motion.

The electric circuit of the armature and the free body diagram of the rotor are shown in the following figure:

Figure 1: DC Motor Circuit and Free Body Diagram For this example, we will assume the following values for the physical parameters. These values were derived by experiment from an actual motor in Carnegie Mellon University's undergraduate controls lab. moment of inertia of the rotor (J) = 3.2284E-6 kg.m^2/s^2 damping ratio of the mechanical system (b) = 3.5077E-6 Nms electromotive force constant (K=Ke=Kt) = 0.0274 Nm/Amp electric resistance (R) = 4 ohm electric inductance (L) = 2.75E-6 H input (V): Source Voltage output (theta): position of shaft The rotor and shaft are assumed to be rigid System Equations The motor torque, T, is related to the armature current, i, by a constant factor Kt. The back emf, e, is related to the rotational velocity by the following equations:

1/6

www.ni.com

In SI units (which we will use), Kt (armature constant) is equal to Ke (motor constant). From the figure above we can write the following equations based on Newton's law combined with Kirchhoff's law:

Transfer Function Using Laplace Transforms, the above equations can be expressed in terms of s:

By eliminating I(s), we can get the following transfer function, where the rotating speed is the output and the voltage is an input:

However, during this example we will be looking at the position as the output. We can obtain the position by integrating Theta Dot, so we just need to divide the transfer function by s.

State-Space Model These equations can also be represented in state-space form. If we choose motor position, motor speed, and armature current as our state variables, we can write the equations as follows:

Design Requirements We will want to be able to position the motor very precisely, thus the steady-state error of the motor position should be zero. We will also want the steady-state error due to a disturbance, to be zero as well. The other performance requirement is that the motor reaches its final position very quickly. In this case, we want it to have a settling time of 40ms. We also want to have an overshoot smaller than 16%. If we simulate the reference input (R) by a unit step input, then the motor speed output should have: Settling time less than 40 milliseconds Overshoot less than 16% No steady-state error No steady-state error due to a disturbance State-Space Model in LabVIEW We can represent the state-space equations in LabVIEW using either a graphical or a hybrid graphical/textual approach. LabVIEW Graphical Approach Begin with a blank VI. Insert the CD Construct State Space Model VI from the Model Construction section of the Control Design palette, and create controls for each of the inputs.

Figure 2: Construct State-Space Model Next, add the CD Draw State-Space Equation VI. This will display the state-space equation on the front panel. Create an output for the Equation from the CD Draw State-Space Equation VI.

2/6

www.ni.com

Figure 3: Display State-Space Equation Now add the CD Step Response VI from the Time Response section of the Control Design palette. Create a control for the Time Info input and an indicator for the Step Response Graph output.

Figure 4: Step Response VI (Download) This should result in a front panel that looks like this:

Figure 5: State-Space Front Panel (Download) Hybrid Graphical/MathScript Approach Alternatively, we can get the same results with a hybrid approach, using the MathScript Node. Begin with a blank VI, and insert a MathScript Node from the Structures palette. Add the following code to your MathScript Node: J=3.2284E-6; b=3.5077E-6; K=0.0274; R=4; L=2.75E-6;

A=[0 1 0 0 -b/J K/J 0 -K/L -R/L]; B=[0 ; 0 ; 1/L]; C=[1 0 0]; D=[0]; motor=ss(A,B,C,D); Then create a State-Space output from the Node, and add the CD Draw State-Space Equation VI and the CD Step Response VI as we did in the graphical approach.

3/6

www.ni.com

Figure 6: Hybrid Graphical/MathScript Block Diagram (Download) Transfer Function in LabVIEW Another option is to represent the transfer function in LabVIEW, instead of using the state-space model. LabVIEW Graphical Approach To represent the transfer function using a LabVIEW graphical approach, begin by inserting the CD Construct Transfer Function Model VI (from the Model Construction section of the Control Design palette) into a blank VI. Create controls for the Numerator, Denominator, and Variables inputs.

Figure 7: Construct Transfer Function Equation Next, add the CD Draw Transfer Function Equation VI to the block diagram, and create an indicator for the Equation output. This will display the transfer function equation on the front panel.

Figure 8: Draw Transfer Function Equation Now add the CD Step Response VI from the Time Response section of the Control Design palette. Create a control for the Time Info input and an indicator for the Step Response Graph output.

Figure 9: Step Response VI (Download) This should result in a front panel that looks like this:

Figure 10: Transfer Function Front Panel (Download)

4/6

www.ni.com

Hybrid Graphical/MathScript Approach Alternatively, we can get the same results with a hybrid approach, using the MathScript Node. Begin with a blank VI, and insert a MathScript Node from the Structures palette. Add the following code to your MathScript Node: J=3.2284E-6; b=3.5077E-6; K=0.0274; R=4; L=2.75E-6; num=K; den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2) 0]; motor=tf(num,den); Create a Transfer Function output from the Node, and then add the CD Draw State-Space Equation VI and the CD Step Response VI as we did in the graphical approach.

Figure 11: Hybrid Graphical/MathScript Block Diagram (Download) Result Using either the state-space model or the transfer function, you should see the following step response graph on the front panel when you run the VI:

Figure 12: Step Response for Open-Loop System From the plot, we see that when 1 volt is applied to the system, the motor position changes by 6 radians, six times greater than our desired position. For a 1 volt step input, the motor should spin through 1 radian. Also, the motor doesn't reach a steady state, which does not satisfy our design criteria.

Controls Tutorials Menu

Motor Position PID Control

Downloads mp-m_ss.vi mp-m_ss_h.vi mp-m_tf.vi mp-m_tf_h.vi mp-modeling_vis.zip

Legal This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE ( http://ni.com/legal/termsofuse/unitedstates/us/).

5/6

www.ni.com

6/6

www.ni.com

You might also like