Procedia Computer Science 3 (2011) 853–858 Procedia Computer Science 00 (2010) 000–000
Procedia Computer www.elsevier.com/locate/procedia Science www.elsevier.com/locate/procedia
WCIT-2010
Engineering simulation with MATLAB: improving teaching and learning effectiveness Dogan Ibrahim a * a
Near east University, Faculty of Engineering, Department of Biomedical Engineering, Lefkosa, Cyprus
Abstract Laboratories are the integral part of any engineering course. They provide students with exposure to real engineering instruments and devices. They can also provide opportunities for students to learn to work together in groups. This paper describes the various simulation tools that can be used in virtual engineering laboratories. The type of simulation environments and their advantages and disadvantages are described briefly together with examples of some commercially available simulator programs. In addition, the use of the MATLAB simulation package in engineering education is shown by an important experiment taken from the field of electrical and electronic engineering. c 2010 Published by Elsevier Ltd. Selection and/or peer-review under responsibility of the Guest Editor. ⃝ Keywords: Simulation; engineering simulation; Matlab; engineering teaching
1 Introduction Laboratories are the integral part of any engineering course. They provide students with exposure to real engineering instruments and devices. They can also provide opportunities for students to learn to work together in groups. Laboratories can build on the concepts covered and learned in the classroom. After students have learned the theory in the class, they will be better prepared to carry out experiments in laboratories and learn how the various instruments, devices, and equipments behave in real life environments. In addition to their traditional uses of reinforcing concepts already presented in lectures, some concepts are best learned through laboratory exploration, such as error analysis, fluctuations, uncertainty, noise and so on. Laboratories have given central and distinctive roles in science and engineering education, and science educators have suggested that there are rich benefits in learning from using laboratory activities. Despite the many real advantages of laboratories, they have some serious disadvantages. Perhaps the biggest disadvantages of engineering laboratories are the cost of setting-up a laboratory, the cost of maintaining an existing laboratory, and perhaps more importantly the fact that engineering is an evolving field, and laboratories constantly need to be updated with new equipment. Laboratories are equipped with real working instruments and devices and such equipment have limited lifetimes, thus needing repair and maintenance, especially as the equipment get older. __________ * Dogan Ibrahim. Tel.: +90 2922236464; fax: +90392 2236627. E-mail address:
[email protected].
c 2010 Published by Elsevier Ltd. 1877-0509 ⃝ doi:10.1016/j.procs.2010.12.140
854
D. Ibrahim / Procedia Computer Science 3 (2011) 853–858 Dogan Ibrahim / Procedia Computer Science 00 (2010) 000–000
As a solution to the problems associated with laboratories, many institutions tend to use virtual laboratories in the form of computer simulation. For example, the behavior of a motor can easily be modeled and analyzed on a personal computer (PC) without the need to use any real motor or associated hardware. The simulation is usually a computer program running on the PC and students can copy and use the program on many different PCs, thus resulting in a relatively lower cost. The cost of setting-up a virtual laboratory is much less than the cost of setting-up real laboratories. In addition, there are no maintenance or repair costs. The laboratory environment can be upgraded by simply upgrading the existing simulation programs to newer software versions. Virtual laboratories also have the added advantages that they can be used in distant engineering education courses where students can be supplied with copies of the simulation programs so that they can perform various experiments in the comfort of their homes at anytime. As shown in Fig. 1, engineering simulation can be carried out using two different approaches: either writing a simulation program from first principles, or using a commercially available simulation software package. ENGINEERING SIMULATION
Writing a Program
C, PASCAL, BASIC
Using a Package Program
General Purpose
Excel,MATLAB,MatriXx
Dedicated
Spice, CarSim,SIMPACK,CHEMCAD
Fig. 1 Engineering simulation options Writing a simulation program from first principles is not an easy task and requires considerable programming skills and engineering know-how. A simulation program is usually developed using a high-level programming language such as C, PASCAL, or BASIC. Writing a simulation program has the following advantages and disadvantages: x x x x x
Requires excellent programming skills Takes long time to develop and test Very cheap as the existing compilers can be used for development Source code is available, so it can be modified and upgraded at no cost The program is usually written for a dedicated simulation problem
The other option of simulating an engineering problem is to use a commercially available simulation package. This option can be analyzed in two headings: general simulation packages, and dedicated simulation packages. General simulation packages can be used to simulate all kinds of engineering problems from all branches of engineering. Some examples of general simulation packages are Excel [1], MATLAB [2], MatriXx [3], and so on. The advantages and disadvantages of general simulation packages are: x x x x x
Moderate cost Programming skills are not required Quick to simulate and get results Model of the system to be simulated is required and this may be difficult to derive The source code is not available and hence it is not possible to modify/upgrade the simulation package
855
D. Ibrahim / Procedia Computer Science 3 (2011) 853–858 Dogan Ibrahim / Procedia Computer Science 00 (2010) 000–000
Dedicated simulation packages are used to simulate only specific engineering problems. For example, commercial simulation packages are Spice [4], Workbench [5], QuickCircuits [6] and so are used to simulate electrical and electronic circuits, CarSim [7] is used to simulate cars and light trucks, BikeSim [7] is used to simulate motorcycles and scooters, SIMPACK [8] is used to simulate mechanical and mechatronic systems, CHEMCAD [9] is used to simulate chemical systems, OPNET [10] is used to simulate computer network systems, and so on. The advantages and disadvantages of dedicated simulation packages are: x x x x
Very expensive Very fast to simulate and get results Model of the system to be simulated is not required. The system can usually be described in visual form (e.g. an electronic circuit can be built and simulated using GUI tools) The source code is not available and hence it is not possible to modify/upgrade the simulation package
This paper describes the various simulation tools that can be used in virtual engineering laboratories. The type of simulation environments and their advantages and disadvantages are described briefly together with examples of some commercially available simulator programs. In addition, the use of the MATLAB simulation package in engineering education is shown by an important experiment taken from the field of electrical and electronic engineering. The experiment shows how a tuned resistor-inductor-capacitor (RLC) circuit can easily be modeled and simulated using the MATLAB engineering simulation and analysis package, without having to use real expensive RLC components, oscilloscopes, and power supplies. 2.
Example Simulation
An example engineering simulation is given in this section to show the importance of simulation and also to show how easily simulation can be carried out using a commercial simulation package such as MATLAB. In this example, a tuned RLC circuit is modeled and then its behavior is simulated. Fig. 2 shows the example tuned circuit simulated in this example. The circuit consists of a resistor (R), an inductor (L), and a capacitor (C). A D.C. voltage is applied to the circuit and the voltages across each component and the current through the circuit can easily be simulated and its response can be plotted as a function of time. Before the circuit can be simulated it is necessary to derive its mathematical model. The mathematical model of the tuned circuit in Fig. 1 can be derived as shown below.
Fig. 2 Simulated circuit In this example we shall attempt to model the circuit using the State Equations which are commonly used in describing the mathematical models of most types of systems. The voltage across the inductor is given by:
VL
L
di dt
(1)
856
D. Ibrahim / Procedia Computer Science 3 (2011) 853–858 Dogan Ibrahim / Procedia Computer Science 00 (2010) 000–000
We have to eliminate VL since it is not a state variable. Then,
L
di dt
V VR VC
(2)
Or, by eliminating VR we get,
V Ri VC L
di dt
(3)
Similarly, the capacitor current is given by:
i
Or,
C
dVC dt
dVC dt
(4)
i C
(5)
Using equations (3) and (5) one can write the state equations as:
d ªi º dt «¬VC »¼
ª R / L 1 / L º ª i º ª1 / Lº V « 1/ C 0 »¼ «¬VC »¼ «¬ 0 »¼ ¬
(6)
Equation (6) can be expressed in the standard state equation matrix form as: x.
x y
Ax Bu Cx Du
(7) (8)
Where,
ªi º » ¬VC ¼
x is the vector «
ª R / L 1 / Lº 0 »¼ ¬ 1/ C ª1 / L º B is the matrix « » ¬ 0 ¼
A is the matrix «
Taking current i as the only output,
ªi º ¬ 0¼
Y is the vector « »
D. Ibrahim / Procedia Computer Science 3 (2011) 853–858
857
Dogan Ibrahim / Procedia Computer Science 00 (2010) 000–000
ª 1 0º » ¬ R 0¼ ª 0º D is the matrix « » ¬ 0¼ C is the matrix «
We can now simulate the circuit using the MATLAB simulation package. Fig. 3 shows the MATLAB function (tuned) developed to simulate the circuit and plot the current in the circuit. The component values can easily be changed and the circuit can be re-simulated. In this example, the following component values were chosen for the simulation: R = 10 Ohms, C = 1nF, L = 10μH function m = tuned(R,L,C) A = [-R/L -1/L; 1/C 0]; B = [1/L; 0]; C = [1 0; 0 0]; D = [0; 0]; system = ss(A,B,C,D); [y,t] = step(system); plot(t, y); title('Tuned circuit step current response (i)'); Fig. 3 MATLAB simulation function Figure 4 shows the time response obtained from the simulation.
Fig. 4 Simulation output
858
D. Ibrahim / Procedia Computer Science 3 (2011) 853–858 Dogan Ibrahim / Procedia Computer Science 00 (2010) 000–000
4.
CONCLUSIONS
Engineering simulation is one of the most important tools in engineering education. Although simulators do not replace real physical laboratories they can be very useful in teaching the working principles of various engineering instruments and devices. The importance of engineering simulation is shown in this paper with an example of simulating a tuned electrical engineering circuit using the MATLAB simulation package. References 1. J. Walkenbach, (2007). “Excel 2007 Bible”, John Wiley & Sons. 2. B. Hahn, B., and D. Valentine. (2009). “Essential Matlab for Engineers and Scientists”, Academic Press. 3. “MatriXx Software Suite”, National Semiconductors, web site: http://www.ni.com [Accessed on: 2nd May 2010] 4. W.P. Tuinenge. (1995). “Spice Circuit Simulation Analysis”, Prentice Hall Inc. 5. M.P. Horsey. (1997). “Electronics Projects Using Electronics Workbench”, Newnes. 6. “QuickCircuits User Guide”, web site: http://www.quickcircuits.com [Accessed on: 2 nd June, 2010] 7. “CarSim Simulator”, web site: http://www.carsim.com/products/index.php [Accessed on 2nd May, 2010] 8. ”SIMPACK User Guide”, web site: http://www.simpack.com/industrial_sectors.html [Accessed on: 3rd July 2010] 9. ”CHEMCAD Chemical Engineering Simulator”, web site: http://www.chemstations.com [Accessed on: 2nd July 2010]/ 10. ”OPNET Network Simulator User Guide”, web site: http://www.opnet.com/ [Accessed on 1 st June 2010]