Вы находитесь на странице: 1из 22

1/22

RPI Mechatronics
http://mechatronics.rpi.edu
How to Simulate a Brushed DC Motor Using LabVIEW 8.2

Jason Luecht, Matt Rosmarin, Mike Kleinigger - Research Assistants
Dr. Kevin Craig, Professor of Mechanical Engineering
RPI Mechatronics Laboratory 2007


This tutorial describes the process necessary to use LabVIEW to simulate the response of a given
dynamic system based on a mathematical model, i.e., a set of differential equations, derived from
the physical model of the actual system. The physical system used in this tutorial is the brushed
DC motor. The mathematical analysis, in this case the numerical solution of the nonlinear
coupled differential equations and resulting predicted dynamic response, is part of the
Engineering System Investigation Process, the cornerstone of modern engineering practice.

















( )
1
( )
1
( )
t
app emf
I t K B
J
di
V K RI t
L dt


=


=

& &&
&


Physical Model Parameters
J = motor inertia = 8.5E-6 kg-m
2

B = viscous damping coefficient = 3.7x10
6
R = internal resistance = 1.85
L = internal inductance = 1.97 mH
K
t
= torque constant = 4.24x10
-2
N-m/A
K
emf
= back-emf constant = 4.24x10
-2
V/rad/s

V
app
= applied voltage (volt)
= angular position of motor shaft (rad)
I(t) = current through the motor at time t (sec)

2/22
RPI Mechatronics
http://mechatronics.rpi.edu
Screenshots of LabVIEW Simulation Files

Plant


Mechanical Subsytem
3/22
RPI Mechatronics
http://mechatronics.rpi.edu

Electrical Subsystem


Front Panel
4/22
RPI Mechatronics
http://mechatronics.rpi.edu
LabVIEW Simulation of the Brushed DC Motor

Step 1
First, open LabVIEW 8.2. Once the Getting Started screen has appeared (Figure 3), under
the New menu select Empty Project. The project window will appear, then right-click
on My Computer New VI (Figure 4). A blank front panel will appear, and
behind that, an empty block diagram (Figure 5).



Figure 1
5/22
RPI Mechatronics
http://mechatronics.rpi.edu



Figure 2


6/22
RPI Mechatronics
http://mechatronics.rpi.edu

Figure 3




Step 2
Select the block diagram window. To do this you may either click the window to bring it
into focus or press the Control and E keys simultaneously. This shortcut can also be used to
switch back to the front panel.


Step 3
We first need to add a simulation loop within which the equations will be implemented.
Right-click in an empty space on the block diagram. You will be presented with the
LabVIEW functions palette (Figure 4). If youd like, click the thumbtack in the top left
corner of this window to fix it in place. Next click Control Design and Simulation, then
click Simulation and finally click the Simulation Loop. Your cursor will change its icon
and you can then click and drag to place the simulation loop onto the block diagram. If at a
later time you wish to adjust the size of the loop, you may click to select it, then click and
drag the boxes which appear to adjust the size. Figure 6 shows our simulation loop.

7/22
RPI Mechatronics
http://mechatronics.rpi.edu

Note: Everything inside of a simulation loop will be run according to
simulation time (right-click the black border of the loop and select
properties to adjust). This loop is how LabVIEW designates what part of
the block diagram defines a simulation.








Figure 5


Step 4
Before implementing the equations, click File Save. Now
we will begin by adding a numeric constant. Right-click to
bring up the functions palette. From the Programming
group (which is opened by default), select Numeric
Numeric Constant and place this on the block diagram.
Next, right-click on this block and select Change to
Control (Figure 6).



Figure 4
8/22
RPI Mechatronics
http://mechatronics.rpi.edu







Figure 6 Figure 7


Once this is complete, right-click the control and select Representation Double
Precision (Figure 7). This will convert the control from its standard integer to a double
(decimal value). You may also wish to change the label of this control to Vapp. Do
this by double-clicking the text, then typing. Once youve done this, repeat the procedure
to create three more constant doubles, K
emf
, R, and L, and one control, Theta dot.
Make sure each of these are set to double precision. Your block diagram should now
look similar to Figure 8.

9/22
RPI Mechatronics
http://mechatronics.rpi.edu

Figure 8

Step 6
Next, right-click to bring up the functions palette, then select Control Design and
Simulation Simulation Signal Arithmetic Multiplication (Figure 9). Place
two multiplication blocks next to the controls and constants you have created. Then, wire the
inputs from Theta dot and K
emf
into the terminals of one block. Wire R into the
multiplication terminal of the other block (Figure 10).
10/22
RPI Mechatronics
http://mechatronics.rpi.edu

Figure 9 Figure 10


Next, add an addition block (Found under Control Design and Simulation
Simulation Simulation Arithmetic). Double-click on this block to open its
properties window. Change the icon shape to Rectangle then click on each of the input
signs to change them to +, -, - as shown in Figure 11.

11/22
RPI Mechatronics
http://mechatronics.rpi.edu

Figure 11


Next, wire the output from Vapp into the + input of the addition block, wire then
wire the outputs from the two multiplication blocks into each of the - inputs. Next, add
another multiplication block and change its terminals to x and by double-clicking
to bring up the configuration window. Connect the output of the addition block to the
x input and connect L to the input as shown in Figure 12.

12/22
RPI Mechatronics
http://mechatronics.rpi.edu

Figure 12

Next, right-click on the output of the latest multiplication block and select Create
Indicator. Re-label this block di/dt. We have now completed the basic block
diagram for the electrical portion of our system. We will now add an integrator block to
compute the value of I(t). To do this, open the functions palette and select Control
Design and Simulation Simulation Continuous Linear Systems
Integrator Wire the input to this block to the output of the last multiplication block (to
which our di/dt indicator is now connected.)

Now, right-click on the output of the integrator block and create a second indicator. Re-
label this indicator I. Also connect the integrator output to the empty terminal on the
first multiplication block, as shown in Figure 13.
13/22
RPI Mechatronics
http://mechatronics.rpi.edu

Figure 13


Next, we will want to encapsulate all that we have created thus far in order to reduce the
complexity of the block diagram. To do this, select all of the blocks that we have placed
inside the simulation loop by clicking and dragging a box around them. Then, select
Edit Create Simulation Subsystem (Figure 14).
14/22
RPI Mechatronics
http://mechatronics.rpi.edu

Figure 14

The selected blocks have now been incorporated into a separate VI, as shown in Figure
15. So that we can easily see our inputs and outputs, right-click the subsystem and select
Icon Style Text Only.

You may now want to start cleaning up your VI by neatly arranging wires and blocks. At
any time, you may right-click on a wire and select Clean Up Wire. LabVIEW then
selects an optimal route for the wire to run. If you have loose/broken wires and you need
to quickly remove, press Ctrl+B and LabVIEW automatically removes them.

15/22
RPI Mechatronics
http://mechatronics.rpi.edu

Figure 15

Step 7
Now we will begin to diagram the equations for the mechanical portion of the system. To do
this, first add three three constant doubles, three multiplication blocks, and one addition
block. The three constants will be Kt, B and J. Wire them according to the equation
given above, as shown in Figure 16.

16/22
RPI Mechatronics
http://mechatronics.rpi.edu

Figure 16

Next, add another integrator block (found under Control Design and Simulation
Simulation Continuous Linear Systems), and connect it to the output of the final
multiplication block. You should also right-click on this output and select Create
Indicator. Next, delete the Theta dot control we created earlier. Connect in its place the
output from the integrator, as shown in Figure 17.

Finally, select the mechanical system blocks (Figure 17), and select Edit Create
Simulation Subsystem to create our mechanical subsystem.

17/22
RPI Mechatronics
http://mechatronics.rpi.edu

Figure 17

At any time, you can edit the contents of a subsystem by right-clicking and selecting
Open Subsystem. Do this now. You will notice that the output indicator connected to
the integrator has been labeled output change this to read omega then save and
close the subsystem (Figure 18)


Figure 18

18/22
RPI Mechatronics
http://mechatronics.rpi.edu

Figure 19

1. At this point your block diagram should look similar to that of Figure 19. We will now
add the necessary blocks to graph I(t) and omega. To do this, we will add the SimTime
Waveform block set. Right-click to open the functions palette then navigate to Control
Design and Simulation Simulation Graph Utilities. Select the SimTime
Waveform blocks and place them on the block diagram. Click and drag a box around
both to select them, then while holding the control key, click and drag to create copies of
both blocks. Now, connect the I and omega outputs to the inputs of the SimTime
Waveform blocks (Figure 20).

Note that holding the control key while dragging any block will create a copy of that
block wherever you release your cursor.

19/22
RPI Mechatronics
http://mechatronics.rpi.edu

Figure 20

2. Now switch back to the front panel by pressing Ctrl+E. You will notice two graph
windows, one input, and one output. Take a moment to organize the front panel. Next,
we will replace the default numeric control, Vapp, with a numeric slider. Right-click
the control and select Replace Vertical Pointer Slide (Figure 21). Once that is
done, right-click the slider and select Visible Items Digital Display. This will
allow us to key in a precise value.

20/22
RPI Mechatronics
http://mechatronics.rpi.edu

Figure 21


3. Before running the VI, we need to adjust the simulation parameters. Switch back to the
block diagram, then right-click on the simulation loop border and select Configure
Simulation Parameters. Change the Final time to 0.1 seconds, ODE Solver to Runge-
Kutta 1 (Euler), and Step Size to 0.00001 seconds as shown in Figure 22. Then, click
OK.

21/22
RPI Mechatronics
http://mechatronics.rpi.edu

Figure 22


4. Before running the completed VI, you may wish to adjust the settings for the two graphs.
Switch back to the front panel, then right-click on the graphs and select Chart History
Length. Enter 50000 for this value.

Note: The Chart History Length is the number of waveforms the chart will keep in
memory. If this value is too small the chart will erase the oldest values.

Next, right-click the graphs and select Properties (Figure 23). Under the Format and
Precision tab, you can adjust the number of digits which appear on the x and y axes.
Clock OK when you are finished adjusting these values. You may also want to change
the range for the x-axis. To do this, double-click the final value and change it to 0.10.
Also change the y-axis on the I(t) plot to range from 0 to 5, and the y-axis on the omega
plot to range from 0 to 150. You will also want to uncheck Autoscale Y Axis. Finally,
click the Run button (or press Ctrl+R) to view the simulation results (Figure 24).

22/22
RPI Mechatronics
http://mechatronics.rpi.edu

Figure 23



Figure 24

Оценить