Freshman Engineering Problem Solving With Matlab For All Disciplines
Freshman Engineering Problem Solving With Matlab For All Disciplines
American
c Society for Engineering Education, 2016
Paper ID #17130
integrated, customized, mechatronics workshops for practicing engineers nationally and internationally,
e.g., at Xerox, Procter & Gamble, Rockwell Automation, Siemens Healthcare Diagnostics, Fiat, Tetra
Pak, Johnson Controls, and others. He is a Fellow of the ASME and a member of the IEEE and ASEE.
In January 2008, he joined the faculty of the Marquette University College of Engineering as Professor
of Mechanical Engineering and the Robert C. Greenheck Chair in Engineering Design, a $5M endowed
chair. He was given the 2013 ASEE North-Midwest Best Teacher Award and the 2014 ASME Outstanding
Design Educator Award, a society award. In the fall of 2014, he returned to the Hofstra University School
of Engineering and Applied Science as a tenured full professor of mechanical engineering. He is the
Director of the $1M Robotics and Advanced Manufacturing Laboratory, and also the Director of the
Center for Innovation, a new center created to collaborate with business and industry to foster innovation
where all intellectual property (IP) belongs to the sponsor.
American
c Society for Engineering Education, 2016
Freshman Engineering Problem Solving with MATLAB &
Simulink
Abstract
The current freshman engineering computer programming course, which utilizes MATLAB
programming language, is being experimentally redesigned to incorporate and highlight
activities focused on engineering problem solving and system investigation processes. These
methods hope to develop the students’ critical-thinking and analytical skills that are more suited
and applicable in real-world engineering. Course description and sample problems are
presented. Results will be shown in a follow-up study comparing the standard computer
program syntax-based approach to this pilot course which employs Simulink model-based
designs and hardware demonstrations.
1 Introduction
In 1969, one of the authors was a plebe (freshman) at West Point, engineering was the
required course of study, and a slide rule (Figure 1) was standard issue. In his first engineering
class, there was a 10-foot-long working slide rule hanging from the ceiling to aid in instruction.
He never once thought that his slide rule was going to solve an engineering problem he was
facing; it would just make his calculations easier. A decade later, he also never thought that his
hand-held calculator was going to solve his engineering problems, but now he could solve easily
many more types of engineering problems without having to resort to punch cards and
mainframe computers. However, his ability to estimate orders-of-magnitude was diminished.
The early 1980s saw the rise of the personal computer, and now every entering engineering
student at most universities has a laptop computer fully-loaded with the latest technical software.
When confronted with a problem before the desktop/laptop computer era, the engineering
student would develop the problem solution by hand, with pencil, paper, and much thought, and
only then was the slide rule or calculator taken out of its case, or, if needed, a computer program
written and cards punched. Today, entering freshmen have the perception that the solutions to
engineering problems are somewhere in the computer and just have to be found, when in fact the
solutions are where they have always been – in the minds of the engineers!
Freshman engineering students in all disciplines usually take some computing class (such as
C, Java, or MATLAB programming) – hopefully, learn about pseudo codes and flowcharting,
and then solve simple problems developed primarily to make use of some features of the
programming language just learned. It is certainly extremely valuable for an engineer to be able
to develop an algorithm to implement a solution to an engineering problem and then turn that
algorithm into computer codes (e.g., MATLAB syntax). But it is the process that is most
valuable: the process of thoroughly understanding the problem, making simplifying
assumptions to develop a physical model of the problem, applying the laws of nature to the
physical model to create a mathematical model, and then solving the mathematical equations,
usually by creating an algorithm, and then programming that algorithm on a computer to gain
insight and understanding. But, once that is done, in engineering practice today, most complex
engineering problems are solved using pre-written programs in MATLAB or LabVIEW, for
example, and only in special situations will an engineer write a computer program from scratch
specifically tailored to solve a complex problem. Even in real-time computer applications, auto-
code generation programs (e.g., Simulink and LabVIEW) are widely available and are quite
reliable. It would be most valuable if freshman engineering students were first exposed to the
types of engineering problems real engineers in any discipline face 90% of the time and
appreciate this process. It certainly would put their laptop computer, computer software, and
computer programming in the proper context. All engineers today, and in the future, must be
able to model multidisciplinary engineering physical systems, predict how they will behave
when built, optimize their design, validate their predictions and designs with engineering
measurements, and see a design through to prototyping and manufacturing, with sustainability
considerations paramount throughout.
Let’s fast forward four years. The engineering student is now graduating and interviewing
for a job. How many piano tuners are there in the city of Chicago? Estimation of rough but
quantitative answers to unexpected questions about many aspects of the natural world was
frequently used by Enrico Fermi, the legendary physicist, to gage one’s power over his/her
theoretical and experimental studies. These types of questions draw upon a deep understanding
of the real world and upon everyday experience. Many companies use problem-solving
questions in job interviews to judge the intelligence and flexibility of their applicants.
Examples of “Fermi Questions” used are: What does it really cost to drive a car? How many
golf balls does it take to fill a 747 airplane? Anyone can make up a Fermi question. These
types of questions serve as a test of applicants’ abilities to think on their feet and to apply their
mathematical skills to real-world problems. There is no single correct way to analyze these
types of questions; there are many paths to the answer. All you need to answer these questions
is a willingness to think! Here is another example: Your chance of winning the Mega Millions
lottery is one in 100 million. If you stacked up all the possible different lottery tickets, the
height of the stack would be greater than Mt. Everest. True? This ability is directly related to
the modeling and analysis of engineering systems. The very crux of engineering analysis and
the hallmark of every successful engineer is the ability to make shrewd and viable
approximations which greatly simplify the system and still lead to a rapid, reasonably accurate
prediction of its behavior.
Engineers are problem solvers and the only way to learn problem solving is to do it!
Only a human can solve problems; the computer is a tool. Design problems are the heart of
engineering and to solve them requires creativity, teamwork, and broad knowledge. The
approach to solving an engineering problem should proceed in an orderly, stepwise fashion,
but often problem solving is an iterative procedure. To become a good problem solver, an
engineer must have – knowledge, experience, learning skills, motivation, and communication
skills. The ability to logically break a problem into pieces is most important.
It is the mindset these Fermi questions engender and the challenges engineers face in
modern practice that motivates the reinventing of the standard Engineering Programming
course found in some form at every engineering school in the country. With all this in mind, a
pilot course is now being taught that attempts to instill excitement and relevance into a course
that, desperately needs revision. This approach to engineering programming is not new
and has been proposed previously 1-3 .
2 Course Description
ENGG 010: Computer Programming for Engineers is a three-credit (3-hour per week)
freshman engineering course offered at 5-6 sections per year (or 2-3 sections per semester).
There are approximately 25-30 students in a class taught in a computer lab equipped with various
softwares including MATLAB and LabVIEW. The main programming language of choice is
MATLAB. A typical syllabus include topics in assigning values to variables, creating scalars,
vectors and matrices, writing scripts and functions, utilizing mathematical, relational and logical
operators, matrix indexing and manipulation, plotting, solving linear systems, programming
constructs: if statement, for loop and while loop, animation, and building GUI programs. A pilot
course is now being taught to two ENGG 010 sections at the present time.
This pilot freshman engineering course (Figure 2) emphasizes the engineering problem
solving process and the engineering system investigation process, and applies both to the
physics of everyday life as experienced by the students. Fundamentals of feedback control are
introduced due to its pervasiveness in the human body, nature, and all engineering systems. The
differences between the analog and digital world, including sampling, aliasing, and quantization,
are fundamental and emphasized. The course applies various computer tools, essential in all
subsequent engineering courses and professional practice, in sufficient detail for the students to
be able to begin to apply them in real-world problem solving and model-based design.
MATLAB, Simulink, and MuPAD are used for – engineering computation, matrix algebra,
numerical integration and differentiation, equation solving, plotting, interpolation and curve-
fitting, and m-file programming; graphical programming using Simulink to predict dynamic
system behavior; symbolic mathematical analysis using MuPAD; and real-time microcontroller
programming using auto-code generation. Measurement with LabVIEW is also introduced.
The importance of the process of engineering problem solving (Figure 3) is highlighted to the
students at the beginning of the course. Every engineering problem must be properly assembled
and analyzed, then solutions are calculated and presented. Specifically, the process involves
subdividing into: Given, Find, Diagram, Basic Laws, Assumptions, Analysis, Numbers, Check,
and Label. Every assignment given must be completed following this process. This is continued
throughout all the courses in the engineering curricula.
Figure 2. Pilot course topics centered on engineering problem
solving.
Several exercises are taught in the class to demonstrate and stress the importance of
engineering problem solving and system investigation processes integrated with contemporary
computer programming tools. Some of them are:
a) Projectile motion problem solved by MATLAB m-file script using for/while loops
then modeled using interactive GUI.
b) Projectile motion problem solved using Simulink. Nonlinear equations can be solved
with Simulink or by assuming constant acceleration over small increments of motion
and writing a complex m-file. Both approaches are presented.
c) A feedback control system (the plant is a basic spring-mass-damper rotational
system) where the control is proportional, proportional + derivative, and proportional
+ derivative + integral. Students see how the control modes effect rise time,
overshoot, and steady-state error.
d) A studio exercise using the Arduino microcontroller with Simulink auto-code
generation to demonstrate aliasing and pulse width modulation.
e) A studio exercise using the Arduino microcontroller with Simulink auto-code
generation to control in real time the speed of a brushed dc motor.
f) A writing exercise to explain to a lay person the laws of nature involved in a physical
observation.
This problem requires the student to apply basic high school physics principles (uniform
motion, uniformly accelerated motion, free-body diagrams, Newton’s 2nd Law) to a projectile
(baseball in this case) and solve the problem first without air resistance, by writing a MATLAB
script with loops (for/while), and then with air resistance, by solving the nonlinear equations
numerically using Simulink.
Background – We have discussed the motion of projectiles (e.g., baseballs, golf balls, tennis
balls, etc.) in air, first neglecting air resistance, and then including air resistance. We know from
practical experience that air resistance has a great effect on the trajectory, range, and speed of a
projectile in air. In analyzing the motion of a projectile in air, we assume that the acceleration
due to gravity, g, is constant and equal to 9.81 m/s2. We also assume that the mass of the
projectile is constant and that the motion is planar (x-y plane). Then we either neglect air
resistance or include air resistance in our analysis. In the absence of air resistance, the only force
acting on a projectile is the gravitational force, its weight, m·g. The projectile motion equations
neglecting air resistance for the horizontal (x) and vertical (y) motion of the projectile are:
a x 0 a y g
v x (v x ) 0 v y (v y ) 0 gt (1)
x x (v ) t y y (v ) t 1 gt 2
0 x 0 0 y 0 2
Here, a is acceleration and v is velocity with the subscripts denoting directions as illustrated in
Figure 5a. The variable t is, as usual, time in s.
Upward
component
of velocity
(vy)0 v0
y
θ (vx)0
Downfield
O component
x of velocity
Figure 5a. Projectile problem components, global (left) and local (right).
The initial position of the projectile is x0 and y0. The launch angle of the projectile with the
horizontal is given by the angle, θ, and the initial projectile velocity is v0 (with (vx)0 and (vy)0
components). The air drag vector force acts opposite to the projectile velocity vector and is
proportional to the square of the projectile speed.
Fdrag, x D(vx )
2
(2)
Fdrag, y D(v y )
2
a x mD (v x ) 2
(3)
a y g mD (v y )
2
The constant, D, depends on the density of air, ρ, the silhouette area of the body, A, and the
drag coefficient constant, C, that depends on the shape of the body. Typical values of C for
baseballs and tennis balls are in the range 0.2 to 1.0.
CA
D 2 (4)
Requirements – The radius of a baseball is r = 0.0366 m and its mass is m = 0.145 kg. The
drag coefficient C = 0.5, appropriate for a batted ball or a pitched fastball. The density of air is ρ
= 1.2 kg/m3, appropriate for a ballpark at sea level. The initial velocity of the baseball v0 = 50
m/s at an angle of θ = 35° above the horizontal. Answer the following questions by following
the engineering problem solving process (Figure 3), documenting all steps.
Tasks –
1) Analyze the motion of the baseball without air resistance by writing an m-file
program, using an explicit for loop, to plot the range (x) vs. time (t), the height (y) vs.
t, x vs. y, and velocity (v) vs. t from time t = 0 until the ball hits the ground. Include
the MATLAB script with the generated figure plots well-labeled.
2) Analyze the motion of the baseball with air resistance using Simulink to solve the
equations of motion. Show plots of x vs. t, y vs. t, x vs. y, and v vs. t from t = 0 until
the ball hits the ground. Include with the plots, well-labeled, a hand drawing of the
Simulink block diagram, along with the actual Simulink block diagram file well-
annotated.
3) Compare the flight of the baseball, x vs. y and v vs. t, across level ground, both
without air resistance and with air resistance. What are your observations?
Example deliverables are shown in Figure 5b which includes a Simulink block diagram for
performing the analysis and a GUI for multiple user inputs and plotting the resulting animation.
Figure 5b. Projectile motion problem and sample solutions. Simulink block diagram (top), simulation
animation with axes to scale (middle), and interactive GUI with animation and user inputs (bottom).
3.2 c - Satellite antenna tracking problem
You wish to control the elevation of the satellite-tracking antenna such as the kind shown in
Figure 6a.
The antenna and moving parts have a combined moment of inertia J (60,000 kg-m2) and an
angular viscous damping coefficient B (20,000 N-m-s). The viscous damping term captures the
energy-dissipation contributions from bearing and aerodynamic friction. For this exercise, we
will neglect actuator and sensor dynamics, and any parasitic effects, e.g., time delay, backlash,
and saturation. However, there is a compliance, a “springiness”, in the mechanism that affects
the performance. It can be quantified as a torsional spring with a stiffness K (N-m/rad) equal to
3000.
Tasks –
1) A picture and sketch of the physical system are shown. Draw a picture of the
physical model along with a list of all simplifying assumptions.
2) Draw a free-body diagram of the physical model. How many degrees-of-freedom
does the model have? Apply Newton’s 2nd Law to the free-body diagram to obtain
the mathematical model, i.e., the equation of motion.
3) A feedback control system must be designed. Draw the block diagram of the
feedback control system showing the plant and controller blocks. Sensor and actuator
dynamics are being neglected in this initial investigation.
4) A PID controller is proposed. Draw a Simulink diagram of the feedback control
system. Use Simulink simulations to show how each of the PID control gains, Kp, Kd,
and Ki (proportional, derivative, and integral, respectively), contribute to: rise time,
overshoot, and steady-state error.
5) Pick values for Kp, Kd, and Ki to give a rise time less than 5 s, an overshoot less than
10%, and zero steady-state error.
Example deliverables are shown in Figure 6b which includes a Simulink block diagram for
performing the analysis and several time responses for different prospective derivative gains.
Figure 6b. Satellite antenna tracking problem Simulink block diagram (top) and sample time response
solutions (bottom).
A coding exercise which includes a tangible, hands-on, component is to observe the aliasing
effect in PWM signals. The student is given a micro-controller and tasked with tracking an
analog signal with a PWM equivalent. Through programming of the micro-controller and
observation of the resulting behavior on an oscilloscope, the student can observe the aliasing
effect when the sampling rate is too low and experience the consequences of proper or improper
coding on the physical world. Figure 7 shows example hardware and the graphical coding
scheme which has been used in this studio exercise. The following is a discussion for the
students of the significance of the theoretical significance of the sampling rate and an
introduction to the Nyquist Sampling Theorem.
Figure 7. Simulink-Arduino application 1, hardware (top) and
programming scheme (bottom).
One of the most powerful mathematical results of the digital era is the Nyquist Sampling
Theorem. A sampled signal can be converted back to its original analog signal without any error
if the sampling rate is more than twice as large as the highest frequency of the signal. The
Nyquist Frequency = ½ fs and it is a discrete-time system property. Restated in mathematical
form, if Ts is the spacing between samples and fs = 1/Ts is the sampling frequency, then
theoretically we can convert the samples of an analog signal back into the original signal if fs >
2fhighest, where fhighest is the highest frequency contained in the analog signal. The value 2fhighest is
called the Nyquist rate. fhighest is the highest frequency contained in a signal. The Nyquist rate is
the lower bound of the sampling frequency that satisfies the Nyquist sampling criterion. It is a
continuous-time signal property.
The implications of the Nyquist sampling theorem are nothing short of remarkable! The
process of sampling a signal, manipulating a sequence of numbers that results from sampling to
remove noise or emphasize certain features, for example, and producing an analog output signal
after the manipulations is called Digital Signal Processing (DSP). Band-limited signals (signals
whose highest frequency falls below some finite value) can be reconstructed perfectly from their
samples, as long as the sampling rate is greater than twice the bandwidth of the signal that was
sampled.
What happens if we unfortunately sample a signal too slowly and fail to meet the
requirement of the Nyquist sampling theorem? Aliasing refers to one signal “pretending to be”
another signal when their samples are the same. It is an undesired effect due to undersampling
whereby one signal can masquerade as another. Aliasing is an inevitable, irreversible process
which shifts frequencies. It cannot be completely eliminated, only reduced.
Another exercise in which the student can experience hands-on application of the programing
he or she is learning is coding the speed control of a small DC motor. The student uses proper
coding of a micro-controller, already learned, to achieve desired performance of the electro-
mechanical system. The mechanical response to changes in the coding world keeps the student
engaged in mundane task of learning rules of syntax. Figure 8 illustrates a system level
summary of the components utilized in the exercise.
An electric machine is a device that can convert either mechanical energy to electrical energy
or electrical energy to mechanical energy. An example of mechanical to electrical is a generator.
Conversely, an example of electrical to mechanical is a motor. All practical motors and
generators convert energy from one form to another through the action of a magnetic field.
Magnetic field acts as the medium for transferring and converting energy. Motors, Generators,
and Transformers are ubiquitous in modern daily life. Why?
Electric power is clean, efficient, and easy to control and transmit over long distances. Four
basic principles describe how magnetic fields are used in these devices. A current-carrying wire
produces a magnetic field in the area around it. A time-changing magnetic field induces a
voltage in a coil of wire if it passes through that coil (basis of transformer action). A current-
carrying wire in the presence of a magnetic field has a force induced on it (basis of motor
action). A moving wire in the presence of a magnetic field has a voltage induced in it (basis of
generator action).
Drop a magnet down a copper pipe such as is shown in Figure 9. The magnet “floats” down
the copper pipe defying gravity. There are five fundamental laws of nature demonstrated here.
What are they? See Maxwell’s Equations and Newton’s Laws of Motion and Gravity.
Communication of complex technical concepts in simple terms is the hallmark of an
accomplished scientist and engineer. Explain what you observe to a lay person in a 250-word
document. Organization, grammar, and style are just as important as accurate content.
Students evaluations for the course, as well as evaluations of how the course impacts
courses in the sophomore year (e.g., Dynamics) and in the junior year (e.g., Modeling, Analysis,
and Control of Dynamic Systems) where problem-solving skills and engineering tools
(MATLAB, Simulink, SimMechanics, LabVIEW) are widely applied, are being conducted and
will be reported in future work.
5 Conclusion and Future Work
A pilot, 3-credit, freshman course, called Engineering Problem Solving, is currently being
evaluated to potentially replace the traditional Computer Programming course. The course
focuses on real-world problems and emphasizes two processes: the Engineering Problem Solving
Process and the Engineering System Investigation Process. MATLAB scripts utilizing iterations
and conditional statements are learned, as well as Simulink graphical programming. The
Arduino microcontroller is used with the MATLAB Simulink real-time code generation to
understand aliasing and pulse-width modulation and perform real-time speed control of a
brushed DC motor. Symbolic mathematics using MATLAB MuPAD is introduced, as is
measurement using LabVIEW with the myDAQ National Instruments device. The pilot course
is now in its second offering to 2 sections and will be expanded to possibly include all freshman
engineers next year. Already students who have taken the course have expressed approval as
they are using what they have learned in their sophomore Statics, Dynamics, and Strength of
Materials courses. Formal evaluations will be conducted as the pilot course becomes a regular
course for freshman engineers.
Bibliography
1. A High-School Level Course in Feedback Control, Jorge Cortes and William Dunbar, IEEE Control Systems
Magazine, June 2007, pages 79-89.
2. Design of an Introductory MATLAB Course for Freshman Engineering Students, Darryl Morrell, ASEE
2007, pages 12.458.1-12.458.7.
3. An Introduction to Technical Problem Solving with MATLAB v.7, Jon Sticklen and M. Taner Eskil, Oxford
University Press, April 2006.