THE DESIGN OF CONTROL SYSTEM SIMULATOR

Selection of a suitable controller type, determination of its coefficients and adjustment if necessary is an important issue in the design of control systems. Quickly checking whether the closedloop system with a designed controller meets some desired time/frequency response criteria will save time for the student/designer. In this paper, an interactive control system simulator is designed to perform the simulations for closed-loop systems obtained with user-defined systems and different types of controllers whose parameters can be changed. The simulator allows the user to see the time/frequency response of the closed-loop system for different systems defined as single or comparatively and check whether some desired time/frequency domain criteria are satisfied, quickly. In addition, the simulator allows the possibility to see the disturbance input response and the effect of the measurement noise altogether with the reference input response, comparatively. Thus, analysis and comparison of different controllers and also teaching of control systems will be performed easily, quickly and effectively by using the simulator.


INTRODUCTION
The purpose of the control systems is to satisfy the some design criteria defined on the time or frequency response of the system. In order to meet these criteria, it is important to select an appropriate controller, determine the values of the controller coefficients and, if necessary, change the value of these coefficients. In this stage, the time response or frequency response of the closed-loop system with the controller is checked to see whether the controller whose type is selected and whose parameters have been determined meets the desired design criteria. If the desired design criteria are not met with the specified controller parameters, the new parameters are determined by changing the controller parameters or the type of the controller. Then, it is checked again whether the desired design criteria are satisfied by looking at the time and frequency response of the closed-loop system. For this purpose, the time response and frequency response of the controlled closed-loop system must be examined quickly. This quick check will save time for the student/designer. For this purpose, the aim of this study is to design a simulator that gives the time response and frequency response of the closed-loop system using the designed controller.
Computer-aided technologies (CAx) are widely used today. There are many simulators, applications, web pages, etc. developed for these technological fields (computer aided analysis, computer aided design (CAD), computer aided engineering (CAE), computer aided instruction (CAI), computer aided learning (CAL) etc.). Many simulators, applications, web pages, etc. are developed in (Vatansever, 2021). There are many studies in the field of system analysis with software in the literature ( There is an interactive GUI tool for PID controller design named "pidTuner" in the MATLAB. One-degree-of-freedom (1-DOF) or two-degree-of-freedom (2-DOF) PID controller can be designed with pidTuner. Also with GUI named "sisotool" in MATLAB can be design single-input/single-output (SISO) compensators by graphically interacting with the some plots (root locus, Bode, Nichols) of the open-loop system (MathWorks, 2021). An interactive control system simulator, which can also be used for educational purposes, was designed in this study. The simulator is used to test whether the obtained the closed-loop control system with a designed controller to satisfy the some desired design criteria. The simulator also performs simulations for different control systems obtained with any controller type whose parameters can be changed, and allows the user to see the time/frequency response of the closed-loop systems for a controller type with different parameters. Also, the simulator allows the opportunity to check whether it meets the design criteria for three different controllers designed by the user and to compare between them. In addition, the simulator allows the possibility to see the disturbance input response and the effect of the measurement noise also, altogether with the reference input response, comparatively. Thus, analysis, comparison and teaching of control systems can be performed easily, quickly and effectively. This paper is organized as follows: In Section 2, control systems are summarized. In Section 3, designed software tool is explained and sample applications are given. Finally, Section 4 contains conclusions.

CONTROL SYSTEMS
In general, the design of control systems consists of three steps: determining the design criteria, determining the controller structure, and determining the controller parameters. The design criteria used to specify the dynamic behaviour of the system are defined on the time or frequency response of the system. The time response criteria are expressed using the maximum overshoot; rise, peak and settling time and steady state error defined on the unit step response of the system. Frequency response criteria are expressed by using the gain and phase margin, resonance peak, bandwidth, etc., which are defined on the Bode curve or Nyquist curve of the system and also express the relative stability of the system. In addition to these criteria, some additional criteria such as sensitivity and robustness to parameter variations or disturbance rejection performance are also used for some applications.
In the traditional design approach, the designer applies a fixed design by connecting the controller to the system. Thus, the design is converted to determining the controller coefficients. The aim is to determine the controller coefficients to satisfy some the design criteria defined in the time/frequency response of the system and, if necessary, modify them to meet the desired design criteria. This design approach which has fixed structured configuration is known as compensation. The block diagram of the compensation used in this study, which has a fixed controller configuration, is shown in Fig. 1.
In the control system configuration, ( ) is the output signal to be controlled and ( ) is the reference signal followed by the output signal. The disturbance input is denoted by ( ) or ( ), and ( ) is the measurement noise contaminated to the output signal of the system. According to the superposition principle of linear systems, the response function of the closedloop system can be expressed as the sum of the responses obtained from each input as follows.

Figure 1: Block diagram of the control system configuration
The most commonly used controller structure is the serial/feedback controller connection in the compensation structure in Fig. 1 and it is denoted by ( ). Proportional Integral Derivative (PID) controllers are widely used in the serial controller structure ( ), and combine proportional, integral and derivative of the error signal e(t) with specific contributions. The coefficients of the PID controller determine the amount of contributions of these three effects to the control system. Integral (I) and Derivative (D) controllers are generally not used alone, but together with Proportional (P) controller as PI controller, PD controller, or altogether as PID controller. In general, the proportional effect is used to improve the speed of the system response, the integral effect to reduce the error in the steady state response, and the derivative effect to reduce the overshoot in the transient response by increasing the damping ratio of the system. Thus, the PD controller is used to improve the transient response of the system, the PI controller is used to improve the steady state response of the system, and the PID controller is used to improve both the transient and the steady state response of the system. Alternatively, Phase-Lead, Phase-Lag and Phase-Lead-Lag controllers can also be used instead of the PD, PI and PID controllers, for the same purposes, respectively ( Notch filter/controller is used to cancel the complex-conjugate poles of a system which are too close to the imaginary axis using pole-zero cancellation method. Also, some desired poles can be placed to desired locations by using the notch filter poles. The complex poles of the controlled system, which cause undesired oscillations in the time response, appear in the models of some mechanical systems which have flexible connections. Due to some systems cannot be modelled correctly or some parameters may change during operation, exact pole-zero cancellation may not be possible. However, inexact pole-zero cancellation may be sufficient if the complex poles are not close to imaginary axis or not in the right-half s-plane. If a notch filter is not enough to meet some desired criteria, a second controller such as a PI, PD, PID, Phase-Lag, Phase-Lead, or Phase-Lead-Lag controller can be used to compensate the notch-controlled system (Golnaraghi and Kuo, 2010).
In the compensation structure in Fig. 1, a filter or another controller can be used as the forward controller ( ). The feedforward controller (or prefilter) allows obtaining 2-DOF control designs. Thus, it allows satisfying more criteria compared to the 1-DOF designs. For example, if a PI or Phase-Lag controller is used as a serial controller, the rise time and settling time can be quite long and the overshoot can be affected negatively. By using a Phase-Lead controller or a PD controller in the system as a forward controller, the rise and settling time and overshoot can be improved. These improvements can be performed without affecting the characteristic equation of the system by using a PD controller (Golnaraghi and Kuo, 2010).
In some control applications, in addition to some desired time/frequency domain criteria, the designed system is desired to be robust/insensitive to disturbance inputs and parameter changes, and these objectives can be achieved by using high loop gains in the robust control design. For this purpose, in classical feedback control design, the controller zeros are placed near the closed-loop dominant poles which are selected according to the some desired time/frequency domain criteria. Because of the controller zeros will also be the zeros of the closed-loop system, the controller zeros will cancel the closed-loop poles. To avoid this, closedloop zeros are cancelled using a ( ) pre-filter. The pre-filter must have the same poles as the closed-loop zeros and not affect the steady state response (Golnaraghi and Kuo, 2010). The desired dominant closed-loop poles can be placed also by using the zeros of a PID controller, thus a robust PID controller can be designed (Dorf and Bishop, 2011).
The feedforward controller ( ) is used to eliminate the negative effect of measurable disturbance inputs on the output signal. Transfer function of the feedforward controller is obtained as ( ) = ( ) ( ) ⁄ by taking ( ) − ( ) ( ) = 0. The ( ) is not related to the feedback controller ( ) or the pre-filter (or forward controller) ( ), and can be used with any ( ) and ( ) combination. If the feedforward controller is not used to eliminate the effect of the disturbance input, it can be taken as ( ) = 0 (Golnaraghi and Kuo, 2010).
The transfer functions of some controllers that can be used as combinations of ( ) and ( ) are given in Table 1.

DESIGNED TOOL and APPLICATIONS
In this study, an application/simulator was designed using MATLAB App Designer (MathWorks, 2021). The main screen of the simulator is given in Fig. 2 and the menu options are given in Table 2. On this screen, the block diagram of the system is displayed and the required values are entered/selected. The reference, disturbance and noise inputs are entered as shown in Table 3-5, respectively. The disturbance inputs of the transfer function and the feedforward controller are inactive when "Disturbance" knob is "Off". When the relevant controls are selected, a new window is opened for entering the parameters. As a result of the single analysis, time and frequency domain responses -together with their parameters (maximum overshoot; peak, rise and settling times; steady state response and error; gain and phase margins, gain and phase crossover frequencies) -are displayed on the screen. There are also closed-loop transfer functions of the system (in both standard and pole-zero-gain form) with the zeros and poles of the inputs. In addition, pole-zero map, root locus, Nyquist diagram and Nichols map are also plotted. In the comparative analysis, the time domain and frequency domain responses of the selected controllers are plotted and their parameters are given in tables.

Figure 2:
The main screen of the designed simulator  Step Ramp  In the first simulation, a position control servomechanism which has a transfer function

None
is controlled by using a PID controller whose coefficients are = 360, = 800 and = 100. The physical parameters of the system are = 10 and = 80 /( / ). A step signal with ( ) = 0.1 is used as reference input and also, a step signal with ( ) = 10 which acts in the opposite direction is applied to the system as a disturbance input (Yüksel, 2016). The aim of the first simulation is to observe the success of the closed-loop system obtained with a PID controller with certain coefficients in terms of some performance quantities defined on the time/frequency responses. Fig. 3a shows to enter the coefficients of the controlled system ( ) and the feedback path transfer function ( ). A step signal is used as the default reference input in the simulator, and to enter of its magnitude is seen in Fig. 3b. When a step signal is added as a disturbance input to the closed-loop system in the simulator, its magnitude is entered as shown in Fig. 3c. To apply the step disturbance to the input of the controlled system, the blocks ( ) and ( ) are entered as 0 and 1 respectively in the simulator as seen in Fig. 3d. When the PID controller is selected as serial controller ( ), its coefficients are entered as shown in Fig. 3e. In the classical serial PID control method, the forward controller ( ) = 1 is used by default in the simulator. The step response and Bode plots of the obtained closed-loop system which has the entered PID controller are shown in Fig.  3f. The analysis results in Fig. 3f are obtained by selecting the single analysis option from the menu before the simulation and using the analysis button on the simulator after all the values related to the system, controller and signals used in the simulation are entered. Some important values defined on the time and frequency responses, which are obtained by using the PID controller, are given under the step response and bode plots. These values can be used to observe the performance of the obtained closed-loop system with the used controller, or to check whether some desired time/frequency response criteria are satisfied. The transfer function, poles and zeros of a closed-loop system obtained with the controller used are listed as shown in Fig. 3g. The closed-loop transfer functions obtained from the disturbance and noise inputs to the output are also listed in Fig. 3g. The pole-zero map, root-locus plot, Nyquist plot and Nichols plot of the closed-loop system obtained with the controller used are shown in Fig.  3h-k, respectively. In the second simulation, transfer function of a sun-seeker system is given as , where is an adjustable preamplifier gain and taken as = 1. In the second simulation, a Phase-Lag controller, a Phase-Lead-Lag controller and a Two stage Phase-Lead controller are compared in terms of some performance variables defined in time/frequency responses. The transfer functions of the controllers used to control of the position of the sunseeker system are given in Table 6 (Golnaraghi and Kuo, 2010).  Fig. 4a shows to enter the coefficients of the controlled system ( ) and the feedback path transfer function ( ). In the simulator, the unit step signal is used as a reference input to the closed-loop system, no disturbance input or noise input is used. The analysis results in Fig. 4b are obtained by selecting the comparative analysis option from the menu before the simulation and using the comparative analysis button on the simulator after all the values related to the system, the controllers selected and signals used in the simulation are entered. The step responses and Bode plots of the closed-loop systems which has three different controllers entered are shown in Fig. 4b, comparatively. Some important values defined on the time and frequency responses are also given under the step response and bode plots. These values can be used to observe or compare the performances of closed-loop systems obtained with three different controllers used or to check whether some desired time/frequency response criteria are satisfied. According to the obtained results, the closed-loop system has the best rise time and settling time values with the Two stage Phase-Lead controller, but the leadlad controller yields the best gain margin.
In the third simulation, a notch controller, a notch-Phase-Lag controller and a notch-PID controller are compared. The transfer function used for velocity control of a dc motor and load system with a flexible shaft is given as Because of the flexible shaft between motor and load, the transfer function of the system has a pair of complex-conjugate poles at 1,2 = −47.66 ∓ 1093.8 (Golnaraghi and Kuo, 2010). The desired time-domain criteria are given as follows: the maximum overshoot < %3.7, the rise time < 0.19 sec., the settling time < 0.256 sec. The desired frequency-domain criteria is the gain margin > 20 dB (Golnaraghi and Kuo, 2010). An inexact pole-zero cancellation is performed by taking the zeros of the notch filter as 1,2 = −50 ∓ 998.749. Thus, the numerator polynomial of the notch filter is chosen as ( + 50 + 998.749)( + 50 − 998.749) = 2 + 100 + 1000000 = 2 + 2 + 2 . Also, more acceptable poles can be placed to the system by using the denominator polynomial of the notch filter which can be designed as 2 + 2 + 2 = 2 + 20000 + 1000000 = ( + 50.1256)( + 19949.8743).
The original system without the notch controller is unstable for = 1 (Golnaraghi and Kuo, 2010). The designed notch filter applies gain attenuation to the system about | ( )| = = 1/200 ⁄ (≅ −46 ) at = 1000 / even with an inexact pole-zero cancellation. Thus, the closed-loop system becomes stable using the notch controller, but gives a lightly damped response and does not meet for an acceptable damping. Because of the designed notch controlled system did not give a satisfactory time response, a Phase-Lag controller and a PID controller can be used as a second controller to compensate the notch-controlled system. The transfer functions of the controllers used to control of the velocity of a dc motor and load system with a flexible shaft are given in Table 7. The step responses and Bode plots of the closed-loop systems which has three different controllers entered are shown in Fig. 5, comparatively.

Figure 5: Comparison of Notch, Notch-Phase-Lag, and Notch-PID controllers
The analysis results in Fig. 5 are obtained by selecting the comparative analysis on the simulator after all the values related to the system, the controllers selected and signals used in the simulation are entered. Some important values defined on the time and frequency responses are also given under the step response and bode plots. These values can be used to observe or compare the performances of closed-loop systems obtained with three different controllers used or to check whether some desired time/frequency response criteria are satisfied. According to the obtained results, the closed-loop system has the time and frequency response values with the Notch-PID controller.

CONCLUSION
In this study, an interactive control system simulator was carried out for simulation of a closed-loop-system which has a designed controller with certain parameters. The simulator allows quickly checking whether the closed-loop system with a designed controller meets some desired time/frequency response criteria. Selection of controller type, determination of its coefficients and adjustment if necessary can be performed in the simulator, and the new results also can be seen again in the simulator. This simulation process is an important issue in the design of control systems and the simulator designed for quick check will save time for the student/designer. The simulator allows the user to see the time/frequency responses of different closed-loop systems defined as single or comparative and quickly check whether some desired time/frequency domain criteria are satisfied. The simulator shows the disturbance response and the effect of the measurement noise together with the reference input, comparatively. Thus, analysis and comparison of several controllers and also teaching of control systems will be performed easily, quickly and effectively by using the simulator.

CONFLICT OF INTEREST
Authors approves that to the best of his knowledge, there is not any conflict of interest or common interest with an institution/organization or a person that may affect the review process of the paper.