Sie sind auf Seite 1von 6

Int. J. Engng Ed. Vol. 21, No. 1, pp. 4954, 2005 0949-149X/91 $3.00+0.

00
Printed in Great Britain. # 2005 TEMPUS Publications.

Modeling and Simulation of the DC Motor


Using Matlab and LabVIEW*
NICOLAE PATRASCOIU
Automatic and Industrial Information Department, University of Petrosani, Romania. E-mail:
patrascoiu@upet.ro
One of the most used actuators in control systems is a direct current (DC) motor. The general
output variable of this actuator can be angular speed or angular displacement motion, but, coupled
with wheels or drums and cables, can provide translation motion. This paper proposes a statespace
model of the DC motor built for constant flux and considering two inputs: supply voltage and
resistive torque. The three states of the resulting model are represented by angular speed, angular
displacement and current supply and any of these states can be an output variable for a simulation
model. Consequently, the system's model has two inputs and three outputs. For the system's
simulation a VI is built where the most important element is a Matlab script which contains the
matrices A, B, C, D of the state-space model, the independent variable time and the Matlab
simulation function lsim. The motor's parameters are given by digital controls on the panel so that
these parameters can be interactively modified. To generate inputs, two CASE structures are used
where the input variables can be set: impulse, step and ramp. Here it is also possible to set the signal
amplitude and duration, either by knob or slide control. TRANSPOSE 2D ARRAY and INDEX
ARRAY are used for setting the matrices' dimensions. The output signals are live display, either
one by one or together, on the WAVEFORM GRAPH.

INTRODUCTION uE, iEexcitation voltage and current;


R, Lwinding electric resistance and inductance;
STUDENTS CAN USE the model and the VI in 'texcitation flux;
the classroom to simulate the running of a DC e(t)back electromotive force;
motor and also to learn how to incorporate the !tangular speed;
latter into a control loop. To start with, based on a m(t)electromagnetic torque;
functionality structure of the DC motor and on the rT(t)restoring torque.
laws of physics and electricity that rule the variable
magnetic flux density (separate excitation) motor's If we apply the Kirchhoff voltage theorem to the
operation, students build a mathematical model. supply circuit, we get:
Afterwards, using the mathematical model in a
series of simulation experiments in LabView, the dia t
vS t et R  ia t L  1
students can observe the motor dynamics. For this, dt
it is necessary to build the simulation VI and
students must analyze the diagram bloc of the VI The torque equilibrium equation on the axis of the
to ensure adequate functionality of the component motor is:
subdiagrams.
mt mT t fT t rT t 2
For the input signal, it is possible to select
various forms of supply voltage and/or resistive where mT t is the motoring torque, which is
torque so that the above-mentioned outputs can be dependent on the moment of inertia of the rotor,
observed. The forms of the output can suggest the and fT t is the motor friction torque.
design of the control loop or the type of controller Now the torque equilibrium equation can be
used. Also, for every input signal, students can written:
observe the effect of varying the parameters of the
DC motor over the outputs. d!t
mt J  F  !t rT t 3
dt
Functionality equations of the DC motor
We will consider a direct current (DC) electric It is known that an electromagnetic torque is
motor with separate excitation, compensating dependent on the excitation flux in excitation
winding and commutating pole. The structure of winding and on the supply current by the armature
this machine is presented in Fig. 1, where: constant kt which in SI units (which we will
vS, iSsupply voltage and current; use here) is equal to the motor constant ke
kt ke k:
* Accepted 14 July 2004.

49
50 N. Patrascoiu

Fig. 1. DC motor functionality structure.

into the general mathematical model of the DC


mt k  't  iS t 4 electrical motor. Now it can build the mathematical
model in statespace form so that it is possible to use
and the back electromotive force is dependent on
it in a Matlab simulation.
the angular speed and on the excitation flux in
Substituting equations (4) and (5) and notation
excitation winding by motor constant k:
(7) in equations (1) and (3) results in a complete
et k  't  !t 5 DC motor model by constant flux, respectively:

(1), (3), (4) and (5) are functionality analytical di t 1 R Km


 vS t  iS t  !t
equations (i.e. a general mathematical model of dt L L L
the DC electrical motor). 8
If we consider the angular displacement t d!t F Km 1
 !t  i t  mL t
instead of angular speed !t, a similar output dt J J J
variable is necessary to take account of the rela-
tionship between these: To build the statespace model, bring into this
d t mathematical model the input, state and output
!t 6 vectors:
dt
. State vector xt, whose components are repre-
The DC motor angular speed control is achieved sented by supply current iS t, angular displace-
by two methods: constant flux and variable flux. In ment t and angular speed !t:
this paper we consider speed control by constant
flux. iS t


Constant flux simulation model
xt t 9
If the excitation flux is constant, insert the
!t
notation:
. Input vector ut, whose components are repre-
k   Km 7

Fig. 2. Front panel and bloc diagram of the simmot.vi.


Modeling and Simulation of the DC Motor 51

Fig. 3. Matlab script node and parameter controls.

sented by supply voltage vS t and load torque


mL t: R Km
iS t 0


L
L iS t
vS t t 0
0 1  t
ut 10
mL t !t Km F
0 !t
J J
. Output vector yt, whose components we treat
as the same as state vector components, so that 1
0
L
it is possible to simulate these three physical vS t
quantities. 0 0  11
mL t
Using these vectors it is possible to write equations 1
0
(8) in matrix form: J
Using systems general equations, this form can be
written in compact form:
xt A  xt B  ut 12
where A and B are a costants matrix:

Fig. 4. Generation of input signals.


52 N. Patrascoiu

Fig. 5. Data representation of input signals.

Now we have the matrix A, B, C, D and we can use


R Km 1 the function lsim, which has the form:
0 0
L L L

A 0 0 1 ; B 0 0 13 y lsimA; B; C; D; v; t 17

Km F 1
0 0 where vector t specifies the time samples for the
J J J simulation and consists of regularly spaced time
If we add the output vector definition, the input samples t to simulate the DC motor as an LTI
output equation can be written as the matrix: system.

1 0 0 iS t 0 0
v t
S Build the VI to simulate a DC motor in LabView
yt 0 1 0  t 0 0 
mL t The control panel and bloc diagram of the VI
0 0 1 !t 0 0
that was used to simulate the DC motor are
14 presented in Fig. 2.
The base element of the LabView program
or, in compact form: simmot.vi, which is used to simulate a working
yt C  xt D  ut 15 DC motor, is the Matlab script node. Through
this, the matrix A, B, C, D of the motor state
where: space model and the simulation function are

1 0 0 0 0 inserted into the LabView program (Fig. 3).
The motor construction parameters R, L, Km , F

C 0 1 0 ; D 0 0 16 and J also represent the model parameters and

0 0 1 0 0 these are set using the controls on the front panel,
which should be named with the same letters as the

Fig. 6. Data representation of output signals.


Modeling and Simulation of the DC Motor 53

Fig. 7. Data representation of output signals in LabView and Matlab.

parameters. For the respective controls, the steps GRAPH display. To do this, the INDEX
of values corresponding to the real values of these ARRAY nodes are used for the input and the
parameters are chosen. The values set by these output. The right signal is selected to set the
controls represent the inputs for the script node index input of these nodes using the corres-
with real data type. ponding button on the front panel, so as to
Because the input vector has two components display the same signal by its connection to the
for generating the right signals, two blocs are built Matlab scrip input.
on the front panel. These two blocs are represented The right sequence of the simulation program is
in diagram bloc by a CASE structure with three necessary in order that the number of samples of
subdiagrams, which generates the standard signals the vector t, which represents the simulation time
(i.e. IMPULSE, STEP and RAMP). The subdia- in Matlab, is the same as the number of samples of
grams contain, respectively, Impulse Pattern.vi, the signal generation pattern. To do this in Matlab
Pulse Pattern.vi and Ramp Pattern.vi, and these script, the vector t that specifies the time samples
can be adjusted by the corresponding controls. for the simulation should have 5/0.01 1 501
Also, the control panel can be used to set para- components. It is also necessary for the number
meters such as amplitude, width (given by START of samples of the Ramp Pattern to be 501. For
TIME end STOP TIME) and delay (given by Stop Time control, Relative time (seconds) in the
START TIME) using either a knob or a slide Format & Precision option should be selected.
control (Fig. 4).
With the two arrays that contain the input
pattern, the BUIL ARRAY node can be used to CONCLUSIONS
obtain a new array that has values arranged in
rows that represent for a real system the input The Matlab lsim function simulates the (time)
signals. For a graphic representation of these, it response of continuous or discrete linear systems
can use a graphic display WAVEFORM GRAPH to arbitrary inputs and lsim (sys, u, t) produces a
type. The input vector requires a transpose array plot of the time response of the LTI model sys to
so that a vector can be obtained that is arranged in the input time history. If this function is incorpo-
two columns and in order that it can use the rated into a Matlab simulation program, such as
TRANSPOSE 2D ARRAY node to rearrange adding Matlab script to a LabView program called
the elements of the 2D array such that the 2D Virtual Instrument (VI), the input u can be
array [i, j] becomes a transposed array [j, i]. produced by a different signal generation function
Similarly, the same node is used at the output of in VI.
the Matlab script node because the output vector LabView starts Matlab and, if using the plot
of this node must be in rows and must have three (t,y) instruction after the lsim instruction in
columns that correspond to the three output Matlab script, a new Matlab window appears
signals. The input and the output terminals of labeled Figure No. 1, which displays the graphical
the Matlab script node corresponding to the responses of the DC motor outputs. In Fig. 7, the
input and output signals must be in Real Matrix similarity between the LabView and Matlab results
type. can be observed.
The input and output signals have different By means of controls placed on the front panel
forms and different value ranges (Figs 5 and 6), of the VI, the model parameters and the input
so that a selection of these signals is necessary signal parameters can be set. For example, where
using the AutoScale option of the WAVEFORM the load torque has a significant value, as shown in
54 N. Patrascoiu

Fig. 6, negative values appear for displacement program, it is possible to make comparisons
and speed outputs. This means that the motor between data acquired from a real system and
axle starts spinning the other way round. data obtained from a mathematical model of the
Also, because LabView is a data acquisition system.

REFERENCES

1. A. Fransua, Masini si actionari electrice, Tehnica, Bucuresti (1986).


2. M. Ghinea, Matlab: Calcul numeric-grafica, Teora, Bucuresti (1997).
3. D. Matko and R. Karba, Simulation and Modelling of Continuous System, Prentice-Hall, New
York (1992).
4. N. Patrascoiu, Modelarea si simularea sistemelor, Focus, Petrosani (2001).
5. LabView User Manual, National Instruments.
6. MATLAB1 Release 11. Documentation set (http://www.mathworks.com/support/).

Nicolae Patrascoiu is an Associate Professor in Engineering. He teaches data acquisition


and control systems at the Automatic and Industrial Informatics Department at the
University of Petrosani, Romania. He shows a particular interest in the links between
data acquisition and modeling and simulation systems.

Das könnte Ihnen auch gefallen