DC Motor System Identification
and Speed Control Using dSPACE Tools
S. Menaka and S. Patilkulkarni
Abstract This paper presents the system identification and speed control technique
of DC motor using dSPACE tools. The two different methods for the speed measure-
ment of the DC motor using dSPACE encoder and the hardware interrupt blocks
are discussed. The system identification of DC motor is done using the dSPACE
Control Desk 5.3 and system identification toolbox. The DC motor speed controller
is implemented using dSPACE hardware tools by PWM technique, where the speed
of the DC motor is controlled by controlling the motor’s terminal voltage with the
help of duty cycle of PWM. The control algorithm is developed using MATLAB-
Simulink and the Real time interfacing (RTI) is done by using dSPACE DS1104
controller board and CP1104 controller panel. The data capturing, visualization and
layout designing is done by using Control Desk 5.3. The developed model can be
used for Rapid control prototyping (RCP) and testing purposes for DC motor related
applications.
Keywords DC motor · CP1104 · MATLAB Simulink · Control Desk 5.3 · System
identification · RTI · PWM · dSPACE · RCP
1 Introduction
DC motors in industrial control systems have many applications as they are straight-
forward to operate and model. Sometimes an accurate DC motor model utilized
in a control system may be necessary for analytical analysis and optimization of
the control system design. In this scenario, the reference values of the DC motor
characteristics as specified in the motor specification which is generally provided
by the manufacturer of the motor might not be regarded sufficient particularly for
S. Menaka (B) · S. Patilkulkarni
JSS Science and Technology University, Mysuru, India
e-mail: menaka2211@gmail.com
S. Patilkulkarni
e-mail: sudarshan_pk@sjce.ac.in
© The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd. 2023 115
S. Chokkadi and R. Bandyopadhyay (eds.), Smart Sensors Measurement
and Instrumentation, Lecture Notes in Electrical Engineering 957,
https://doi.org/10.1007/978-981-19-6913-3_7
116 S. Menaka and S. Patilkulkarni
the more affordable DC motors, whose electric and mechanical parameters tend to
be quite high. DC motor model identification may be accomplished using general
system identification methods [1–3]. In the absence of costly testing equipment and
a lengthy testing cycle, a rapid and effective technique of system identification [4–
7] based on the input and output values (i.e., the voltage and speed values) of the
motor is desirable and advantageous, particularly for field applications and quick
controller development [8]. It is necessary to load a specific input signal and identify
the system’s output [9] in order to make an approximation to obtain the mathematical
model of the system. This permits the design and insertion of PID controller to a
closed-loop system model [10, 11]. By the auto tuning process of the PID controller,
PID parameters are created [12]. The modified PID controller can then integrated
into the hardware in the loop (HIL) simulation of the control system [13], and the
performance of the system’s response can be assessed. From the literature review
for the system identification process different models such as Process model, ARX,
ARMAX, OE model, State space model [14], non-linear models were used. Among
all of the models used the process model is considered in our work since it is less
complex and is sufficient for second order system and the model coefficients have
an easy interpretation as poles and zeros. Other models can also be considered for
estimating transfer function to achieve more accuracy which is the future scope of
the work.
In this paper, a DC motor speed controller system using PWM technique is
proposed and implemented, and its performance is analyzed. The system identi-
fication process is also discussed. The controller is developed using MATLAB-
Simulink and implemented in real time using dSPACE Control Desk and hardware
tools (DS1104 controller board and CP1104 controller panel). The dSPACE tool
helps in developing a virtual controller for easy prototyping with making use of less
hardware components. The proposed system uses voltage, current and speed sensor
for measuring the input and output signal of the DC motor.
2 Methodology
Figure 1 describes the proposed block diagram of the experiment. The voltage sensor
is used to detect the voltage drawn by the motor. Output of voltage sensor is given to
ADC of ds1104 controller board and is then calibrated using the gain blocks to obtain
the motor voltage output. The current sensor is used to detect the current drawn by
the motor. The output of current sensor is given to ADC of ds1104 controller board
and is then calibrated using the gain blocks to obtain the motor current output. The
quadrature incremental magnetic encoder is used to obtain the speed feedback of the
motor. The encoder channel outputs is given to the encoder or interrupt pin of ds1104
controller board based on the speed technique used and is calibrated using the gain
blocks to obtain the output in terms of rpm value of the motor. The experimental
data of voltage, current and speed values are captured using Control Desk and are
used to obtain transfer function by system identification method. The speed control
DC Motor System Identification and Speed Control Using dSPACE Tools 117
Fig. 1 The proposed block diagram
of DC motor is implemented by using the pulse width modulation technique (PWM),
by applying variable duty cycle PWM signal to the motor driver circuit which also
controls the motor terminal voltage.
2.1 Voltage and Current Measurement
RTI Simulink model for voltage sensing is shown in Fig. 2. For analog inputs, the
dSPACE unit has an integrated gain of 0.1. Any signal read from a dSPACE ADC
block is multiplied by 0.1 in Simulink. Hence a gain value of 10 is applied on the
output of an ADC block to compensate for this. The 5 V range obtained across the
analog pin of voltage sensor lets recognizing of voltages up to 25 V with the help of
controller. Hence a gain value of 5 is multiplied to obtain the voltage value drawn
by the motor.
RTI Simulink model for current sensing is shown in Fig. 3. The dSPACE device
features an inbuilt gain of 0.1 for analog inputs. In Simulink, each signal received
from a dSPACE ADC block is multiplied by 0.1. Therefore, a gain value of 10 is
used to compensate for this in the output of an ADC block. The voltage observed
across VCC of ASC712 is around 4.86 V. When there is no current flow through the
terminals of the module, the output voltage will be half of the supply voltage, i.e.,
2.4325 V. This implies subtracting 2.4325 V from the voltage recorded at the ADC
pin. The current value is calculated by dividing this value by the sensitivity value of
the sensor. The below equation is used to calculate current drawn by the motor
Currentvalue = (adcvoltage − offsetvoltage)/Sensitivity (1)
Fig. 2 The RTI Simulink
model for voltage sensing
118 S. Menaka and S. Patilkulkarni
Fig. 3 The RTI Simulink model for current sensing
2.2 Speed Measurement of DC Motor Using Incremental
Magnetic Encoder
2.2.1 Speed Measurement Techniques
There are two techniques for measuring the speed using an incremental encoder they
are
– Pulse counting (Frequency measurement)
– Pulse timing (Period measurement).
Pulse Counting (Frequency Measurement)
The conventional and perhaps easiest way to determine rotor speed is by measuring
the frequency of the pulses of the encoder. In a given and constant time window,
the number of pulses observed is counted. Pulse counting method determines the
average pulse time. For the calculation of the angular velocity ω, say the count is n
pulse for a sample period T. Thus, the average pulse time is T /n. If N windows are
available on the disc, NT /n is the average time of one rotation. Therefore, the angular
velocity is given by
ω = 2π n/N T (2)
where
ω angular velocity
n pulse count
T sample period
N pulse per revolution.
Pulse Timing (Period Measurement)
The high frequency clock signal is measured with the pulse timing method during a
single encoder cycle. Assume the frequency of the clock is f Hz. If m clock cycles are
counted over an encoder cycle, m/f will be the time taken to complete one encoder
DC Motor System Identification and Speed Control Using dSPACE Tools 119
cycle. The average time for one disc revolution is Nm/f when there are a total of N
windows on the track. Therefore, the angular velocity is given by
ω = 2π f /N m (3)
where
ω angular velocity
f clock frequency
m number of clock cycles
N pulse per rotation.
2.2.2 The Implementation of Simulink RTI Model for the Speed
Measurement of DC Motor
Method 1: Speed measurement using encoder of ds1104 board (Pulse counting
method).
In this method speed is calculated based on the number of pulses obtained during a
certain amount of time. The block “DS1104ENC_POS_C1” gives read access to two
encoder interface channel’s position and delta position. The encoder master configu-
ration block defines the global characteristics for the encoder interface channels. The
encoder signal type is set to single ended (TTL) in the “Encoder master setup” block.
The encoder has a disc of 51.42° for each line, with 7 lines per revolution. The line
count is multiplied by the fixed number 51.42 to convert it to degrees. The “Encoder
delta position” output is used to compute the angular velocity of the motor in rad/s
by dividing it by the sampling time as in Fig. 4. The angular velocity is converted
to rpm by multiplying the rad/s value with 60/2π. The rpm values obtained in this
method was not accurate because in a fixed sample time the sufficient information
of the pulses is not obtained as a low-speed motor is used. This method is best suited
for high-speed motors.
Method 2: Speed measurement using hardware interrupt of ds1104 controller board
(pulse timing method).
The implementation of time measurement is being carried out by the function
call subsystem which is triggered by the DS1104MASTER_HWINT_I1 external
hardware interrupt block as shown in Fig. 5. The channel A of the incremental
magnetic encoder is connected to the external hardware interrupt pin of the ds1104
controller board. The input port of the function call subsystem, i.e., “Angle” denotes
the fixed angle between two successive pulses of the sensor which is calculated using
the equation 2π /(impulses per revolution).
Figure 6 depicts the proposed contents of the function call subsystem for the time
measurement. The previous time and the time difference value between two pulses
of the encoder are being stored in the data store memory and data store read blocks.
The system outputs block has been taken from the custom code library.
120 S. Menaka and S. Patilkulkarni
Fig. 4 The RTI Simulink model for speed measurement using encoder
Fig. 5 The RTI Simulink model for speed measurement using hardware interrupt
The following code is entered in the System Outputs block
// declare local variable
double currentTime;
// read timestamp
currentTime = ts_time_read();
// calculate difference to previous step
deltaT = currentTime – oldTime;
// save new timestamp
oldTime = currentTime;
The ts_time_read() function reads the absolute simulation time from the hard-
ware through which the currentTime and the oldTime values are obtained. The time
difference deltaT and the previous time of the encoder pulse oldTime is written to
the corresponding data store memory blocks. Thus the speed of the motor is calcu-
lated by dividing the fixed angle with the measured time difference deltaT, i.e.,
(2 * pi)/(impulses per revolution * deltaT).
DC Motor System Identification and Speed Control Using dSPACE Tools 121
Fig. 6 The Simulink model of function call subsystem block
3 System Identification of DC Motor
The experimental voltage and speed values of the DC motor captured using the
dSPACE control desk are exported to the MATLAB workspace. The transfer function
of the DC motor is identified by system identification toolbox as shown in Fig. 7.
Several models such as Process model, Polynomial models transfer function
model, state equation model, non-linear models are available to estimate the plant
model. In this work the process model structure was incorporated for the identifica-
tion process because the order of the model was easier to anticipate as the DC motor
model is a second order system. The reason why the ARX model is being ignored is
that the estimated model is a prediction model and is not directly dependent on the
input and output values which might cause difficulty in building the controller. The
obtained transfer function model has the best curve fit of 84% between the model
response and the measured output.
Figure 8 shows the flowchart of the system identification process which depicts
the steps involved during the identification process.
The obtained transfer function from the system identification process is given
below
122 S. Menaka and S. Patilkulkarni
Fig. 7 System identification toolbox
83.2
G(s) = (4)
(1 + 0.01534s)(1 + 0.00234s)
The Transient response, frequency response and the pole-zero plots of the obtained
transfer function from the system identification process is as shown in Figs. 9, 10
and 11, respectively.
4 Controller Implementation and Result
The Pulse Width Modulation (PWM) method can regulate the efficient armature
voltage using ON-OFF control technique. The greater duty cycle pulse turns ‘ON’
more long than the lower one. The duty cycle δ, is regulated by the following equation
Pulse on time or pulse width (ton )
Duty cycle (δ) = (5)
Pulse time period (T )
The ratio of ON to OFF time is known as the duty cycle, and it influences the
motor’s speed. By varying the duty cycle the desired speed can be obtained. PWM
pulses are used to control the duty cycle of a motor driver circuit. A square wave with
a constant voltage but variable pulse width or duty cycle is used to power the motor.
The controller implementation using pulse width modulation technique is as shown
in Fig. 12. The PWM pulse is generated using DS1104SL_DSP_PWM3 block. Since
DC Motor System Identification and Speed Control Using dSPACE Tools 123
Fig. 8 Flowchart of system
identification process
Fig. 9 Step response
124 S. Menaka and S. Patilkulkarni
Fig. 10 Bode plot
Fig. 11 Pole zero map
the frequency of the PWM pulse is kept constant to 1 kHz but the on-off duration
varies, the determination of duty cycle of PWM is based on the pulse width of the
pulse. As pulse width increases, the duty cycle of PWM also increases which in turn
increases the power delivered to the motor driver circuit. The duration of ON period
of PWM is longer at 100% duty cycle than at 50% duty cycle. This result in a faster
motor speed at 100% duty cycle compared to 50% duty cycle. The following equation
expresses the relationship between average voltage, supply voltage, and duty cycle.
DC Motor System Identification and Speed Control Using dSPACE Tools 125
δ
V(average) = (6)
V(supply)
Table 1 shows experimental results of the DC motor speed and voltage values
obtained at different values of duty cycle. The duty cycle was varied from 0 to 1
and the corresponding voltage and speed values were noted down. As the duty cycle
increases the DC motor’s speed also increases. The motor speed is 295 RPM at 30%
duty cycle, and the corresponding output voltage of the converter is 3.62 V. When
the duty cycle is set to 50%, the motor’s speed is 498 RPM, and the resulting output
voltage of the converter is 6.14 V. As the duty cycle approaches 70 and 90%, the
motor’s speed and the converter output voltage increases.
The graphs shown in Figs. 13 and 14 depicts the relation between duty cycle,
voltage and speed.
Fig. 12 The controller implementation model of DC motor
Table 1 Experimental results
Duty cycle (%) Voltage (V) Speed (RPM)
0 0 0
0.3 3.62 295
0.4 4.85 393
0.5 6.14 498
0.6 7.25 595
0.7 8.47 698
0.8 9.64 794
0.9 10.82 896
1 12.3 997
126 S. Menaka and S. Patilkulkarni
Fig. 13 Duty cycle versus
speed
Fig. 14 Duty cycle versus
voltage
Figure 15 shows the GUI developed using control desk for capturing the voltage,
current and speed data’s of the motor.
5 Conclusion and Future Scope
The two different methods for speed measurement of motor were implemented. It
was found that the pulse counting method using encoder block is best suited for
high-speed motors and the pulse timing method using hardware interrupt block is
best suited for low-speed motor. The process of system identification is discussed,
and the transfer function of the motor was achieved. The PWM method was used to
create a motor speed controller system. The relation of duty cycle against voltage and
speed parameters was investigated. It has been discovered that the greater the pulse
width, the higher the average voltage supplied to the motor terminals. As a result,
the magnetic flux inside the armature windings becomes greater. As a result, the
motor will revolve faster. By varying the duty cycle of the PWM pulse, the DS1104
controller gives flexibility in managing the speed. The impact of PWM pulse width
on DC motor voltage and speed values has been investigated.
The accuracy of the obtained transfer function from system identification process
can be increased by considering other models for estimation. The closed-loop
controller can be implemented for the transfer function obtained from the system
DC Motor System Identification and Speed Control Using dSPACE Tools 127
Fig. 15 The control desk layout designed for the experiment
identification process and can be implemented on hardware. The cascade control of
the motor can also be incorporated by considering current also as feedback along
with speed. The same model can be worked on and implemented using dSPACE
MicroAutobox II.
References
1. Awoda M, Ali R (2019) Parameter estimation of a permanent magnetic DC motor. Iraqi J Electr
Electron Eng 15(1):28–36
2. Sankardoss V, Geethanjali P (2017) Parameter estimation and speed control of a PMDC motor
used in wheelchair. Energy Procedia 117:345–352
3. Ramasubramanian D (2016) Identification and control of DC motors. Master’s thesis in
automatic control and robotics, Barcelona School of Industrial Engineering, ETSEIB
4. Bature A (2013) Identification and real time control of a DC motor. IOSR J Electr Electron
Eng 7(4):54–58
5. Becedas J, Mamani G, Feliu V (2010) Algebraic parameters identification of DC motors:
methodology and analysis. Int J Syst Sci 41(10):1241–1255
6. Othman K, Kamal M (2009) System identification of discrete model for DC motor positioning.
In: Recent advances in circuits, systems, electronics, control and signal processing, pp 212–216
7. Hassan MM, Aly AA, Rashwan AF (2007) Different identification methods with application
to a DC motor. J Eng Sci 35(6):1481–1493
8. Tang WJ, Liu ZT, Wang Q (2017) DC motor speed control based on system identification and
PID auto tuning. In: Chinese control conference, CCC, 61403422, pp 6420–6423
9. Ljung L (1998) System identification. In: Procházka A, Uhlíř J, Rayner PWJ, Kingsbury NG
(eds) Signal analysis and prediction. Applied and numerical harmonic analysis. Birkhauser,
Boston, MA
128 S. Menaka and S. Patilkulkarni
10. Joshi B, Shrestha R, Chaudhary R (2014) Modeling, simulation and implementation of brushed
DC motor speed control using optical incremental encoder feedback. In: Proceeding of IOE
graduate conference, Nov 2014, pp 497–505
11. Fliess M, Sira-Ramirez H (2008) Closed-loop parametric identification for continuous-time
linear systems via new algebraic techniques. In: Identification of continuous-time models from
sampled data. Springer, pp 363–391
12. Dewangan AK, Chakraborty N, Shukla S, Yadu V (2012) PWM based automatic closed loop
speed control of DC motor. Int J Eng Trends Technol V3(2):110–112
13. Wu W (2010) DC motor parameter identification using speed step responses. In: Proceedings
of the American control conference 2012, no 3, pp 1937–1941
14. Basilio JC, Moreira MV (2004) State-space parameter identification in a second control
laboratory. IEEE Trans Educ 47(2):204–210
15. Rahmani F, Quispe D, Agarwal T, Barzegaran M (2020) Speed control of brushless DC motor
by DC-DC boost and buck converters using GaN and SiC transistors for implementing the
electric vehicles. Comput Res Prog Appl Sci Eng 06(02):70–75
16. Amalrajan R, Gunabalan R, Tewari N (2020) DSPACE1103 controller for PWM control of
power electronic converters. In: Lecture notes in electrical engineering, vol 687, pp 307–322
17. Fatma MW, Hamid MI (2019) PWM speed control of DC permanent magnet motor using a
PIC18F4550 microcontroller. IOP Conf Ser Mater Sci Eng 602(1)
18. Hamzi B, Owhadi H, Koch J, Naung Y, Schagin A, Oo HL, Ye KZ, Khaing ZM, Simani S,
Alvisi S, Venturini M (2021) Implementation of data driven control system of DC motor by
using system identification process. Electronics (Switzerland) 8(2):1801–1804
19. dSPACE DS1104 control workstation & Simulink tutorial (2018) Utah University, pp 1–38
20. Tatenda Katsambe C, Luckose V, Shahabuddin NS (2017) Effect of pulse width modulation on
DC motor speed. Int J Students’ Res Technol Manag 5(2):42
21. Agung IGAPR, Huda S, Wijaya IWA (2014) Speed control for DC motor with pulse width
modulation (PWM) method using infrared remote control based on ATmega16 microcontroller.
In: Proceedings—2014 international conference on smart green technology in electrical and
information systems: towards greener globe through smart technology, ICSGTEIS, pp 108–112
22. Gunda KK (2008) Adjustable speed drives laboratory based on dSpace controller. MSc thesis,
Louisiana State University
23. Mamani G, Becedas J, Feliu-Batlle V, Sira-Ramirez H (2007) Open-loop algebraic identifica-
tion method for a DC motor. In: 2007 European control conference (ECC), pp 3430–3436
24. Petrella R, Tursini M, Peretti L, Zigliotto M (2007) Speed measurement algorithms for low-
resolution incremental encoder equipped drives: a comparative analysis. In: International
Aegean conference on electrical machines and power electronics and electromotion ACEMP’07
and electromotion’07 joint conference, pp 780–787
25. Azli NA, Bakar MS (2004) A DSP-based regular sampled pulse width modulation (PWM)
technique for a multilevel inverter. In: International conference on power system technology,
POWERCON, vol 2, pp 1613–1618
26. Lord W, Hwang JH (1977) DC servomotors-modeling and parameter determination. IEEE
Trans Ind Appl 3:234–243