DC Motor Control: Jacob Fainguelernt
DC Motor Control: Jacob Fainguelernt
DC Motor Control ∗
Jacob Fainguelernt
This work is produced by The Connexions Project and licensed under the
Creative Commons Attribution License †
Abstract
This module demonstrates the use of the c28x peripherals and DMC library blocks to control the
speed of a DC motor in a closed-loop fashion. This example is based on the "DC Motor Speed Control
via RTDX" SIMULINK demo.
1 Introduction
This chapter demonstrates the use of the c28x peripherals and DMC library blocks to control the speed of
a DC motor in a closed-loop fashion. This example is based on the "DC Motor Speed Control via RTDX"
SIMULINK demo.
The target speed of the motor is set by the user in the MATLAB GUI. This value is fed to the Controller
(based on the eZDSP-F2812) to change the motor speed. The loop is closed by a tachometer. The controller
constantly adjusts the value of the DC voltage applied to the motor to maintain the desired speed. The
control loop is shown in the following gure:
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 2
The Speed controller comprises two blocks (please refer to Figure 2):
1. This block compares the desired speed with the measured speed and generates a digital value propor-
tional to the DC value to be applied to the motor.
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 3
2. This block is implemented using a PWM signal generator and a Low Pass Filter as shown in Figure 3.
This method is described in . The output voltage, generated at the LPF output will be:
V = D · Vss (1)
Where:
V - Generated Voltage
Table 1
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 4
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 5
1.1 Setup
This demo is based on the Spectrum Digital eZdsp-F2812 that is connected to a DC Motor Kit through a
dedicated interface circuit. The setup is shown in Figure 5.
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 6
Figure 5: Setup
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 7
2 System Identication
The transfer function of a DC motor can be approximated by a rst order model with unknown constants.
These constants can be identied experimentally.
The tachometer provides the feedback signal for speed control systems. A schematic diagram of the
tachometer is given in Figure 6.
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 8
In this section we will identify the constants in the mathematical models of a DC motor and the tachome-
ter experimentally. The process consists of consists of two parts:
Measurement Equipment
• Signal Generator
• Voltmeter
• Oscilloscope.
• Stroboscope
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 9
Figure 8 shows the model that will be used to generate the control voltage.
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 10
The PWM block will be congured to generate a PWM signal with a period of 4096 clock cycles of 75
MHz (please refer to Figure 9).
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 11
Measurement Procedure:
1. Connect the circuit shown in Figure 7.
2. Generate a 0 V input to the DC Motor Kit (Compile Build and Run the model with Duty Cycle=0)
3. Measure the motor speed using the stroboscope and the tachometer voltage using a voltmeter.
4. Repeat step 3 for input voltages in the range 0-15 V. Change the Duty Cycle from 0 to 100% in steps
of 10 %.
5. Obtain a plot of tachometer voltage vs. servo amplier input voltage.
The ADC input voltage of the DSP should be in the range 0-3V, the therefore the tachometer output voltage
must be inverted and scaled down. This is done with the circuit shown in Figure 19. The gain of this circuit
is G = - 100/270 = - 0.37, i.e., inverting and attenuating approximately 1/3. The results obtained are shown
in Figure 10.
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 12
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 13
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 14
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 15
Measurement Procedure
1. Connect the circuit shown in Figure 12.
2. Generate the pulse shown in Figure 13.
3. Measure the rising and falling times of the motor response.
The DC motor was modeled as a rst-order linear system where τrise = τfall ; however, the actual motor is
not linear (due to friction, for example), therefore the measured values were:
Table 2
We used the average of these readings, i.e., (0.13+0.23)/2 = 0.18 and rounded to 0.2 sec.
Ω(s) 1 Ω(s)
E(s) = Km 1+sτ m
⇔ E(s) = Km 1+1.2s (2)
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 16
3.1 Simulation
The speed control is a PID controller. A DC motor model (Figure 14) was created. The complete control
loop model is shown in Figure 15. Figure 16 shows the parameters chosen for the PID controller.
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 17
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 18
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 19
The interface circuit contains two blocks. The rst is LPF with an amplier (shown in Figure 18),
connected between the PWM output and the servo amplier input. The second block is an attenuator
(shown in Figure 19) connected between the tachometer output and the Analog to Digital Input of the
eZDSP.
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 20
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 21
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 22
Procedure:
..\MATLAB\R2006b\toolbox\rtw\targets\tic2000\tic2000demos
• c2812speedcontrolDC.mdl
• runc2812speedcontrolDC.m
• runc2812speedcontrolDC.m
• Open the c2812speedcontrolDC.mdl model and save it as "DCMotorControlc2812.mdl"(please
4
refer to Figure 21 ).
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 23
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 24
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 25
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 26
6. Delete the selected blocks and replace them by the ADC block from Open the ADC block from the
C281x Chip support group from the C2000 Target Preferences, and connect is as follows:
7. Now the model is ready for real-time, we need however to update the MATLAB script le. Open the
Model Properties from File menu. Change the PostLoadFcn callback to runc2812speedcontrolIDC,
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 27
as shown:
8. The next step is to change the original PWM range (up to 64000) to the desired range (up to 4000).
Open the speddControlIDCLoop.m le with the MATLAB editor, an change on line 48 the command:
cycle = (double(pid).*100./64000);
to
cycle = (double(pid).*100./4000);
Please refer to the following picture:
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 28
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 29
12. You may change the speed of the motor using the slider in the right hand side and the Apply button.
http://cnx.org/content/m22189/1.1/
Connexions module: m22189 30
5 References
1. "eZdspTM F2812 Technical Reference", Spectrum Digital, 2003 http://c2000.spectrumdigital.com/ezf2812/docs/ezf2812
5 http://c2000.spectrumdigital.com/ezf2812/docs/ezf2812_techref.pdf
6 http://www.ti.com/litv/pdf/spraa88a
http://cnx.org/content/m22189/1.1/