{'fraction_non_alphanumeric': 0.02805635882606288, 'fraction_numerical': 0.0067064541930720485, 'mean_word_length': 4.9299525720539945, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A Virtual-Lab Tool for Teaching the Fundamentals of a DC Motor-Generator Operation using Excel-VBA

This paper presents an Excel-VBA implementation tool for teaching some fundamentals of rotating electrical machines in undergraduate and graduate level, particularly for electrical engineering curriculum. The basic concepts of a Direct Current (DC) motor operation and a DC generator have been simulated for several operational scenarios. The simulation results have been compared to mathematical models implemented in the Matlab/Simulink© environment using the 4 Runge-Kutta method for numerical solution of the differential equations that correspond to the dynamic behavior of the electrical machine. In addition, some experimental results have shown a good approximation between the simulation results obtained from the proposed virtual tool and the experimental data. Therefore, the present development is capable of serving as a potential virtual lab for a better understanding of rotating electrical machines concepts, particularly for undergraduate courses.


INTRODUCTION
The study of rotating electrical machines is a huge challenge for many students, since it requires a good background on advanced calculus and electromagnetics [1]. In many cases, engineering and engineering technology students lack the required background, and they have difficulties to learn these subjects. Even for graduate level, the mathematical concepts belong to Direct Current (DC) and Alternating Current (AC) rotating machines are quite complex to understand. In this sense, the dynamic behavior of the electrical motors is governed by different type of equations, such as mechanical, electrical and thermal conditions. Other works have addressed this kind of problem, particularly in the field of electrical machines [2]. In this work, the authors have mentioned the fact that it is not possible to understand the depth of some concepts without exploring the practical aspects of electrical machines. As cited by a recent work [3], the economic limitations for the acquisition of material and the limitations of laboratory availability makes some experimental practices be carried out in a limited duration and controlled extension within excessive rigid sessions, which means that the students have a restricted contact with the practical issues related to the learning of electrical machines concepts. As cited by [4], usually the engineering experiments are carried out in small groups of students and often at specified times, in fixed laboratories and with custom lab benches, thus, the use of computer tools are emerging in the field of education, such as the virtual laboratories. For over a decade, other researchers have demonstrated the relevant use of such tools in the education environment. In [5], for example, the authors have described the importance of the development and use of the simulation and remote labs for improving the students learning experiences. They have also mentioned that the simulations play a vital role in engineering education, especially considering laboratory exercises. In the work published by [6], the authors have presented a critical overview of existing concepts and technologies in the field of virtual laboratories, being possible to identify some trends, advantages and drawbacks. The researchers have shown that virtual systems provide a cost-efficient way for schools and universities and several students can use the same virtual equipment at the same time. On the other hand, this work cited a drawback related to this kind of solution, being often time-consuming to configure. However, a simple software tool, such as the solution proposed in this paper could be very useful and user-friendly, since MS-Excel is well known by the general public, including engineering students, for example. In [7], the authors have proposed a virtual laboratory for supporting high school learning activities and a survey applied to 40 students have show that 90% of them said that virtual laboratory is ease to use. In [8], for example, the authors have presented a virtual learning laboratory environment for undergraduate mathematics education in some real-world applications spanning signal processing, data science and analytics with good results that can enhance students'learning. In the engineering field, virtual and remote laboratories are becoming powerful tools that let the students better understand concepts and simulate several operational conditions similar to those found in a real equipment. More particularly, the virtual laboratories allow the students to learning no only regular, but also fault scenarios [9], [10] and [11]. For electrical engineering simulations, there are some works ( [2], [3], [12], [13], [14], [15]) that have addressed electrical machines and/or the behavior of the rotating magnetic fields in virtual environments. In addition, the use of Microsoft Excel Solver and Excel Visual Basic for Applications (VBA) have been demonstrated an efficient and interesting tool for simulation in distinct knowledge fields. In [16], for instance, the authors have used an Excel VBA-based education module for simulation and energy optimization of spray drying process, widely used in chemical, ceramic, food and pharmaceutical industries for manufacturing of high-volume, as well as high-value parciculate products. In [17], the researchers have addressed the application of the Microsoft Excel Sover tool in the optimization of distillation sequence problems. In [18], Excel-VBA has used for teaching hydraulics of pipe flow in engineering curricula and in [19], Excel-VBA has been applied for 2-dimensional finite-element (FE) stress analysis. In this sense, the present research proposes the use of Excel-VBA for teaching the fundamentals of a DC motor running at several operational conditions. As cited by [18], for example, a virtual tool implemented in Excel-VBA is very similar to MS Excel's buit-in worksheet functions, being possible to obtain real-time solutions and the user is able to view the results immediately after changing any parameter of the system. As cited by [16], the familiarity with Excel interface and the rich graphical user interface of developed Excel VBA enable students to accomplish the requested tasks independently in a short time. Therefore, the proposed Excel environment allows the student to obtain an user-friendly operational interface and the results quickly. The operational scenarios simulated with a DC machine, running as a motor and as a DC generator, have been compared to a mathematical model implemented in the Matlab/Simulink software. The developed tool has been demonstrated good results and can be used as a potential virtual lab for a better understanding of rotating electrical machines concepts.

DC Motor Mathematical Model (Separately Excited DC motor)
Over the last century, many articles and textbooks have addressed the design, theory and the operation of DC machines ( [20], [21], [22] and [13]) . The dynamic characteristics of this electrical machine are usually solved by using Laplace transformation techniques [20]. Essentially, this type of motor has two windings, the field winding (LFF) and the armature (LAA) coil, as shown in Fig.  1. Fig. 1: Equivalent circuit for separate field and armature excitation [20] Both windings are feed with a DC supply, or the field may be created by permanent magnets. The called main flux is those produced by the field winding i f . In this machine, the current flowing through the armature coil i a interacts with the main flux to produce the rotational force (torque). A simulation model of a separately excited DC motor was built using Excel-VBA. In matrix form, the field and armature voltage equations of this machine can be written as [20]: Where L F F and L AA are the self-inductances of the field and armature windings, respectively, and ρ is the short-hand notation for the operator d/dt. The voltage equations of a DC motor are also given by: Where R f =r f x +r f and capital letters are used to denote steadystate voltage and currents. In this work, the resistance value of r f x + is set to zero, since this parameter is related to the use of an external field rheostat and this research employed a DC supply for this case. The torque and rotor speed of the DC motor are related by (4): Where J is the inertia of the rotor and, in some cases, the connected mechanical load. As described by [20], the load torque T L is positive for a torque, on the shaft of the rotor, which opposes a positive electromagnetic torque T e . The constant B m is a damping coefficient associated with the mechanical rotational system of the machine and ω r is the rotor speed of the rotor. In this paper, equations 2, 3 and 4 are used to simulate a separately DC motor and/or generator as shown in section 4. In the next section, the development of the virtual lab environment is presented.

The Graphical Interface Development
In the present work the DC electrical machine mathematical model has been implemented using Excel Visual Basic for Application (VBA) environment. In addition, the graphical interface has been built using the activeX controls on a worksheet, such as text box, command button, option button, scroll bars, among others. In Fig.2 it is possible to observe the main interface used to set up the DC motor simulation parameters. In this interface, the student can easily set up the electrical parameters of the motor, such as the r f , r a , armature and field voltage levels and other machine parameters like armature inductance, inertia of the rotor, damping coefficient, initial load torque and mutual inductance. By using the red command button, labeled "Simulation Parameters and Results", it is possible to navigate to the simulation results interface, as shown in Fig.3.
It should be noted that, the electrical parameters and some mechanical values, such as the speed (rpm) and the load torque (N.m) are arranged in such a way that allow the student to better understand their connection to the equivalent electrical circuit (Fig. 1). In Fig.2, the student can set up the simulation parameters such as the start time, stop time and the simulation step. Moreover, it is possible to modify the load torque during simulation, the armature voltage level and the field voltage level. These values can be easily adjusted by entering new values in the text box components. In Fig.  2. the students can monitor and observe the simulation results using graphic components of the Excel software, thus, in a very intuitive visualization. Finally, by clicking on the orange command button, labeled "Motor DC parameters", the user will return to the previous screen (Main interface).In Fig.4, the student has the possibility to debug the simulation results for each step simulation.

The DC motor mathematical model implementation
The mathematical model of the DC machine has been built using the 4 th order Runge-Kutta (RK4) numerical integration routine, since this kind of solution provides an acceptable tradeoff between accuracy and computational cost ([23]- [24]). For simulation purposes, equation (3) and (4) have been rewritten respectively as fol- lows, in order to solving the initial value problem for each ordinary differential equation (ODE): As cited by [25], the RK4 is an interesting numerical solution for differential equations, thus, in the present research RK4 has been applied to solve equations (5) and (6). The RK4 method is given by the following equations: Where the slope approximations are given by: Figures 5 and 6 shows a piece of code in VBA for calculating i a and ω r using RK4 method. In the present study, the step h has been set up to 0.001s.

SIMULATION RESULTS AND DISCUSSION
In this section the simulations results are presented and discussed for a separately excited DC machine running as a motor and generator. For all simulation scenarios, the DC machine has the parameters shown in Table 1. For each case, the simulation results have been compared to the DC machine mathematical model (equations 5 and 6) simulation implemented in the Matlab/Simulink©. For this purposes, the differential equations have been modeled using Laplace Transform functions, as shown in Fig. 7. In this work, the following operational scenarios have been carried out and simulated: i-) DC machine running as a motor and subjected to constant torque from start-up; ii-) DC machine running as a motor with load torque variations; and iii-) DC machine running as a generator with a constant resistive load.

Simulation Results for a DC machine running as a motor
The first two simulations have been carried out for a DC machine configured as a motor. For the first scenario, the DC machine has been configured as a motor which has been started without load torque.  Fig.8, it is possible to observe a good approximation between the present virtual lab results and those obtained from the mathematical model implemented in the Matlab/simulink©. In Fig. 9, the armature current simulated with both models shows a good approximation. It is also possible to note in Fig. 9 some numerical results obtained with the same Runge-Kutta (RK4) numerical integration routine. In Fig.11 it is possible to observe, during the start of the DC motor, the integration values on each step using the RK4 routine and the approximation between the values obtained during simulation.

Simulation Results for a DC machine running as a generator
The final simulation has been carried out for a DC machine set up as a DC generator. A load resistance R L = 50 Ω has been connected to the armature terminals and several speed and field voltages have been tested. Table 2 shows the results obtained using the Excel-VBA model and the one implemented in the Matlab/Simulink©.

Experimental results for a DC machine running as a generator
An additional investigation has been carried out using some experimental data. Fig. 15 shows the experimental setup used for performing tests with DC machine running as a generator. In this case, DC machine has been driven by an induction motor (AC motor) and a load resistance has been connected to the armature terminals. The armature voltage has been evaluated for different field voltage levels and speed. In Table 3, for example, it is possible to observe a good approximation between voltage levels obtained for the present virtual lab tool and those results obtained from the experimental setup.

CONCLUSION
This paper presents the development of a virtual lab tool for teaching the fundamentals of a DC rotating machine. The lab tool has been implemented using Excel and Visual Basic for Applications (VBA) environment. The graphical interface (screens) has been built using the active X controls on a worksheet and VBA has been applied to model the mathematical equations of a separately excited DC machine. The main equations have been implemented using the Runge Kutta numerical integration routine and several operational conditions have been carried out. The main interface allow students to set up the main parameters of the electrical machine and the simulation parameters are configured in other screen. It is possible to easily navigate between the screens. The machine has been set up as a motor and as a DC generator, being possible to achieve good simulation results using the present virtual tool and the same mathematical model implemented in the Matlab/Simulink software. Moreover, some experimental tests have shown a good approximation between the simulation results obtained from the present lab tool and those related to the experimental tests. Therefore, the authors understand that the present development is capable of serving as a potential virtual lab for a better understanding of rotating electrical machines concepts, particularly for undergraduate courses.
Finally, the authors are conducting new studies, in order to develop new resources in the present VBA tool, like the scenarios for a speed or position control of the DC motor. Thus, it will be possible to add new features in the virtual lab and allow the students to better understanding concepts related to control engineering, for example, among others.