Co-simulation of self-adjusting fuzzy PI controller for the robot with two-axes system

Received May 12, 2020 Revised Jun 6, 2020 Accepted Jul 20, 2020 This paper presents the co-simulation of the self-adjusting fuzzy PI controller to control a two-axes system. Each axis was driven by a permanent magnet linear synchronous motor (PMLSM). The position and speed controller used the fuzzy PI algorithm with parameters adjusted by a radial basis function neural network (RBFNN). The vector control was applied to the decoupled effect of the PMLSM. The field programmable gate array (FPGA) was used to control both axes of the system. The very high-speed integrated circuithardware description language (VHDL) was developed in the Quartus II software environment, provided by Altera, to analyze and synthesize designs. Firstly, the mathematical model of PMLSM and fuzzy PI was introduced. Secondly, the RBFNN adjusted the knowledge base of the fuzzy PI. Thirdly, the motion trajectory was introduced for testing the control algorithm. Fourthly, the implementation of the controller based on FPGA with the FSM method and the structure of co-simulation between Matlab/Simulink and ModelSim were set up. Finally, discussion about the results proved the effectiveness of the control system, determining the exact position and trajectory of the XY axis system. This research was successful in implementing a two-motor controller within one chip.


INTRODUCTION
Nowadays, robots are increasingly used to replace people in repetitive work or dangerous jobs. Robots are operated on a particular trajectory. However, most robots have a limited operating space, which affects the flexibility and accuracy of their actions. Many types of research for the multi-axis controller were designed to resolve these problems. Typically for this control method are two XY axes, driven by permanent magnet linear synchronous motor (PMLSM). The design of a specialized IC to make the controller compact, flexible, and low-cost has been studied by many experts to control the two XY-axes system. The two-axis XY, each axis has a PMLSM, the moving mechanism uses a ball screw nut. The contact between screw and screw nut is a layer of steel balls bearings to minimize friction, which helps smooth movement and achieve high accuracy.
Field programmable gate array (FPGA) technology has also been used in this case, with the hardware description programming feature, fast response time, short design cycles, embedded processors, low power consumption. The paper [1] designed the current vector control by Matlab/Simulink then convert it into Verilog hardware description language (HDL) code to speed up the calculation and attain a fast response. The vector TELKOMNIKA Telecommun Comput El Control  Co-simulation of self-adjusting fuzzy PI controller for two-axes system (Nguyen Vu Quynh) 3347 control for permanent magnet synchronous motor (PMSM) was coding by very high-speed integrated circuithardware description language (VHDL) in this research [2]. The paper [3] is using pipeline and resource sharing methods of FPGA to implement the sensorless PMSM drives. The BLDC was controlled by fuzzy sliding mode based on FPGA of Xilinx [4]. There were many types of research on intelligent controllers such as fuzzy control, sliding fuzzy control, artificial intelligence, adaptive control to control the speed and position of the motor for improving precision in machining and assembly. The fuzzy controller was applied to control the tennis ball robot for better training [5], modified direct torque control gives better performance of surfacemounted PMSM [6]. The scalar and field-oriented control techniques controlled the three-phase induction motor drive [7]. The fuzzy and sensorless methods were used to increase the exact speed of PMSM without encoder [8]. A sliding-mode fuzzy controller was used to strengthen the dynamic performance for the discretetime uncertain system [9]. The back-propagation and radial basis function networks were used for PMSM to get the quick parallel speed and high torque response [10]. The adaptive fuzzy controls the rotor field-oriented of surface mount PMSM, speedy and precise control can be achieved [11]. The adaptive controller with simple estimator equations and the absence of the voltage probe depends on direct and quadrature reference current only [12]. The paper [13] showed an adaptive fuzzy supervisor controller for the PMSM sensorless control. The fuzzy control method is an intelligent control system, with an inference mechanism from experts' control experience, but obtaining fuzzy sets and the optimal membership functions are not easy. To resolve this problem, the PID gain or the fuzzy knowledge base were adjusted appropriately based on the feedback system parameter. In this paper, an adaptive fuzzy controller is implemented in DSP to cope with the dynamic uncertainty and external load effect to the PMLSM [14]. The neural network can perform real-time control of the back-propagation learning algorithm [15][16][17]. The adaptive filter and fuzzy logic controller are applied for torque ripple minimization [18]. The fuzzy logic controller and genetic algorithm are designed to reduce the selected time for the optimized error signal gain values and, as a result, enhance the controller and system performance [19]. This research designed a non-linear controller and observer for a PMSM drive [20]. The co-simulation work by electronic design automation (EDA) Simulator Link has been gradually applied to verify the effectiveness of the Verilog and VHDL code in the motor drive system [21][22][23][24]. The EDA Simulator Link [25] provides a co-simulation interface between MATLAB/Simulink and HDL simulators-ModelSim [26]. Using it, you can verify a VHDL, Verilog, or mixed-language implementation against your Simulink model or MATLAB algorithm [25]. Therefore, EDA Simulator Link enables the use of MATLAB code and Simulink models as a test bench that generates stimulus for an HDL simulation and analyzes the simulation's response [25].
This research focuses on improving the control method by using the self-adjusting fuzzy PI controller to control a two-axes system. The controller of both X and Y-axis is implemented on one chip. This research also presents a mixed-method with parallel and sequential processing to implement the self-adjusting fuzzy PI controller. The radial basis function neural network (RBFNN) has three neural networks; they are computed in an identical manner. The others are calculated in a sequential manner. The co-simulation method is applied to check the result.

DESIGN OF THE SELF-ADJUSTING FUZZY PI CONTROLLER
The control diagram for the XY system is shown in Figure 1. It consists of two loops, in which the current controller is an inner loop; the position and speed controller is an external loop. The external loop uses RBFNN to adjust the parameter for the fuzzy PI controller. The VHDL code programmed the whole structure of the controllers. RBFNN has three layers, the input layer, the hidden layer, which is a set of Gaussian functions, and the output layer is a set of total linear functions. There are two phases of network training. Firstly, the weight functions were calculated from the input layer to the hidden layer ( ), ( − 1), ( − 2); then the weights from the hidden layer to the output layer were calculated to adjust the , values of the fuzzy PI controller to make the fuzzy PI controller more accurate. Each axis has a controller, so the system consists of two self-tuning controllers.

Mathematical model of PMLSM
The torque of motor under the effect of field-oriented control (FOC) ( = 0) is: motion equation of motor: with and as the motor's current on the d-q axis, , , and are the motor's coefficients, the total weight of the rotor, the coefficient of friction, and the load of the motor, respectively.

Fuzzy PI controller design
The fuzzy PI controller's input has two values: the difference (E) between the desired position and current position of the motor on the X or Y-axis, which returned from the encoder and which is derivative by the time (dE): This equation controlled the position of the motor: where are the coefficients of the PI controller at the external loop, is the output of the integral controller (I), T is the sampling time, and is the output of the fuzzy PI controller. The fuzzy PI controller can be summarized as follows: The membership functions were the symmetrical triangles to calculate the input variables E and dEx. During each cycle, only two values of Ex and dEx were supplied to the system as shown in Figure 2. From the values of Ex and dEx, based on membership functions, we can calculate the values of ( ) ( ) with: Where is the linguistic value of Ex, is the linguistic value of dEx. The fuzzy rules described as follows: where , is real value; i, j values from 1-49 are the number of fuzzy rules. The RBFNN adjusted the value of , . Now, there are only four fuzzy rules triggered. The fuzzy controller uses the product inference rule, singleton for fuzzifier, and central average method for defuzzification, the output signal can be calculated by:

Using RBFNN to adjust parameters of the fuzzy controller
During operation, the parameters of the system change, so it is necessary to adjust the , (knowledge base of the fuzzy controller) in order to get a better output response. , is adjusted according to the criterion of root mean square. The value function: Derivative (12) we get the minimum value: where > 0 shows the convergence rate of the value function. From (11) and (12) we have: RBFNN was used to adjust the parameters of the fuzzy controller ( , ). RBFNN has one input layer, one hidden layer, and one output layer. Figure 3 (a) shows the diagram of RBFNN. The input signal of RBFNN: The output of RBFNN is: where is the weight function, and ℎ is the activation function in the hidden layer of the neural network. The activation function is the Gaussian: where = [ 1 2 3 ] and are respectively central and spread. To adjust the system parameters, the instantaneous value function is defined: where s=1, 2, 3 and > 0 is a learning rate of RBFNN. In (5) is transformed as follows: where the Jacobian was calculated from (17) From (13), (14), (22), and (23) the parameter , of the fuzzy PI controller was updated as follows: with m = j, j+1 and n = i, i+1

The motion trajectory of the system
A reference equation generated the motion trajectory of the system with ( ) and ( ) on both axes. The motion trajectory is a star shape as shown in Figure 3

IMPLEMENT THE CONTROLLER BASED ON FPGA AND USING MATLAB/SIMULINK/MODELSIM FOR SIMULATIONS 3.1. FPGA controller structure and Matlab simulation
FPGA technology was used to implement the control algorithm of this paper. One of the crucial advantages of FPGA is that it allows the completion of the product quickly and makes it easy to use design tools. This research used Altera Cyclone II EP2C115 to implement all algorithms of this research. Altera Cyclone II EP2C115 has 114,480 logical Elements (LEs) and 3.9 Mbits of RAM. With the co-simulation of Simulink/ModelSim, the evaluation task of the VHDL code becomes more convenient. We can also change the input signal for examining VHDL code behavior, which is a challenging job in some VHDL development tools, such as Quartus II. The Simulink/ModelSim model for evaluation of the proposed algorithm is shown in Figure 4. The two motors, two IGBT inverters, are executed by the function of Simulink. The four ModelSim models execute the VHDL code of whole proposed algorithms. In Figure 4, the ModelSim model named ModelSim_1 and ModelSim_3 performs the function of position and speed controller of the X-and Y-axis. The ModelSim model named ModelSim_2 and ModelSim_4 performs the function of the current vector controller of the X-and Y-axis. The rotor speed of the two motors was fed back to ModelSim_1 and ModelSim_3. The rotor position, three-phase stator currents of two motors, were fed back to ModelSim_2 and ModelSim_4. The m-file is applied to develop the program of star shape motion trajectory. The following simulation will test the result of the proposed algorithm. Firstly, the decoupled system is tested. Secondly, selfadjusting is tested. The single-axis speed response was checked and compared between typical fuzzy PI and self-adjusting fuzzy PI controllers. Finally, the two axes simultaneous motion within the star trajectory was checked. Figure 5 shows the architecture of the proposed algorithm. It implements FPGA technology for the PMLSM position and speed controller. The CLK and CLK_40ns are the input clocks 50MHz and 25MHz to supply all modules of the proposed algorithm. The command speed and rotor speed xm, xp are the input of the self-adjusting fuzzy PI controller for the X-axis. The three-phase currents (Iax, Ibx, Icx) and rotor flux angle θex are the input of the vector control for the X-axis. The 6 PWMs are the output of SVPWM on the X-axis. Similar for the Y-axis.

Implementation of the control algorithms
The transfer function in the discrete domain of the motion equation was described as follows: where ∅ = exp (− ) , = (1−∅) . Hence the control equation at the output is:

RESULTS AND DISCUSSION
The speed and position controller of both X and Y-axes have been embedded in one FPGA chip. The proposed algorithms in the main block diagram are shown in Figure 6. The FSM sequential programming technique was used to describe control algorithms. The FSM method with one multiplier, one adder, one lookup table, has been used to implement the proposed algorithm. In the speed and position control loop, the fuzzy PI controller is applied. The RBFNN adjusted the knowledge base of the fuzzy PI controller. The internal circuit of the main proposed algorithm, included one circuit of position and speed fuzzy PI controller, one circuit of RBFNN, one circuit of the current controller, and coordinate transformation.
In Figure 6 (a), there are 85 steps to carry out the fuzzy PI controller. The steps s0-s1 compute the rotor speed error and error change. The steps s2-s5 compute the fuzzification.
Step s6 looks up the fuzzy table to select four values of cmn based-on i and j obtained from s5. The steps s7-s15 compute the defuzzification function; those are (6)(7)(8)(9)(10)(11). The steps s16-s18 compute the current command, and it is the PI function. The steps s19-s70 and s71-s73 calculate three neural networks; the FPGA is parallel processing; Therefore, it needs only 52 steps for completion. The steps s74-s84 turn the fuzzy rule parameters. To compute one neural takes 52 steps as shown in Figure 6 (b). The steps s0-s5 compute the norm value. The steps s6-s33 calculate the exponential function (17). The steps s34-s35 compute the output of neural and Jacobian at r th neural. The steps s36-s51 update the weight, variance, and node center value of the neural network.
The data type in vector control and SVPWM for PMLSM are 12-bits. The data type is designed with a 16-bits length for the self-adjusting fuzzy PI controller. Each clock pulse in the FPGA is 40ns to complete a command. There are 85 steps (3.4μs), 52 steps (2.08μs) to implement the fuzzy PI and one neural network, respectively. It does not lose any performance because the operation time of the self-adjusting fuzzy PI with 3.4μs is much less than the sampling time of the position and speed controller (2 kHz). Although the control algorithm of this research in using RBFNN to adjust the parameters of the fuzzy PI controller is quite complicated, using the FSM description in step-by-step order, it simplified the coding. The simulation was performed on Matlab/Simulink/ModelSim for adjusting and verifying the controller's parameters and checking the accuracy of the proposed algorithm. The ModelSim software was embedded in Matlab/Simulink for simulating the whole system. Motion trajectories, feedback signals, PMLSM engine models were designed on Simulink. VHDL codes of position control and speed control algorithms for XY axes were embedded in ModelSim.
The sampling frequency of the position and speed controllers was 2 kHz; the vector control was 16 kHz. The FPGA resources used for the whole algorithm are 73,402 LEs and 348,947 RAM bits. Firstly, the step response is set up, the step signal with period of 0.5s and magnitude variation from 0 => 500 rpm => 0rpm => 1000 rpm =>  Figures 7-9. It presents a good speed response as shown in Figure 7 and the id, iq currents complete decoupled effect as shown in Figure 8, the id current approached zero. The PMLSM can control as DC motor, and the speed is dependent on the iq current. The speed response in Figure 7 without overshoot, the rising time is about 0.2 s, and steady-state value is zero. The three-phase stator currents in Figure 9 are balanced.    Figure 10. In the beginning, the fuzzy controller was used to control the speed of the motor. The speed response has lag and overshoot. After one second, the self-adjusting fuzzy PI affects the , which is turning to reduce the error speed between rotor speed and reference model. The result shows that with the proposed algorithm, the rotor speed can track the reference model well. Similar to the light-load condition shown in Figure 11. Figure 8. The iq and id of the motor, decoupled effect, helps to control the servo motor as to control the DC motor Figure 9. The three phase-currents of the motor are balance Figure 10. The rotor speed of the motor at the fuzzy controller and self-adjusting fuzzy PI controller are compared at the heavy-load condition Figure 11. The rotor speed of the motor at the fuzzy controller and self-adjusting fuzzy PI controller are compared at the light-load condition Finally, the star shape is considered. The input signal with five segments from a to e (25 to 29) was stimulated from the Simulink. The simulation results are shown in Figures 12 and 13. The tracking performance by using fuzzy PI and self-adjusting fuzzy PI is compared. Figure 12 shows the performance of fuzzy PI; The error in Rotor speed Desired speed Command speed

Self-adjusting Fuzzy PI Fuzzy PI
X-axis is a maximum of about 3.5mm; the error in the Y-axis is a maximum of approximately 10mm. Figure 13 shows the performance of the self-adjusting fuzzy PI, the output motion of the X and Y-axis can draw the star shape well. The position output response followed the motion star trajectory very well. The error in X-axis is less than 2 mm; the error in the Y-axis is less than 8mm. It still has a different error between the two axes. However, objective control has been achieved. The self-adjusting fuzzy PI controllers with the knowledge base are turned by RBFNN; the results proposed algorithm are better than the fuzzy PI controller. Figure 12. (a) The combination of two axes motion in case fuzzy PI controller, (b) the X-axis position, (c) the Y-axis position, (d) The error on X-axis is a maximum of about 3.5mm, (e) The error on Y-axis is a maximum of approximately 10mm Figure 13. The output position response faithfully follows the input star trajectory signal in the case of a self-adjusting fuzzy PI controller; (a) the combination of two axes motion, (b) the X-axis position is less than 2 mm, (c) the Y-axis position is less than 8 mm, (d) The error on X-axis, (e) The error on Y-axis

CONCLUSION
This paper successfully applied FPGA technology to control the movement of the two-axes XY system. The proposed structure includes motion trajectory, position, and speed self-adjusting fuzzy PI controller. The RBFNN adjusted the fuzzy PI controller during the operation. The controller of both X and Y-axis was implemented on only one chip. The RBFNN is computed in a parallel method; it gets the fast response to adjust the fuzzy parameter when the system changes. Besides, the FSM method can help to control the implementation of the exact whole system. The system has been successfully simulated in Matlab/Simulink and ModelSim environments. The simulation results show that the proposed algorithm's tracking performance is better than the fuzzy PI controller. The motion controller is sufficient and correct.