You are on page 1of 9

Low-Cost Take-Home Experiment on Classical Control Using

Matlab/Simulink Real-Time Windows Target



Eniko T. Enikov, Vasco Polyzoev, Joshua Gill

Advanced Micro and Nano Systems Laboratory, Department of Aerospace and Mechanical
Engineering, University of Arizona

Abstract

This paper presents a low-cost hands-on experiment for a classical undergraduate controls course
offered on behalf of non-electrical engineering majors. The setup consists of a small DC
electrical motor attached to one of the ends of a light rod. The motor drives a 2-in propeller and
allows the rod to swing. Angular position is measured by a potentiometer attached to the pivot
point. A custom designed circuit board produces the controlled voltage input to the motor. The
board communicates with the PC through its serial port using RS-232 protocol. A simple
Matlab/Simulink module has been created to read the angle and send command signal to the
motor. The module is based on Real-time Windows Target software allowing a sampling rate of
200Hz. Students are able to construct classical PID and phase lead-lag controllers, as well as
modern controllers including state-space controller design and feedback linearization. The
project was tested in a classical control systems design class offered to senior-level mechanical
engineering students. Student feedback and survey data on the effectiveness of the module is also
presented.


I. Introduction

Hands-on laboratories have been an integral part of the engineering curriculum since its
inception
1
. Their importance has been recognized by the Accreditation Board of Engineering
Education (ABET) and its predecessors by creating criteria requiring adequate laboratory
practice for students
2-6
. During the last three decades, engineering laboratories have become
more complex, including simulation tools and computer-controlled test and measurement
equipment
7-8
. This increased sophistication has also led to more expensive equipment. The
inclusion of such laboratory courses in the undergraduate curriculum is challenging due to the
large number of students and the increased demand for instruction and equipment time. Hands-
on experience, on the other hand, is invaluable for active and sensory learning styles, which are
the predominant types of learning styles used by undergraduate students
9
. This paper describes
the development and testing of a new low-cost take-home laboratory module designed to
supplement the experience of our students taking their first course in Controls System Design.
This project was developed primarily for students who are not electrical engineering majors, as
these students typically do not have the benefits of electronic circuits training and tend to shy
away from projects involving electronics. In the Aerospace and Mechanical Engineering
Department of The University of Arizona, it is not unusual for the Control System Design course
to have enrollment of about 100 students. This makes offering a laboratory section within the
course nearly impossible. The project described here was developed primarily as a way to
provide some practical experience to the students using an inexpensive and portable setup which
Proceedings of the 2010 American Society for Engineering Education Zone IV Conference
Copyright 2010, American Society for Engineering Education


can be taken home. The portability and low-cost of the setup allows them to conduct experiments
during the semester and use the device to complete a term project. In addition to significantly
reducing the cost of offering an experimental component, the experimental module provided an
opportunity to demonstrate a modern approach towards control systems based on computers
(digital control).

II. Experimental setup description
The setup consists of a small DC electric motor driven by a 5 V pulse-width modulated (PWM)
signal. The motor is attached to the free end of the a light carbon rod while the other end of the
rod is connected to the shaft of a low-friction potentiometer. The potentiometer is fixed on a
plastic stand at the proper height, so that the pendulum can swing freely (see Fig. 1).



Fig. 1: Experimental apparatus: pendulum (left) and circuit board (right)

A 2-in propeller (model U-80) is attached to the motor shaft to produce a thrust force in order to
control the angular position of the pendulum. A self-calibrating step during the initialization
allows the system to automatically find the vertical position (origin of the coordinate system). A
custom designed circuit board produces the controlled voltage supply for the motor via Pulse-
Width Modulation (PWM) with a resolution of 0.05V. It also reads out the voltage on the
potentiometer, which is proportional to the angular position of the pendulum. These functions are
implemented using a Microchip PIC16F690 microcontroller, mounted on a ZIF socket for
convenient replacement in case of damage or of need for reprogramming. The apparatus
communicates with a PC through its serial port using RS-232 protocol and a Maxim MAX232
driver/receiver. For computers equipped with USB ports only, an RS232-to-USB adaptor is used
(Model: PL2303, Prolific Inc.). Through this serial link the microcontroller sends the value of
the potentiometer voltage measured by the built-in Analog-to-Digital Convertor (ADC), and
receives the computed control signal, converting it to the respective PWM output to the motor.
The PWM output is passed to an H-bridge formed by four MOS transistors, which produce the
Proceedings of the 2010 American Society for Engineering Education Zone IV Conference
Copyright 2010, American Society for Engineering Education


necessary current for the motor and allows bi-directional motor control. A MATLAB program
(either an m-file or a Simulink model) residing in the PC receives the potentiometer voltage,
computes the angular position of the pendulum, calculates the control signal from it, and sends
is to back to the embedded processor for conversion to PWM. Both open loop and closed loop
responses can be generated. The Matlab software also plots the pendulum angle in real time
during the experiment (see Fig. 2 for an example). A LabVIEW version of the experiment has
also been developed, however it was not used in the classroom yet.



Fig. 2: Motor pendulum setup (left) and step-input response (right)

The experiment also illustrates the use of Matlab/Simulink Real Time Windows Target (RTW)
environment. The RTW module performs classical control experiments using hardware in the
loop simulations. Using RTW, the sampling time was reduced by an order of magnitude to 5ms.
This is achieved by a built-in functionality of RTW that compiles the Simulink model down to C
or C++code, and then builds a native executable file. Removing the need for an interpreter
greatly improves the efficiency of the simulation. Packet-In and Packet-Out blocks are used in
the RTW model to communicate with the microcontroller on the custom printed circuit board. To
receive the angle of the pendulum, the microcontroller must be asked to send the angle. This is a
done via a Packet-Out block (see Fig. 3). Once the data is ready, the Packet-In block receives the
raw voltage. A step function with a period of 5ms and a duty cycle of 50% is used to generate a
query to the microprocessor every 5 ms.





Proceedings of the 2010 American Society for Engineering Education Zone IV Conference
Copyright 2010, American Society for Engineering Education




Fig. 3: Matlab/Simulink RTW implementation of the experiment

III. Description of student project assignment

The hardware described here has been tested with senior-year mechanical and aerospace
engineering students taking their first and only mandatory course in controls system design. Prior
to this experiment this course has been a lecture-only class, therefore the experiment had to be
conducted as part of the regular homework assignments. Consequently, the students had to
receive a detailed manual for the installation of the kit (www.nano.arizona.edu/mechatronics).
The project assignment asks the students to develop a non-linear mathematical model of the
pendulum and identify its physical parameters. The students focus on the dynamics of the
pendulum, while the dynamics of the electronic components and the DC motor were assumed
fast and negligible for the sake of this experiment. Typically, the students arrive at
TL c mgL mL + =
& & &
sin
2
, (1)
where mg is the weight of the motor, L is the length of the pendulum, c is the viscous friction
coefficient, and T is the thrust force from the propeller. Students are then asked to use feedback
linearization which cancels out the non-linear term in the form
u mg T + = sin . (2)
The resulting linear system has a simple transfer function with two real poles
cs s mL
L
s U
s
+
=
2 2
) (
) (
. (3)
Students are asked to use their knowledge of root locus design method and determine the
behavior of system (3) under closed loop control, i.e. to plot the root locus of (3) under
proportional feedback. In the next step of the assignment, students are presented with the fact
that for small values of the input voltage u , there is not thrust, i.e. the motor has internal dry
friction preventing it from spinning until the voltage is approximately 1 V.
A simple non-linear model of this friction is given by
0 0
~
),
~
( u u u u K T > = , (4)
where
0
u is the threshold voltage needed to overcome friction, and K is a proportionality
constant. Students are then asked to use a control law in the form ) ( sin
~
0
t u S u u + + = and to
show that under this law, the steady state angle of the pendulum
ss
and the input voltage
ss
u are
related through a graph shown in Fig. 4 (left). They are then asked to show that by selecting the
parameter mg K S / = , the resulting transfer function between the time varying input ) (t u and the
Proceedings of the 2010 American Society for Engineering Education Zone IV Conference
Copyright 2010, American Society for Engineering Education


output angle ) (t is that of Fig.5. Using multiple open loop response experiments of this later
system, students are able to identify numerical values of the parameters mL K / and
2
/ mL c .

Fig. 4: Sine of the steady-state displacement angle vs. motor voltage (left) and open-loop
response (right)

s
mL
c
s
mL
K
2
2
+

Fig.5: Transfer function of the feedback-linearized pendulum

Upon identifying the parameters of the system, the students are asked to implement proportional
closed loop control according to the diagram of Fig. 6. Using root locus method, student predict
that the system is stable under all values of
p
K . However, when asked to run experiments for
5 . 1 ; 0 . 1 ; 8 . 0 ; 3 . 0 05 . 0 ; 02 . 0 =
p
K , they realize that for low values of the gain they obtain
stable response as shown in Fig. 7, while beyond certain gain the system looses stability and the
pendulum undergoes violent oscillations.


s
ml
c
s
ml
K
2
2
+



Fig. 6: Closed-loop control

0 5 10 15 20 25
-20
0
20
40
60
80
Time (s)


(
d
e
g
r
e
e
s
)
u

u

p
K

+
30
Proceedings of the 2010 American Society for Engineering Education Zone IV Conference
Copyright 2010, American Society for Engineering Education



Fig. 7: Closed loop response

This experience leads to the third phase of the project which introduces the concept of time
delay. Students are asked to augment their model with a first-order lag term (third pole added
at
D
T / 2 ) which models the time delay introduced by the digital sampling, data transfer. The
time delay,
D
T , varies based on the computer performance but is generally in the range of 30-50
ms. Using this additional information, they are able to modify their predictions by re-plotting the
root locus of a third order system as shown in Fig. 8. Subsequent testing of the closed loop
response does predict the correct stability limit of the closed loop gain.



Fig. 8: Root locus of third-order system reflecting the effect of time delay


0 5 10 15 20 25 30 35 40
-20
0
20
40
60
80
Time (s)


(
d
e
g
r
e
e
s
)
Disturbances
induced by slighly pushing
on the rod
Proceedings of the 2010 American Society for Engineering Education Zone IV Conference
Copyright 2010, American Society for Engineering Education


IV. Student experience assessment

An anonymous survey was conducted for the students choosing the project, to share their
experience after the first semester this project setup was offered in the Control System Design
course, following the protocol approved by the Institutional Review Board. As part of the
evaluation students were asked questions about the technical content as well as the
implementation and impact of the take-home project. Table 1 shows the evaluation of technical
content. As expected the majority of the students found the system quite useful in illustrating the
principles of control system design. Since frequency design methods were not used, the students
correctly indicated that Bode plots were not illustrated (row 7 in Table 1).

Table 1. Students technical experience assessment


As a comparison group, a paper-based term project was also offered. In the second part of the
survey, we asked the students why they had chosen the hardware project over the paper-based
one. The majority of them were excited by seeing the effect of the application of control theory
to a tangible system. They were also interested in establishing a connection between the
calculations and the experimental results. Comments such as I was excited about the idea of
Proceedings of the 2010 American Society for Engineering Education Zone IV Conference
Copyright 2010, American Society for Engineering Education


actually seeing this design work on paper get implemented into a tangible mechanismThe
hardware project offered a more real-world physical representation of control system designIt
seemed more interesting to be able to apply the topic to a physical system rather than a
theoretical controller design

The third set of questions referred to the implementation of the project, i.e. how portable and
convenient the kit is, whether the students were able to find necessary data, and how needed was
the assistance of a teaching assistant. The percentage of students who answered yes to each
question is shown in Table 2.

Table 2. Project implementation assessment
Did not need a physical lab at all, I could do everything myself 56 %
Had to use the TA a bit, but 1 hr per week was enough 32 %
I needed to ask for additional assistance outside the 1 hr/week from the TA/instructor 8 %
The project should be done in a permanent lab with fixed operating hours and TA-s 4 %

Finally, we inquired about the impact the project had on other courses taken by students by
administering a survey 6 months after completing the class. Students reported that the greatest
contribution of the project was in using controls in their senior-year capstone design course.
More than 50% of the students also indicated that they had used this experience in their job
search by including it on their resumes.

V. Conclusion

An inexpensive (less than $100) take-home experimental setup has been designed for a hands-on
experience of mechanical engineering students with a real control system. This makes it suitable
for a term project, where minimal or no supervision is required, and no special time or place is
needed. It also helps students whose major is not electrical engineering to become familiar with
the modern developments in implementation of real-time control systems. While simple, the
hardware allows demonstration of advanced concepts such as feedback linearization and time
delay. Early evaluation data show that the project is well-received among students and it can be
completed at home as initially conceived.

Acknowledgements

The authors acknowledge the financial support of the National Science Foundation under Grant
Nos. 0633312 and 0637052.

Bibliography:

1. Feisel, LD. and Rosa A.J . The Role of the Laboratory in Undergraduate Engineering Education, Journal of
Engineering Education, v. 94(1), p.121-130, 2005
2. New Directions in Laboratory Instruction for Engineering Students, Report of the Commission on
Engineering Education, J ournal of Engineering Education, v.58(3), ,p.191195, 1967.
3. The Undergraduate Engineering Laboratory, Final Report of the Quality of Engineering Education Project
(QEEP), American Society for Engineering Education, Washington, D.C., p. 125145, 1986.
Proceedings of the 2010 American Society for Engineering Education Zone IV Conference
Copyright 2010, American Society for Engineering Education


4. A National Action Agenda for Engineering Education, Washington, D.C.: American Society for
Engineering Education, 1987.
5. Ernst, EW, Editor, The Undergraduate Engineering Laboratory, Proceedings of an Engineering Foundation
Conference, J uly 2429, 1983.
6. Engineering Criteria 2000, Baltimore, Md.: ABET, 2002.
7. Aburdene, MF and El-Sharkawy, M, Integrated Engineering Workstations in Electrical Engineering
Laboratories, IEEE Transactions on Education, v. E-32, p. 404408, 1989.
8. Kadlowec, J, Lockette, PV, Constans, E, Sukumaran, B, and Cleary, D, Visual Beams: Tools for Statics and
Solid Mechanics, 32
nd
ASEE/IEEE Forntiers in Education Conference, Boston Mass., November 69, p.
T4D-7 - T4D-10, 2002.
9. Felder, RM. Reaching the Second Tier-Learning and Teaching Styles in College science Education, J . of
College Science Teaching, v. 23(5)p. 286-290, 1993