# Stable Rules Definition for Fuzzy TS Speed Controller Implemented for BLDC Motor
## 3 Simulation Results  
The main point of this research was the hardware implementation of a controller in a low-cost microcontroller board. In order to reduce the risk of faults in the control algorithm and (potential) hardware damage, the implementation was preceded by simulation tests. The model was established in Matlab/Simulink 2022b on the basis of the mathematical description given in the introductory part of the paper (Section 2). Because further hardware development was the main objective, the reference and measured speeds were subjected to interference from the noise signal in order to align the test conditions with a real microcontroller system environment. The time constants for the transfer functions representing the power electronics \(T_{e}\) and mechanical inertia \(T_{m}\) of the laboratory drive and the simulation sample time \(T_{s}\) are presented in Table 3.  
The first test was conducted with controller gains equal to 1 to appraise the accuracy of the defined rules. Despite the fact that the speed transient dynamics were not at a satisfactory level, the test was passed correctly. The Lyapunov function \(\dot{V}\) was within the desired range throughout the whole test, as we can see in Figure 8. For the test purposes, a square reference signal was used, representing the most difficult operation conditions--immediate response to reference speed change. The controller gains were then optimized using the CSA with all the above considerations taken into account. For the purpose of the research, a simple cost function was defined (26):  
\[F_{c}=\frac{\sum_{s=1}^{S}|w_{m_{s}}-w_{ref_{s}}|}{S} \tag{26}\]  
where \(S\) is the number of considered samples; \(w_{m_{s}}\) is the measured speed; and \(w_{ref_{s}}\) is the reference speed. Figure 8: Values of the Lyapunov function \(\dot{V}\) during simulation with stable control rules. \begin{table}
\begin{tabular}{c c} \hline \hline
**Parameter** & **Value** \\ \hline \(T_{e}\) & 0.001 s \\ \(T_{m}\) & 0.016 s \\ \(T_{s}\) & 0.001 s \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Time constants of the simulation model. In Figure 9, the chosen speed transients obtained in the selected iterations (_i_) of the CSA optimization are depicted. For comparison purposes, the speed of the motor drive measured for the case of the controller with gains equal to 1 is also attached. An unquestionable improvement in the dynamics can be noticed in Figure 9. The overshoots and oscillations in both the dynamic and static operation of the motor were reduced drastically. This figure also confirms the fact that the correct tuning of the controller gains is essential for correct operation. It should be emphasized that the fuzzy logic controller, even in a very basic configuration, provides the possibility to track the reference signal. However, the dynamics can be improved by correct gains calculations. The presented transients also confirm that the CSA is an efficient tool for tuning fuzzy controllers. After five iterations of the algorithm processing, the offset in the steady state was eliminated. The further iterations eliminated the overshoot level and damped high-frequency oscillations. Thus, the error between the reference signal and the measured speed was minimized--this can be noticed in Figure 10.  
The parameters of motors in an industrial environment change during operation because of the variable temperature, different load torques, etc. [79]. The second part of the simulation tests was focused on the verification of the drive operation with an increased mechanical time constant \(T_{m}\). Figure 11 presents the speed transients of the motor with different (disturbed) time constants and an initially tuned controller. The results were  
Figure 10: Cost function values under fuzzy controller optimization with the CSA. Figure 9: Speed transients of the drive with optimized fuzzy controller (chosen stages of the parameter optimization). obtained for the following optimized controller coefficients: \(K_{e}=0.59\), \(K_{de}=3.32\), and \(K_{u}=870.20\).