A DC Motor Position Control System in a 3D Real-Time Virtual Laboratory Environment Based on NCSLab 3D

—Virtual laboratories and remote laboratories have been a great complement of traditional laboratories in the last few decades. Virtual laboratories, which use computer technology to perform experiments utilizing virtual instrumentation instead of physical devices, are warmly welcomed for its low-cost advantage, 24/7 operation, remotely accessibility and sharing features. In this paper, a DC motor control system which can be used to carry out the experiments of position control in real time based on NCSLab framework is presented. After describing the process of 3D modelling, rendering in Flash 3D engine and control algorithms that are generated using Matlab Real-Time Workshop, a position control experiment is conducted and the experimental results are demonstrated as an example. For most virtual control laboratories, users are only allowed to design the algorithms and then monitor the control results. However, wiring process which is also an important part of practical control experiments cannot be emulated. To address this problem, a new experiment modelling method which allows the users to do the wiring in the 3D real-time virtual laboratory is proposed in this paper. It could make users feel more sense of reality and immersion when performing the virtual experiments.


INTRODUCTION
Engineering students have learned quite a lot of theories from teachers and books ever since they entered the engineering field. However, laboratory work is also important as it provides students practical hands-on skills. Therefore, laboratories play a vital role in students' learning career. Experiments in laboratories could highly enhance their capability to apply theories to practice and improve or even create something which may change our life in some way.
However, much merit as laboratories have, limitations on funds, laboratory rooms and experimental staff impose negative effects on the laboratories' development. Thus, virtual laboratories [1,2], remote laboratories [3] and hybrid laboratories [4] gradually find their way and finally become a great complement of traditional physical and hands-on laboratories without loss of any level of knowledge [5]. These laboratories share a common feature as remotely and 24/7 accessible by users no matter where they are, which enhances the availabilities and promotes learner autonomy [6] restricted by traditional laboratories.
As technologies such as Internet technologies and communication technology have achieved great advances in the last two decades, a lot of remote or virtual laboratories such as iLab [7] in MIT, WebLabs [8] in University of Cambridge, WebLab-Deusto [9] in University of Deusto, VISIR [10,11] in Blekinge Institute of Technology (BTH) and sharing remote laboratories [12] have been setup around the world. These laboratories provide services and opportunities for those who have a will to learn but limited either by the learning environment or their own limitations.
Among the experimental equipment in laboratories, DC motor has been extensively used in industrial applications such as CNC machine tools and electric vehicles etc. DC motor [13] control systems are typical in control engineering education for the study on servo control and closed-loop feedback control.
In this paper, a DC motor position control system in a real-time virtual environment based on NCSLab is presented. NCSLab was originated from the UK and has been developed both in UK and China. NCSLab 3D [14] is developed on the basis of NCSLab framework which supports both remote real-time experiments [15] and virtual experiments in 3D environment [16].
In the old NCSLab 3D system, users are only allowed to customize the algorithms and monitor the real-time experiments remotely. However, wiring process, which is also an important part of practical control experiments apart from control algorithm design, cannot be reflected in the virtual laboratory platform. To address this problem, in this paper, a method which allows users to do the wiring in the 3D virtual laboratory is proposed. Users are required to setup the wiring before the virtual controller and test rigs can be successfully activated, which can emulate the practical situation in hands-on experiments more closely. This paper is organized as follows. Section II presents the physical DC servo control system and the 3D modelling process as well as the rendering in Flash 3D engine. Section III demonstrates the design of the control algorithm for the DC motor system. Section IV introduces how the 3D model and the mathematical model are combined to perform real-time experiments. The methods for simulating the wiring process are also introduced in this part. Section V gives the conclusion and puts forward some future works.

A. DC Servo Control System
DC servo control systems can be used to study the control theory and applications for teachers, students and engineers. Fig. 1 shows a practical DC servo control system placed inside the campus of University of South Wales. It can be accessed remotely through www.ncslab.net. Using this system, a lot of control strategies such as PID and LQG can be implemented remotely. However, the powerful functionalities also mean it is very costly. The purchase price of this system is nearly £9000, which may not be affordable for all the universities or institutions especially in the developing world. Therefore, a virtual DC servo control system is necessary for its accessibility and low-cost advantages. In this paper, parts of the expensive servo control system which can be simulated using the 3D virtual test rig is introduced.

B. 3D Modelling
The DC motor control system consists of a power source, a motor driver, a DC motor, a position sensor, a controller and an attenuator. To build a system which can be used to perform real-time experiments in 3D virtual laboratory, the first step is to construct models of the system one by one according to their physical model patterns. Fig. 2 shows parts of models of the DC motor control system in 3DS Max environment.
Secondly, electric wires which are used to make connections between different parts should also be constructed. Separate wires are distributed with different kinds of colors so that they can be easily distinguished from each other, letting users understand whether they should be connected to the signal terminals, positive terminals, negative terminals or ground terminals.
Finally, wire terminals of the four types which bridge models using electric wires should also be taken into account. They are not constructed in 3D software like other models. Instead, they are generated by ActionScript codes in Flash 3D engine so that they can be selected by users using the mice, which will be introduced in Section II. C.

C. Model Rendering in Flash 3D Engine
Though models are constructed well in 3D modelling software, they can only be zoomed and viewed from different angles in 3DS Max environment. In order to embed them into the web browsers, Flash 3D engine and HTML5 are two possible solutions. HTML5 is relatively new and the compatibilities for different web browsers still needs to be tested, while Flash plug-ins are installed by most of the personal computers (PC). Considering the compatibility issues, Flash 3D engines are selected as the rendering solution in this paper.
There are plenty of different Flash 3D engines available such as Sandy 3D, Alternativa3D, and Away3D etc. Among them, Away3D is selected for its open source feature, informative help documents and rich tutorials and also its strong hardware accelerated rendering capacities.
As mentioned in Section II. B, wire terminals which are missed in the 3D modelling are developed by Flash 3D engine. In order to achieve that, wire terminals are reconstructed as a Cylinder Mesh Objects. Wire terminals are twice the amount of wires as a wire is connected to two terminals like in the real situation in the physical world. In order to setup the experiments, users are required to place the wires to the right positions using keyboards and mice, exactly as they do in a hands-on experiment.
While all the models are constructed well in 3D modelling software and imported into Flash 3D engine, they are loaded onto the stage of the Flash 3D engine and can be zoomed in, zoomed out, rotated or viewed from any possible angle. Both the 3D models and their corresponding textures should be carefully placed to the right folders in the server side before they can be successfully loaded into the web browsers by the Flash 3D engine properly, as shown in Fig. 3. For DC motor position control system depicted in Fig.  1, the mathematical model is identified as where the input of the transfer function is the voltage applied to the DC motor and the output is the voltage sampled from a position sensor. The sample time is 0.04s. The controller is designed to be a proportionintegral(PI) controller as shown (2) Both Equation (1) and (2) are given in [17]. Fig. 4 shows the interconnection between the mathematical model designed using Simulink and 3D model in Flash 3D engine for the DC motor control system. The mathematical model contains many "product" blocks and "constant" blocks. The initial values for these "constant" blocks are zero, which means the corresponding wires in the 3D models are unconnected initially. For example, the wire from the position sensor and controller is not connected, which means the feedback channel in the mathematical model is disabled because of the missing wire.
When two wire terminals are connected, the corresponding value of the "constant" block is changed to one. The "product" blocks work like a AND gate. Only when all the wires are placed by users, the corresponding signal is enabled. For example, only when both live and ground wires are connected for the motor driver, the motor driver can be activated, which mean the route for the corresponding signal (from output of the PI controller to the input of the DC motor) established in the block diagram.
When all the electric wires are well connected by the users, which means the values of all "constant" blocks become one, the whole system is activated and the feedback PI control algorithm starts to work.  However, the control algorithm designed by Simulink cannot be used directly by the NetCon controller. They have to be compiled into binary codes that can be executed in the real-time controller. It can be achieved without any programming using Real-Time Workshop (RTW). RTW framework is slightly modified as the generated codes can be compiled and downloaded into the ARM-based controller. Fig. 6 shows the configuration interface of RTW. When all the parameters are well configured, by clicking the button "Build", the executable control algorithm codes which can be used directly by NCSLab system are generated automatically.

IV. REAL-TIME EXPERIMENTS OF DC MOTOR CONTROL SYSTEM
In order to conduct the real-time virtual experiments, the 3D models rendered in Flash 3D engine described in Section II and the control algorithms designed in Section III should be combined together to form the 3D virtual DC motor control system.
Before presenting the experiment, the NCSLab should be briefly introduced. NCSLab is built based on Tomcat Web Server. It has browsers/server (B/S) structure and no plug-ins rather than Flash is necessary for the users.
The use case diagram to conduct virtual experiments in NCSLab 3D is demonstrated in Fig. 7  When the users login, a list of sub-laboratories is displayed in the web browser. As a virtual test rig in the NCSLab framework, DC motor control system is classified in the Servo Control Sub-laboratory. By clicking the corresponding web link, the DC motor test rig is chosen and the web page for DC motor appears.
Then the user can request full control for the virtual test rig. There is a 30 minutes time slot for each user to perform the experiment. If the user cannot finish the experiment in the given time slot, he can apply for the full control again to continue the experiment, and he can also give up the full control anytime if he finishes the experiment early. As introduced in Section III, control algorithms are designed and automatically converted to executable codes that can be used directly by NCSLab 3D. As showed in the middle of Fig. 8, users can upload a new executable algorithm designed by themselves, which expand the functionalities of the NCSLab and enhance its utility.
After all work has been completed, the algorithm can be downloaded automatically, followed by creating the new monitoring interface of the experiment. The final step before starting the position control experiment of DC motor in 3D real time virtual laboratory is to choose the corresponding signals and parameters for the monitoring interface. Signals are used for monitoring, for example, the speed and position of the DC motor; while parameters are for remote control, like the knob position of the attenuator, the set point value and the values for all of the electric wires that determine whether they are in the connected or disconnected state.
The models appear when entering the 3D real-time virtual laboratory, and parameters such as the position, the output of the engine at the top left corner are in the initial state. If the user would like to conduct the experiment, he needs to connect all of the models in the correct order by using wires which appear when two terminals in a group (the two terminals used to connect one wire) are clicked. For instance, after one of the terminals (+15V) in the source model is clicked, if the corresponding terminal in the position sensor model which forms a group with the former one is clicked, the wire appears and connects the two terminals, as the red wire in Fig. 9.
To avoid confusion for users, only one terminal can be selected at a time. When a wire terminal is clicked, it is selected and its color will change from black to red, therefore, from the point of view of the 3D interface, the terminal is highlighted and easy to be distinguished from other parts, as the example in Fig. 9 and Fig. 10.
If two terminals which don't belong to one group are clicked (for example, in Fig. 9, the user tries to connect the negative power of the power source and the ground of the motor driver), a warning message will appear to warn users to choose again as terminals don't match. Figure 9. Warning message appears when the wrong terminal is clicked in NCSLab 3D interface After all the wiring work is completed correctly, the corresponding states of the real time simulation executed inside the NetCon Controller on the server side are updated. The virtual experiment is activated and the real time virtual experimental results are sent back to the client side through the NCSLab datalink. Fig. 10 shows the control and monitoring interface of DC motor control system, in which the virtual motor is rotating synchronized with the remote simulation running in the NetCon controller.
As in the control algorithm, the parameters like the set point and values for wires can also be changed in the NCSLab 3D interface. For example, the first seven parameters at the lower right corner of Fig. 11 are the values for all the terminals. Since all the terminals are connected with wires, the corresponding values which represent the state of wires are all number 1. Fig. 11 also shows the adjusting process while set point was changed from 25 to 12.5, the curve in red depicts the change of position of the DC motor when the opening degree of the knob is 0.6, the parameters at the top left corner also shows and verifies the result. In this paper, a DC motor position control system based on NCSLab is presented. The real DC servo control system was briefly presented, before the 3D modelling as well as the model rendering in the Flash 3D engine was introduced. Then, the control algorithm and mathematical model which include a closed-loop position feedback was designed for the virtual test rig. In Section IV, a virtual DC motor control system which combines the 3D model with the mathematical model and carries out position control experiments in real time is presented. The method of how to simulate wiring processes was described in details. Users are required to do the wiring work on the virtual test rig before the practical experiments start, which can emulate the situations in hands-on laboratories more closely. In the case study, a DC position control experiment is represented as an example. It shows that the position control performance turns out to be as expected and parts of the expensive servo control system can be simulated using the 3D virtual test rig proposed in this paper.
In the future, there are still a lot of work to be done to improve the DC motor control system. Firstly, other functionalities of DC motor such as speed control should be included in the proposed system. Secondly, user experience and feedback should be collected in the real teaching practice. Most importantly, in order to totally eliminate plug-ins, HTML5 which represents the future trend of web technologies need to be adopted in the future version of NCSLab 3D. PAPER A DC MOTOR POSITION CONTROL SYSTEM IN A 3D REAL-TIME VIRTUAL LABORATORY ENVIRONMENT BASED ON NCSLAB 3D Figure 11. Adjusting process when the set point was changed from 25 to 12.5 when the openning degree of the knob is 0.6