Matlab Gui Application for Teaching Electronics

The Electrical Engineering (EE) Department at the University Arab Emirates (UAE) University incorporates numerous software tools in teaching the diverse electrical engineering (EE) courses imparted at undergraduate and graduate level. The most common being the use of MATLAB, Simulink and LabView, in addition to standard circuits, electronics, and power systems software packages such as OrCAD, MultiSim and PSCAD. Instructors also make use of free available online JAVA applets that apply to specific advanced EE courses such as signals and systems, electromagnetics, antenna engineering, among others. The variety of tools used in each EE course makes it difficult for students to learn a new tool or program for each course. This suggests that MATLAB can be used as a common platform for all courses given its rich library and available tools. Student evaluations over the past years have reflected favourably on the use of MATLAB tools as a valuable support in graphical visualization, numerical evaluation and modelling tasks in the diverse EE course. Most books published nowadays in the various EE subjects include MATLAB exercises and applications in each chapter. The use of these software tools is intended to enhance student appreciation of theoretical concepts and as support tools for hands-on analysis and design experience. Most EE students use the limited MATLAB/Simulink Student Version which does not include many of the needed MATLAB toolboxes. As a result students have to work on campus in order to access the specialized toolboxes. Developing GUI-based applets offers the advantage of providing more independent MATLAB-based tools for use by students on their own Laptop anywhere. Numerous educators have been developing software applets in different electrical engineering subjects. Such tools are indispensable in helping students better understand basic scientific and engineering concepts through a user-friendly interactive environment that also counts with an adequate help menu to guide students through the application. (Azemi & Stook, 1996) utilized MATLAB in undergraduate electric circuit courses. They focused on features of MATLAB that have not been adapted by other educators before. They worked on generating analytical solutions with the Symbolic Math toolbox, creating interactive simulations with user interface control, and the use of MATLAB Compiler and MATLAB C Library to produce stand-alone applications. They presented examples illustrating the above mentioned features and made the code available on their website.


Introduction
The Electrical Engineering (EE) Department at the University Arab Emirates (UAE) University incorporates numerous software tools in teaching the diverse electrical engineering (EE) courses imparted at undergraduate and graduate level.The most common being the use of MATLAB, Simulink and LabView, in addition to standard circuits, electronics, and power systems software packages such as OrCAD, MultiSim and PSCAD.Instructors also make use of free available online JAVA applets that apply to specific advanced EE courses such as signals and systems, electromagnetics, antenna engineering, among others.The variety of tools used in each EE course makes it difficult for students to learn a new tool or program for each course.This suggests that MATLAB can be used as a common platform for all courses given its rich library and available tools.Student evaluations over the past years have reflected favourably on the use of MATLAB tools as a valuable support in graphical visualization, numerical evaluation and modelling tasks in the diverse EE course.Most books published nowadays in the various EE subjects include MATLAB exercises and applications in each chapter.The use of these software tools is intended to enhance student appreciation of theoretical concepts and as support tools for hands-on analysis and design experience.Most EE students use the limited MATLAB/Simulink Student Version which does not include many of the needed MATLAB toolboxes.As a result students have to work on campus in order to access the specialized toolboxes.Developing GUI-based applets offers the advantage of providing more independent MATLAB-based tools for use by students on their own Laptop anywhere.Numerous educators have been developing software applets in different electrical engineering subjects.Such tools are indispensable in helping students better understand basic scientific and engineering concepts through a user-friendly interactive environment that also counts with an adequate help menu to guide students through the application.(Azemi & Stook, 1996) utilized MATLAB in undergraduate electric circuit courses.They focused on features of MATLAB that have not been adapted by other educators before.They worked on generating analytical solutions with the Symbolic Math toolbox, creating interactive simulations with user interface control, and the use of MATLAB Compiler and MATLAB C Library to produce stand-alone applications.They presented examples illustrating the above mentioned features and made the code available on their website.
They also discussed student response to use of the developed MATLAB software package in circuits analysis.(Andreatos & Michalareas, 2008) developed a MATLAB-based application for e-assessment in an introductory analog electronic design course.The application included separate MATLAB GUI interfaces for students and instructor.The applet was intended to help students design a transistor amplifier and in parallel provide an automated qualitative and quantitative assessment tool for instructors.The added assessment tool aimed at ensuring that students engage in actual circuit evaluation rather than making random guesses.(Andreatos & Zagorianos, 2009) also presented a MATLAB-based GUI tool for teaching Automatic Control Systems.The tool is demonstrated using a step-by-step exercise on a typical aircraft control system.(Attia, 1995(Attia, , 1996) ) designed AC circuits and electronics teaching tools using MATLAB to teach circuit theory, filter design, random processes, control system and communication theory.The tools employ matrix functions for experimental data analysis as well as graphical features to display the frequency response of amplifiers and illustrate the principles and concepts of semiconductor physics.The circuits MATLAB exercises cover sinusoidal ac analysis, network characteristics and frequency response.The interactive programming and versatile graphics of MATLAB are especially effective in exploring some of the characteristics of devices and electronic circuits.(Rajashekar & Bovik, 2000) presented a suite of user-friendly interactive Digital Signal Processing (DSP) demonstration modules using MATLAB.Their focus was on providing visualization tools that emphasize the intuitive aspects of DSP algorithms.A MATLAB/GUI based educational tool was developed by (Koç & Aydoğmus, 2009) for power system fault calculations.This software provides a user-friendly interface to help the student understand the symmetrical components and fault calculations.The tool allows students to choose one of four fault options for which fault current and voltage calculations are performed.The GUI provides a graphical output representation of currents and voltages.For such application, the instructor expects students to check their answers with hand calculations.The EE Department at UAE University offers two circuits courses, namely, Electric Circuits I (ELEC 320) and Electric Circuits II (ELEC 325).The Electric Circuits I course runs through both semesters of the academic year.It focuses on the analysis of basic DC and AC electric circuits.Among the topics covered in this introductory course are operational amplifier (OP-AMP) circuits.The average student population each year ranges from 25 to 30 students.At the beginning of the course, students have background knowledge of basic mathematics, physics, and MATLAB programming skills needed throughout the course.One of the most significant course design objectives is the development of a tool for achieving improved learning process.Today, during the teaching process of the fundamentals principles of Electronics, the emphasis is not given on tedious calculations, but rather on offering engineering education, by utilizing efficient software tools.Computer-aided applications are appropriate tools, because they improve the efficiency of learning.In this chapter, basic electronic and electric circuits are investigated using an interactive MATLAB GUI program applet (MATLAB, 2010).The developed comprehensive and user-friendly tool called Electronics Teaching Assistant (abbreviated herein as ETA) can perform typical operational amplifier (OP-AMP) gain calculations and displays analog graphs for input and output currents and voltages in a user friendly MATLAB environment.Section 2 will address the operational amplifier and basic configurations used in teaching OP-AMP circuits.Section 3 briefly discusses the voltage and current divider circuits.Section 4 explains in detail the development of the GUI tool including code used and input and output windows.Conclusions are then presented in Section 5.
The authors intend to develop more GUI-based applets for numerous circuits and electronics subjects with the objective of making student learning of basic electrical topics fun and interactive.Proper assessment of student learning is followed each semester in line with the ABET outcome assessment process.

Operational amplifiers
Operational amplifiers (op amps) typically have 2 inputs, a positive (non-inverting) input and a negative (inverting) input.A signal fed into the positive (non-inverting) input will produce an output signal which is in phase with the input.If the signal is fed into the negative (inverting) input, the output will be 180 degrees out of phase when compared to the input.The following sub-sections represent an attempt to give you the basic understanding of OP-AMP configurations.None of the power supply connections are shown.Most OP-AMP circuits used in audio applications use a ±15 volts power supply.They can also be used with a single ended supply (no negative voltage).The diagram below (Fig. 1) shows the OP-AMP symbol.An input voltage, V in is applied to the input resistor, R 1 .The OP-AMP amplifies the input voltage it receives and inverts its polarity, producing an output voltage, V out .This same output voltage is also applied to a feedback resistor, R 2 , which is connected to the amplifier input along with R 1 .The OP-AMP itself has a very high voltage gain.As a result, the junction of the two resistors, which is also the OP-AMP input, must be virtually at ground potential.A non-zero input voltage will be amplified so that the output voltage would try to exceed its electronic limits.At the same time, the OP-AMP requires an extremely small input current to operate.Therefore, the input current (Vin/R 1 ) must be the same as the feedback current (V out /R 2 ).This implies that the effective gain of the circuit with feedback in place is simply the resistance ratio, R 2 /R 1 .With such configuration, we can obtain accurate results if we use precision resistors, and yielding a gain of:

Non-inverting amplifier
Fig. 3 shows a non-inverting OP-AMP circuit.In this circuit, the input signal is effectively used as the reference voltage at the "+" input, while the "-" input is indirectly referenced to ground.In order to keep the two input voltages the same, the OP-AMP must set V out to whatever voltage is required to make the feedback voltage to the "-" input match the input voltage to the "+" input.

Fig. 3. The non-inverting configuration
Since R 2 and R 1 form a voltage divider, the feedback voltage will be: The gain of this circuit becomes:

Voltage follower
This is a special case of the non-inverting amplifier with R 1 = ∞ and R 2 = 0. Fig. 4 shows the voltage follower circuit.

Fig. 4. The voltage follower
For the circuit shown in Fig. 4, and using equation ( 3), one can easily find: This is a very useful circuit, because the input impedance of the OP-AMP is very high, giving effective isolation of the output from the signal source.The circuit draws very little power from the signal source, avoiding "loading" effects.This circuit in general is a useful first stage.The voltage follower is often used for the construction of buffers for logic circuits.

Summing amplifier
This is special case of the inverting configuration with more than one input as shown in Fig. 5.

Fig. 5. The summing amplifier
This circuit will amplify each individual input voltage and produce an output voltage signal that is proportional to the algebraic "SUM" of the two individual input voltages V in1 and V in2 .We can also add more inputs if required.The point of using an OP-AMP to add multiple input signals is to avoid interaction between them, so that any change in one input voltage will not have any effect on the other input.This is because the input signals are effectively isolated from each other by the "virtual earth" node at the inverting input of the OP-AMP.
For the circuit shown in Fig. 5, the voltage at the output is given by: A direct voltage addition can also be obtained when all the resistances are of equal value (i.e.R F = R 1 = R 2 ): ( )

Differential amplifier
The circuit of a differential amplifier is shown in Fig. 6.Apply the superposition principle to obtain the gain expression: 1 For R 2 = R 4 , the output will be: ( ) Finally, for R 2 = R 1 one can obtain the exact difference of V in2 and V in1 : www.intechopen.com

Basic electric circuits
This section explains briefly two basic circuit configurations of general use in electronic circuit analysis.

Voltage divider
The two resistor voltage divider, shown in Fig. 7, is used often to supply a voltage different from that of an available battery or power supply.In practice, the output voltage depends upon the resistance of the load it drives.Note here that R 2 includes also the load resistance.

Graphical MATLAB-based tool
A graphical user interface tool was designed using the Matlab GUIDE environment which greatly simplifies the process of building and developing GUIs.GUIDE Layout Editor allows the user to populate a GUI by clicking and dragging GUI components namely, axes, panels, buttons, text fields, sliders into the layout area.Moreover, from the Layout Editor, the user can size the GUI, modify component look and feel, align components, set tab order, view a hierarchical list of the component objects, and set GUI options.GUIDE automatically generates a program file containing MATLAB functions that controls how the GUI operates.This code file helps initialize the GUI and contains a framework for the GUI callbacks; the routines that execute when a user interacts with a GUI component.The MATLAB Editor should be used to add code to callbacks in order to perform the required actions [MATLAB Creating Graphical User Interfaces, 2004].

%----To open Electric Circuits window -
In order to show the logo and background images and their axes, the code is written under Opening Function.Axes function is used to determine which axes the image should display followed by imshowfunction.

Fig. 9. Electronics Teaching Assistant
The ETA_Op_AMP_Circuits window shown in Fig. 10 is designed to allow the user choose between different types of circuits through a pop-up menu.The user can also visualize the circuit diagram when updated according to the user choices.This diagram is presented on Circuit Axes which is located on the top right hand.Input and output parameters vary according to circuit types.All circuit components are first laid out then their values are defined.For example, the R 1 and R 3 text located in the background of R 1 has its visibility property set to off.Once the user selects the differential amplifier circuit, the text becomes visible and R 1 text will become invisible.The relationship between input and output voltage (i.e. the gain) is plotted on Vin_Vout_Axes which is located underneath Circuit Axes.Three push buttons are presented namely; Calculate, Reset and Main.The calculate button computes gain(s) and plots input and output voltages.The Reset button clears the contents of input and output texts and axes.The Main button opens the main window and closes current window.Figures 14 and 15 show the functions of the inverting and non-inverting amplifier circuits, respectively.The inputs for these circuits are named V in (V), R 1 (Ohm) and R 2 (Ohm).The inputs and outputs are represented as sinusoidal waves and the relationship between them (i.e.gain) can be plotted.The red waveform represents the input of the amplifier while the green waveform represents the output.The value of the gain and V out are displayed numerically.The Summing Amplifier function is shown in Fig. 16.The inputs areV in1 (V), V in2 (V), R 1 (Ohm), R 2 (Ohm) and R F (Ohm) while the output is V out (V).The Differential Amplifier function is shown in Fig. 18.Parameters V in1 , V in2 , (R 1 , R 3 ), and (R 2 , R 4 ) are the inputs of the differential amplifier circuit, while V out is the output.This ETA program has the ability to check if the clipping phenomena is occurring and notifies the user by displaying a warning message as illustrated in Fig. 19.Moreover, it checks user inputs; if the user unintentionally enters a non-numeric value, the error message will be shown as Fig. 20.The error message will be display if the user attempts to enter a voltage input that exceeds power supply voltage values (-15 V, 15V) as shown in Fig. 21.In case the user enters maximum input voltage, a warning message will be shown as shown in Fig. 22.When the voltage divider circuit is selected from the menu, the circuit's schematic is displayed on axes.The inputs of this circuit are: Vin (V), R1 (Ohm) and R2 (Ohm).The Calculate, Reset, and Main buttons perform functions as described earlier.Fig. 25 shows the function of the current divider circuit.When the current divider circuit is selected from the menu, the circuit's schematic is displayed on axes.The inputs of this circuit are: Is (A), R1 (Ohm) and R2 (Ohm).The values of I1 and I2 are displayed.The Calculate, Reset, and Main buttons perform functions as described earlier.

Conclusion
This chapter presented a user-friendly interactive MATLAB-based GUI tool for teaching basic electrical OP-AMP circuits.The programming code for the GUI tool development was also addressed in addition to explanation of input and output parameters needed for different types of OP-AMPs.In addition, MATLAB has a rich collection of mathematical functions and tools to compute and visualize data for different circuit applications.Students can use OrCAD PSpice to compare with the developed applet results.The interactive and friendly nature of MATLAB and its immediate graphing tools are indispensable for helping electrical engineering students achieve a better understanding of basic concepts and principles of semiconductor fundamentals and other electrical topics.

Fig. 16 .
Fig. 16.Running the Summing Amplifier GUI TheVoltage Follower function is shown in Fig.17.This circuit has only one input V in (V) with unity gain implying that the input and output values are equal.The V in waveform does not appear because V out = V in .

Fig. 20 .
Fig. 20.The Input is not a Number Warning Message

Fig. 22 .
Fig. 22.The Maximum input chosen Warning Message