# Random PWM Technique Based Two-State Markov Chain for Permanent Magnet Synchronous Motor Control
## 3 Random PWM Technique Based Two-State Markov Chain
### Two-State Markov Chain Parameter Optimization Based on the Immune Algorithm  
From Equation (8), the desired frequency and the random gain together determine the frequency variation range of the RPWM, so the random degree of the carrier frequency can be expressed as follows:  
\[R_{f}=\frac{f_{\max}-f_{\min}}{f_{c}}=\frac{2r}{f_{c}} \tag{13}\]  
where \(f_{\max}\) and \(f_{\min}\) represent the upper limit of frequency change and the lower limit of frequency change, respectively. It can be known from the above formula that the random degree is jointly determined by the random gain \(r\) and the desired frequency \(f_{c}\), while the value of \(f_{c}\) is set in advance by the control requirements of the permanent magnet synchronous motor system. Therefore, the random degree is only determined by one parameter, random gain \(r\), and the spreading effect depends on the size of the random degree, which means that \(r\) affects the final effect of the RPWM. From this, it can be concluded that the magnitude of the values of the two spreading parameters, random gain \(r\) and transition probability \(p\), play a decisive role in the final effect of the proposed method. Moreover, when the given range of these two parameters is large, the computation volume will increase as it is discrete data, which occupies a larger memory of the main control chip. Therefore, in this paper, the immune algorithm is chosen to optimize the spread spectrum parameters \(r\) and \(p\) so that the set of \(r\) and \(p\) with the best harmonic suppression effect can be found quickly. The immune algorithm is an intelligent optimization algorithm inspired by the biological immune system, which has the characteristics of balanced global and local search, strong robustness, and anti-interference ability compared to other optimization algorithms (e.g., genetic algorithm, particle swarm algorithm, ant colony algorithm, etc. ), which makes it more advantageous than other intelligent algorithms in solving parameter optimization problems [25; 26]. When using the immune algorithm to optimize the parameters, the most critical link is to establish the evaluation target model. And through the above analysis, it can be known that each set of different values of \(r\) and \(p\) produces different harmonic suppression effects, which are manifested as different output current waveform spectra of permanent magnet synchronous motors in practical applications. The purpose of using the immune algorithm  
Figure 7: Results of random number generation based on a two-state Markov chain. for parameter optimization is to find the minimum current spectrum harmonic peak within the given parameter range. This problem can be abstracted as the following expression:  
\[y=1/f(r,p) \tag{14}\]  
where \(f(r,p)\) represents the peak magnitude of the current spectrum harmonics of the experimental motor model under the set of independent variables \(r\) and \(p\), and \(y\) is the reciprocal of the peak magnitude of the harmonics. Thus, we have obtained the evaluation target model \(y\). Now, the parameter optimization is converted into solving \(\max(y)\) with \(r\) and \(p\), that is, using the immune algorithm to find the globally optimal solution, and the basic flow block diagram is shown in Figure 8.  
The global optimal solution is solved as follows:  
1. Initial parameter calibration: According to the system parameters of the experimental motor, as shown in Table 1, the parameters of the permanent magnet synchronous motor model in the simulation model are calibrated to ensure that the results of the simulation model are consistent with the experimental results;
2. Specification of the range of antibody values: The range of random gain \(r\) is set to [1500, 2500] and the range of transition probability \(p\) is set to [0.5, 1];
3. Initialization of antibody population: The initial antibody population \(A_{0}\) is randomly generated based on probability; each antibody in the population contains two basic information, that is, random gain \(r\) and transition probability \(p\).