Sei sulla pagina 1di 13

University of Maribor

Faculty of Electrical Engineering and Computer Science


Smetanova ulica 17, 2000 Maribor
Slovenia
INSTITUTE Of ROBOTICS

DC Motor Library and Demonstration Examples


User’s Guide

Authors: Aljaž Kapun


Darko Hercog
dsp2lib version: 1.5.03
Terminal version: 1.5.3
MATLAB version: 6.5
Contact: aljaz.kapun@uni-mb.si

October, 2005 DC Motor Demos


TABLE OF CONTENT i

TABLE OF CONTENT

1. ABOUT THIS DOCUMENTATION ....................................................................3

2. DSP-2 DC MOTOR SIMULINK LIBRARY .........................................................4


2.1. DESCRIPTION OF DC MOTOR SIM MODEL BLOCK .......................................................... 4
2.2. DESCRIPTION OF DC MOTOR DSP-2 INTERFACE BLOCK .................................................. 5
3. DEMO EXAMPLES FOR DC MOTOR .................................................................8
3.1. DEMO EXAMPLES FOR SIMULATION ........................................................................... 9
3.2. DEMO EXAMPLES FOR REALIZATION ON DSP-2 BOARD ...................................................10
3.3. FILES FOR DEMONSTRATION EXAMPLES ...................................................................... 1
TABLE OF FIGURES ii

TABLE OF FIGURES

Figure 1: DC motor .................................................................................................. 3


Figure 2: DC motor Simulink library ............................................................................ 4
Figure 3: Mathematical model of DC motor in Simulink .................................................. 5
Figure 4: Setting parameters for DC motor SIM model block .......................................... 5
Figure 5: Contents of DC motor DSP-2 interface block ................................................... 6
Figure 6: Setting parameters for DC motor DSP-2 interface block.................................... 7
Figure 7: Demo examples for DC motor....................................................................... 8
Figure 8: Demo example for simulation – current control of DC motor ............................. 9
Figure 9: Demo example for realization on DSP-2 board – current control of DC motor......10
Figure 10: Monitoring current response in Terminal scope .............................................. 1
ABOUT THIS DOCUMENTATION 3

1. About this documentation


In this guide usage of DC motor library (dcservolib) and DC motor demonstration
examples is described. It is assumed that user is familiar with DSP-2 board, DSP-2
library for Simulink and DSP Terminal, if not user should read the documentation
which can be found under:
http://www.ro.feri.uni-mb.si/projekti/dsp2/documentation.htm

Related documentation:
• DSP-2 board
• DSP-2 Library for Simulink
• DSP Terminal
• Three phase bridge (Hardware description).

Figure 1: DC motor
DSP-2 DC MOTOR SIMULINK LIBRARY 4

2. DSP-2 DC MOTOR SIMULINK LIBRARY


The library is accessible by typing following line in the MATLAB Command window:
>dcservolib
After confirming the command the dcservolib library window, shown on Figure 2
appear.

Figure 2: DC motor Simulink library

The dcservolib library is used for working with DC motor with permanent magnets.
The library contains two blocks. Block named DC motor SIM model is used for
simulations, while the block named DC motor DSP-2 interface is used for realization
on DSP-2 board.

2.1. Description of DC motor SIM model block


Block DC motor SIM model represent a mathematical model of DC motor with
permanent magnets (Figure 3). The block is masked which means that it is possible to
change the parameters of the model through Block Parameters window (for Block
Parameters window double click DC motor SIM model block), see Figure 4. Parameters
of used motor (ESCAP 28D2R 219P DC motor) are defined in parm_escap219p.m file.
DSP-2 DC MOTOR SIMULINK LIBRARY 5

Figure 3: Mathematical model of DC motor in Simulink

Figure 4: Setting parameters for DC motor SIM model block

2.2. Description of DC motor DSP-2 interface block


DSP-2 DC MOTOR SIMULINK LIBRARY 6

Block DC motor DSP-2 interface consist from group of blocks that interface to the DC
motor. It has two inputs and four outputs.
Inputs are:
• Enable signal which enables execution of pulse width modulation from DSP
Terminal. Enable signal is also used in logic unit, which reset PI regulators
integrators at the beginning of control algorithms.
• Motor terminal voltage ua. Motor terminal voltage is then fed into PWM block,
which calculate switching times for H-bridge.

Outputs are:
• Measured DC link voltage (Udc).
• Measured motor (armature) current (Ia).
• Measured rotor speed (ω).
• Measured rotor position (ϕ)

Figure 5: Contents of DC motor DSP-2 interface block

Block DC motor DSP-2 interface is masked; the following parameters of used


hardware can be changed through Block Parameters window, see Figure 6:
• motor voltage limit,
• ADC scale factor for measuring DC link voltage and motor current,
• number of incremental encoder pulses for transforming pulses into radians.
DSP-2 DC MOTOR SIMULINK LIBRARY 7

Parameters of used hardware (ESCAP 28D2R 219P DC motor and H bridge ver.2. or
three phase bridge) are defined in parb_hbv2.m file.

Figure 6: Setting parameters for DC motor DSP-2 interface block


DEMO EXAMPLES FOR DC MOTOR 8

3. DEMO EXAMPLES FOR DC MOTOR


For easier beginning with DC motors and DSP-2 board demonstration examples are
made. These demonstration examples can be invoked by typing the following line in
MATLAB Command window:

>dcmot_demos

After confirming the command the DC motor demos window, shown on Figure 7
appear.

Figure 7: Demo examples for DC motor

Following demo examples are made:


• control (connecting voltage to motor terminals and observing motor current,
rotor speed and rotor position),
• cascade control of DC motor – current loop,
• cascade control of DC motor – speed loop,
• cascade control of DC motor – position loop.
DEMO EXAMPLES FOR DC MOTOR 9

Demo examples are made for simulation purposes and also for realization of control
algorithms on DSP-2 board. Desired demo example is chosen with mouse click on
corresponding button.

3.1. Demo examples for simulation

After the desired demo example is chosen the block scheme in Simulink is opened.
The block scheme has two yellow blocks in left upper corner with names Edit
Parameters and Update Parameters. Double click on Edit Parameters block opens m-
file in MATLAB Editor window. In this m-file all necessary parameters for simulation
are called and defined. A variable called limits is also defined in this m-file. The
variable is used to take limits in consideration (set limits>0) or not (set limits<0).
Limits are defined in set_limits.m and no_limits.m files. By default limits are not taken
into consideration.
Double click on Update Parameters block runs parameters.

Figure 8: Demo example for simulation – current control of DC motor

To perform simulation demo examples the following steps should be made:


• choose demo example,
• change parameters if necessary, if not this step can be skipped,
• run parameters with double click on Update Parameters block,
DEMO EXAMPLES FOR DC MOTOR 10

• run the simulation with mouse click on Start simulation icon.

3.2. Demo examples for realization on DSP-2 board

Demo examples for realization on DSP-2 board are based on demo examples for
simulation. The main difference is in representation of DC motor. Instead of DC mot
sim model block, here DC mot DSP-2 interface block is used to represent DC motor.
Because of noise second order low pass filter is added to rotor speed measurement.
Note that, by default limits are taken into consideration.
A block Build is added to blocks Edit Parameters and Update Parameters, which have
the same meaning as in demo examples for simulation. Double click on Build block
starts the code generation process for the DSP-2 board from Simulink block scheme
(Figure 9).

Figure 9: Demo example for realization on DSP-2 board – current control of DC motor
CHAPTER 3: DEMO EXAMPLES FOR DC MOTOR 1

To perform demo examples for realization on DSP-2 board the following steps should be
made:
• choose demo example,
• change parameters if necessary, if not this step can be skipped,
• run parameters with double click on Update Parameters block,
• start code generation process for the DSP-2 board with double click on Build block,
• start the control algorithm on DSP board with setting Enable value greater than zero
in DSP Terminal (Figure 10).

Start the control


algorithm

Figure 10: Monitoring current response in Terminal scope

3.3. Files for demonstration examples

For proper working of demo examples, files listed in table below are needed. All files are
located in dcmotor directory.
CHAPTER 3: DEMO EXAMPLES FOR DC MOTOR 2

File name Description


dcmot_demos.m
DC motor demos window.
dcmot_demos.fig
dcservolibslo.mdl Library for DC motor.
parb_hbv2.m Bridge parameters.
parm_escap219p.m DC motor parameters.
set_limits.m
Limits definition.
no_limits.m
dcmot_sim_data.m
Control of DC motor– simulation.
dcmot_sim.mdl
dcmot_treg_sim_data.m
Current control of DC motor – simulation.
dcmot_treg_sim.mdl
dcmot_hreg_sim_data.m
Cascade speed control of DC motor – simulation.
dcmot_hreg_sim.mdl
dcmot_preg_sim_data.m
Cascade position control of DC motor – simulation.
dcmot_preg_sim.mdl
dcmot_data.m
Control of DC motor– realization on DSP-2.
dcmot.mdl
dcmot_treg_data.m
Current control of DC motor – realization on DSP-2.
dcmot_treg.mdl
dcmot_hreg_data.m
Cascade speed control of DC motor – realization on DSP-2.
dcmot_hreg.mdl
dcmot_preg_data.m Cascade position control of DC motor – realization on
dcmot_preg.mdl DSP-2.

Potrebbero piacerti anche