You are on page 1of 7

1/7 www.ni.

com
1.
2.
3.
4.
5.
6.
Simulation Modeling for DC Motor Position
Publish Date: Dec 13, 2010 | 4 Ratings | out of 5 4.00
Overview
This tutorial shows how to use LabVIEW and the LabVIEW Control Design and Simulation Module to construct a dynamic system to represent DC motor position.
These tutorials are based on the developed by of the Mechanical Engineering department at the University of Michigan and of the Control Tutorials Professor Dawn Tilbury Professor Bill Messner
Department of Mechanical Engineering at Carnegie Mellon University and were developed with their permission.
Motor Position Digital Control Controls Tutorials Menu

Table of Contents
Physical Setup
System Equations
Building the Model
Open-Loop Response
Implementing Digital Control
Closed-Loop Response
1. 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
electromotiveforceconstant(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
2. System Equations
The motor torque, , is related to the armature current, , by a constant factor . The back emf, , is related to the rotational velocity by the following equations: T i Kt e
In SI units (which we will use), (armature constant) is equal to (motor constant). Kt Ke
3. Building the Model
This system will be modeled by summing the torques acting on the rotor inertia and integrating the acceleration to give the velocity, and integrating velocity to get position. Also, Kirchoff's laws will be
applied to the armature circuit.
First, we will model the integrals of the rotational acceleration and of the rate of change of armature current.
2/7 www.ni.com
To model these integrals, begin with a blank VI. Create a Simulation Loop, from the Simulation section of the Control Design & Simulation palette. Insert three Integrator blocks (from the Linear
Systems section of the Simulation palette) into your model. To create labels, double-click on empty space in your block diagram.
Figure 2: Integrator Blocks
Next, we will start to model both Newton's law and Kirchoff's law. These laws applied to the motor system give the following equations:
The angular acceleration is equal to 1/J multiplied by the sum of two terms (one positive, one negative). Similarly, the derivative of current is equal to 1/L multiplied by the sum of three terms (one
positive, two negative).
To model this, drag two Summation blocks (from the Signal Arithmetic section of the Simulation palette) into the Simulation Loop. Adjust the inputs on each Sum block to represent the signs of the
terms in parentheses above.
Drag two Gain blocks into your model (from the Signal Arithmetic section of the Simulation palette). The outputs of each of these Summation blocks will need to be multiplied by the inverses of J and
L. We will be entering these values externally. Double-click on each Gain block, and change the Parameter Source from Configuration Dialog Box to Terminal. Attach each one with a wire to the
outputs of the Summation blocks. Connect the outputs of the Gain blocks to the inputs of two of the Integrator blocks.
Figure 3: Summation and Gain Blocks
The Gain blocks should have values of 1/J and 1/L. From the Front Panel, create two Numeric Controls. Title them "J" and "L". On the Block Diagram, insert the Reciprocal block (from the Numeric
section of the Programming palette). Connect J and L to separate Reciprocal blocks, and then connect the output of these Reciprocal blocks to the Gain blocks in the Simulation Loop.
Figure 4: Inductance and Inertia
Next, we need to model the terms from the angular acceleration equation. Recall that Kt (armature constant) is equal to Ke (motor constant). For this reason, we can create a single variable to use for
both of these values. Create a Numeric Control on the Front Panel, and title it "K".
For the Kt term, create a Gain block and place it to the left of the lower Summation block in the Simulation Loop. Label this block "Kt". Configure it so that its source is from a terminal. Connect the i
output from the upper Integrator block to the input of the Gain block that you just created. Then connect K to the gain terminal of the Gain block.
To account for damping, create another Numeric Control, and name it "b". Create another Gain block, configure it so that its source is from a terminal, and then connect b to this terminal. Reverse the
3/7 www.ni.com
To account for damping, create another Numeric Control, and name it "b". Create another Gain block, configure it so that its source is from a terminal, and then connect b to this terminal. Reverse the
block (right-click on the block and select "Reverse Terminals"), and then connect theta to its input. Wire the output of the damping block to the negative terminal of the lower Summation block. We
have now modeled the inertia equation.
Figure 5: Angular Acceleration Equation
For the armature current equation, we need to model Ke and R (resistance). Create a Gain block, and configure it so that its source is from a Terminal. Connect K to this terminal, and label the block
"Ke". Tap off the d(theta)/dt wire, and connect it to the Ke input. Connect the Ke output to a negative terminal of the upper Summation block.
To account for resistance, create another Numeric Control, and name it "R". Create another Gain block, configure it so that its source is from a terminal, and then connect R to this terminal. Reverse
the block, and then connect i to its input. Connect the output of this block to the remaining negative terminal on the upper Summation block.
Figure 6: Armature Current Equation
Now we need to model the source voltage, V, for the system. Insert a Step Signal block from the Signal Generation section of the Simulation palette, and connect it to the positive input of the upper
Summation block.
Figure 7: Step Signal
Double-click on the Step Signal block to configure its settings. Set the initial value to 0, the final value to 1, and the step time to 0.01.
4/7 www.ni.com
Figure 8: Step Signal Configuration
Now, set the values for the Numeric Controls on the Front Panel. When you are finished, save these values by clicking the Edit menu and selecting "Make Current Values Default."
Figure 9: Front Panel Controls
On the Block Diagram, insert a SimTime Waveform block from the Graph Utilities section of the Simulation palette, and connect it to the theta output.
( ) Figure 10: Waveform Chart Download VI
4. Open-Loop Response
To simulate this system, an appropriate simulation time must be set. Double-click on the terminals located on the left side of the Simulation Loop. In the Simulation Timing section at the top of the
dialog box, set the initial time to 0 seconds and the final time to 0.3 seconds. 0.3 seconds is long enough to view the open-loop response. For the ODE solver, select 'Runge-Kutta 45'. Close the
dialog box.
5/7 www.ni.com
Figure 11: Configure Simulation Parameters
Now, switch to the front panel. Right-click on the x-axis of the Waveform Graph, and de-select Auto-Scale X. Double-click on the maximum value of the x-axis (default is 10), and change it to 1.
Next, right-click on the y-axis of the Waveform Graph, and de-select Auto-Scale Y. Double-click on the maximum value of the y-axis (default is 1), and change it to 10.
When you run the simulation, you should see the following output:
( ) Figure 12: Open-Loop Response Download VI
5. Implementing Digital Control
In the example, a digital controller was designed with the following transfer function: Motor Position Digital Control
Starting with the VI that you used for the open-loop response, select all the blocks in your Simulation loop except for the Step Signal block, the Waveform output block, and the Waveform Chart
indicator. With these blocks selected, click "Edit" and select "Create Simulation Subsystem".
Next, insert two Discrete Zero-Order Hold blocks (from the Discrete Linear Systems section of the Simulation palette). Place one just after the Step Signal input, and the other just before the SimTime
Waveform output.
Figure 13: Zero-Order Hold
Next, insert a Summation block and a Discrete Transfer Function block (from the Discrete Linear Systems section of the Simulation palette). Connect the Summation block and the Transfer Function
block in series with the first Zero-Order Hold block.
6/7 www.ni.com
Figure 14: Discrete Transfer Function
Double-click on the Discrete Transfer Function block and change the Transfer Function Parameter source to "Terminal". Change the Execution Mode to "Direct".
Figure 15: Discrete Transfer Function Configuration
Create a MathScript Node outside the Simulation Loop, and paste the following code into the Node:
num = 450*conv([1 -.85],[1 -.85]);
den = conv([1 .98],[1 -.7]);
sys = tf(num,den,0.001);
Create an output from the Node for the variable, and change its data type to "TF object". Connect this transfer function to the Transfer Function terminal of the Discrete Transfer Function block. sys
Figure 16: Create Transfer Function
Now, connect the Step Signal block to the positive input of the Summation block. Tap off the output from the second Zero-Order Hold block, and connect that to the negative input of the Summation
block.
( | ) Figure 17: Step Signal Connection Download VI Subsystem
7/7 www.ni.com
6. Closed-Loop Response
To simulate this system, an appropriate simulation time must be set. Double-click on the terminals located on the left side of the Simulation Loop. The design requirements included a settling time of
less than 0.04 sec, so we simulate for 0.06 sec to view the output.
In the Simulation Timing section at the top of the dialog box, set the initial time to 0 seconds, the final time to 0.06 seconds, and the ODE solver to Runge-Kutta 23. Close the dialog box.
Figure 18: Configure Simulation Parameters
On the front panel, change the window axis values on the Waveform Graph. Change the maximum y-axis value to 1.5 and the maximum x-axis value to 0.05.
Now run the VI. You should see the following output:
( | ) Figure 19: Closed-Loop Response Download VI Subsystem
Motor Position Digital Control
Controls Tutorials Menu

You might also like