Design of torque system for electric bicycle based on fuzzy PID

: This article analyses the structure and working principle of the brushless DC motor, the advantages and disadvantages of PID regulation and fuzzy control are analysed as well, and puts forward the fuzzy PID motor control technology with both advantages. The speed control of the brushless DC motor is carried out and the simulation model is built. The results show that, compared with the traditional PID adjustment, the fuzzy PID makes the motor speed more stable and the speed fluctuation decreases obviously, which satisfies the requirement of the speed control of the electric bicycle.


Introduction
In recent years, the energy shortage and environmental pollution have forced the rapid development of electric vehicle technology, and for the core of the electric vehicle, brushless DC motor, good control is very important to the performance of electric vehicles [1][2][3].
Pulse width modulation (PWM) is a widely used technology in brushless DC motor control [4]. It controls the speed of the motor by controlling the switching and closing time of the switch tube and changing the duty ratio of the armature voltage of the motor [5]. However, in order to achieve better control of motor, PWM technology alone is not enough. As a new control method combining artificial intelligence and automatic control, intelligent control can solve the control problems that traditional methods cannot solve. Fuzzy control is an important intelligent control method, which is mainly based on rule control, and the main source of the rule is the experience of technical personnel and expert knowledge. So the fuzzy control can achieve the effect of simulating the artificial control process [6,7], but the fuzzy control rules are difficult to sum up, and once the control rules are determined, it is difficult to adjust online. The system is less adaptive to some situations [8]. To sum up, only one kind of intelligent control, such as individual fuzzy control or single PID adjustment, is difficult to meet the requirements of motor control performance, but the combination of traditional method and modern control can get good control effect after complementing. This paper combines the traditional PID and fuzzy control to get the fuzzy self-tuning PID control method [9]. It is applied to the brushless DC motor system. It has the advantages of simple PID algorithm and easy to eliminate the system error, and has good robustness to parameter change and interference [10].

Structure of brushless DC motor
The schematic diagram of Brushless DC motor is shown in Fig. 1, which mainly includes three parts: motor body, electronic commutator, and rotor position sensor.
Brushless DC motor can be regarded as a permanent magnet synchronous motor whose armature winding current is square wave and counter electromotive force waveform is trapezoidal wave. Compared with traditional brushless DC motor, brushless DC motor removes brushes and commutators instead of electronic commutators. The electronic commutator here is a three-phase bridge type full control circuit. Its main function is to get the PWM signal at the moment after the signal of the rotor position sensor is processed by the position signal. Then, the stator winding is guided in a certain logical order, and the stator winding is induced by electric abortion to produce magnetic potential and the magnetic field produced by the rotor. The electromagnetic torque is generated, and then the motor is turned. The rotor position sensor, as the name suggests, is a sensor used to detect the rotor position and is installed inside the motor. It is an important part of the electronic commutation. The position signal of the rotor is detected by the Holzer sensor, which can correspond to the switch tube in the three phase bridge type full control circuit. It is the key step to realise the electronic reversing. Fig. 2 is a three-phase full-bridge control circuit diagram of brushless DC motor. The stator winding used here is made of star type, and the three phase is connected to the six bridge arm of the inverter, and the position detection function is realised by the Holzer sensor with the motor. In general motor control, the order of stator three-phase conduction is AB, AC, BC, BA, CA, and CB. So, according to this order, the order of the six switches is VT1 and VT4, VT1 and VT6, VT3 and VT6. When the motor rotates, only two-phase windings are connected at the same time, and each phase is connected to a 120° electric angle (Fig. 3).

Working principle of brushless DC motor
The three output signals obtained by the position sensor are recorded as Ha, Hb, Hc, and the value of three signals is 0 or 1 to write 6 codes representing six states: 101,100,110,010,011,001, representing the rotor position of the brushless DC motor.

Double closed-loop control:
Here, a double closed-loop control strategy for a speed loop outside the inner current loop is adopted, in which Nr is given speed and Nf is feedback speed as in Fig. 4. The error is obtained after the two phases are subtracted. When the result is input to the regulator, the calculated current I is then subtracted from the current if measured from the stator windings of the brushless DC motor, and second error amounts are obtained. The second errors are processed by the current regulator to produce the control quantity, and then the square wave with precise switch-on time is input into the three-phase stator winding of the brushless DC motor and the motor can rotate normally.

Digital PID algorithm:
The PID algorithm is a traditional control method by calculating the difference value of input and output, and then taking the difference into the PID formula to get the control quantity. PID basic structure diagram is shown in Fig. 5. The difference between the input R and the output Y is input into the PID controller, which generally includes three basic parts, namely, proportional control P, integral control I, differential control D, and the control amount obtained after the three parts of linear combination calculation is applied to the control object, so that the error is gradually reduced to elimination. Proportional control can accelerate the speed of system error reduction, but too large is easy to cause system oscillation, too small cannot meet the requirements of fast adjustment, and only proportional control cannot completely eliminate the steady-state error. The integral control is also needed to eliminate the steady-state error, but the integral control cannot be too large, otherwise the system overshoot will be increased, and the addition of differential control can reduce the overshoot, make the system more stable, and improve the performance of the system. The general incremental PID algorithm is as follows To achieve PID control, we need to collect three recent error data.

Fuzzy control:
Fuzzy control is based on the combination of fuzzy set theory, fuzzy logic theory, and traditional control theory, aiming at an intelligent control method that cannot establish accurate mathematical model control object and imitate human thinking way and operation habit. Fig. 6. Fuzzy control mainly includes four parts: fuzzification, fuzzy rules, fuzzy reasoning, and anti-fuzzy. Take a two-dimensional input single output fuzzy controller as an example: Fuzzification. According to the actual situation, the observation value distribution of two input variables and one output variable is determined, that is to determine the range of the three variables, the error variable E, the error change rate EC, the control quantity u, to determine the domain of the three variables, and to divide the domain of each language variable, and define its corresponding membership function and the distribution space of the covered variables，blurring the value of a definite variable Fuzzy rules. According to the expert knowledge and operation experience, combining the dynamic characteristics of the system, the appropriate control rules can be formulated. The fuzzy rule is the core of the control, and it determines the precision of the control. In general, it can be written into fuzzy control rules with multiple IF-THEN forms, which also represented by a fuzzy rule table for the sake of simplicity.
Fuzzy reasoning is also known as approximate reasoning. According to the input variable and the fuzzy rule table, the fuzzy value of the output control can be obtained.
Anti-fuzzy. Anti-fuzzy is the process of transforming the fuzzy values of output variables into explicit values. Generally speaking, anti-fuzzy is an algorithm for finding the average distribution.
Here, the centre-of-gravity method is used to solve the fuzzy method and the centre-of-gravity method is the centre of gravity of the membership function of the output and the area of the abscissa. The specific calculation formula is shown below (Fig. 7).

Design of fuzzy PI controller:
The traditional PI control parameters K p and K i are fixed values, but if the same K p and K i parameters are taken under different working conditions, it is difficult to achieve good control effect. Therefore, a method of adjusting the PI parameters according to the working condition is needed, and the fuzzy control is obviously a good control method.   Fig. 8 is the schematic diagram of a fuzzy PI controller. On the basis of the traditional PI, by measuring the value of error E and the error rate EC, after fuzzification, fuzzy reasoning, and defuzzification, two delta K p and delta K i are obtained, and the values of initial K p 0 and K i 0 are added, respectively, then new fuzzy PI parameters are obtained. In different situations, the parameters are also different, which can significantly improve the system's dynamic steady-state performance and improve the antijamming capability.
The fuzzy PI controller is mainly used to find the error of PI parameters, and the fuzzy relation between the two variables of the error change rate is generally speaking. In the early stage of the system response, selecting a larger K p can accelerate the response of the system. The selection of a larger K i will help to speed up the elimination of errors, and the selection of the smaller K p in the middle of the system can prevent excessive overshoot. The moderate K i can be kept stable, and the system can respond to the later stage. The appropriate increase of K p and K i can further reduce the error.
Here, the fuzzy PI controller selection error, the change rate of error, the fuzzy domain of the control quantity are [ − 6, 6], the domain of the two output is [ − 1,1], and seven language variables are defined in the fuzzy domain. They are the positive large PB, the median PM, the positive small PS, the zero ZO, the negative NS, the negative NM, the negative big NB, at the same time, triangle membership function is selected, and the curve of specific membership function is set as shown in Fig. 9.In the experiment simulation, the basic domain of error and error rate is [ − 9,9] and [ − 1 × 105,1 × 105], respectively, so the corresponding quantising factors are 0.66 and 6 × 10 −5 , respectively. After many experiments and modifications in simulation, the ΔK p fuzzy rule table is formulated in Table 1 and ΔK i fuzzy rule table in Table 2.

Simulation research of brushless DC motor:
In order to verify the control effect, this paper uses Simulink to simulate and build BLDC motor control system, the debug it.
As can be seen from Fig. 10, the brushless DC motor control system mainly includes a motor body module, a logic commutation module, a double closed-loop fuzzy controller module, and an inverter bridge module. The logic commutation module and the control module are selected in detail below.
Logic commutation module. The received three Holzer signals, ha, Hb, HC, pass through a convert module, the data type is converted from Boolean to double type, and then through a true value table module, the corresponding six output values are obtained. Combined with the PWM modulation value and logic   Control module. The two inputs of the control module are the speed error E and the bus current I of the three-phase inverter bridge, and the output value is PWM control with a duty cycle. As of the fuzzy PI control strategy, the traditional dual loop control speed regulator is changed to the fuzzy PI controller, and the signal cycle in the PWM generator is set to 50 us (Fig. 11).

Results
Simulation is carried out on the basis of brushless DC motor control system in Fig. 10. The phase resistance and phase inductance of the stator winding of the motor are 0.25 Ω and 0.3 mH, respectively. The rated speed is 3000 rpm, the output power is 103 watts, the holding torque is 0.33 Nm, the torque constant is 0.062 Nm/Amps, and the back-EMF constant is 6.5. V/krpm, moment of inertia 106 g.cm 2 . The initial values of the proportional and integral coefficients are both 5, the error quantification factor is 0.66, the error change quantification factor is 6 × 10 −5 , and the scale factor of both outputs is 1. The current controller has a scale factor of 1 and an integral factor of 5. The voltage of the inverter bridge is 24 V DC voltage, and the simulation experiments are carried out on these bases. The advantages and disadvantages of the traditional PI control and the fuzzy PI control are compared in the case of no load and load torque.

Simulation one
The traditional PI control is used, and the simulation results are shown in Fig. 12 when the speed is 3000 r/min.

Simulation two
Figs. 13 and 14 show simulations result using fuzzy PI control and 3000 r/min at a given speed.

Simulation three
With conventional PI control, a load torque of 0.1 N.m is added at 0.05 s and the given speed is 3000 r/min. The simulation results are shown in Fig. 15.

Conclusion
From the simulation results, the conventional PID control can meet the general control requirements and achieve the control goal, but there is a large steady-state error. The brushless DC motor control using fuzzy PID control method can adjust the PID parameters according to the error and the error rate. The stability is better than the traditional PI control under the condition of no load and load. The stability of the system is reduced and the stability is enhanced, and the control requirements of the electric bicycle are satisfied.

Acknowledgments
The work presented in this paper was funded by the guiding project of the Fujian Rural Department of Science and Technology (2019H0039).