# Random PWM Technique Based Two-State Markov Chain for Permanent Magnet Synchronous Motor Control
## 3 Random PWM Technique Based Two-State Markov Chain
### RPWM Technique Based on Two-State Markov Chain  
In order to solve the problem of unsatisfactory random number generation results mentioned in the previous section, this section introduces the Markov chain into the RPWM technique to improve the random performance of the random numbers, thus further weakening the harmonic peaks. Markov property refers to the fact that under the condition that the current state is known, the value of the future does not depend on the past; only the current state can predict the future, and the past is useless for predicting the future [24]. And the random process with the Markov property is called the Markov process. Let \(\{A(t),t\in T\}\) be a random process with \(0<t_{1}<t_{2}<\ldots<t_{n}\in T.\) If the value of \(A(t)\) at moment \(0<t_{1}<t_{2}<\ldots<t_{n}\) is \(a_{1}\), \(a_{2}\), \(\ldots\), \(a_{n}\) and  
\[F(a_{n},t_{n}|a_{n-1},t_{n-1};a_{n-2},t_{n-2};\ldots;a_{1},t_{1})=F(a_{n},t_{n} |a_{n-1},t_{n-1}) \tag{9}\]  
then \(A(t)\) is called a Markov process. A Markov process with both time and state being discrete is called a Markov chain. It is a sequence of random events where the future value is only related to the current value and has no relation to historical values. It is a discrete random process. Therefore, to handle discrete problems, the concept of transition probability is introduced in Markov chains:  
\[P_{ij}(m,n)=P\big{\{}X_{n}=a_{j}\big{|}X_{m}=a_{i}\big{\}}=P\{X_{n}=j|X_{m}=i\} \tag{10}\]  
where \((i,j)\in S\), \(S=\{a_{1}\), \(a_{2}\), \(\ldots\), \(a_{n}\}\) represents the state space, while \(P_{ij}\) denotes the transition probability. From Equation (8), it can be seen that the probability that the state is \(a_{i}\) at \(m\) moments and after \((n-m)\) time is transferred to \(a_{j}\) state; it can also be understood as the probability of being in state \(j\) at \(n\) moments under the condition that the state is \(i\) at  
Figure 5: Results of random number generation in conventional RPWM. moments. Therefore, the transition probability is actually a conditional probability. And from this, the expression for the transition probability matrix is derived:  
\[P=\left\{p_{ij},\left(i,j\in S\right)\right\}= \begin{bmatrix}p_{11}&p_{12}&\cdots&p _{1M}\\ p_{21}&p_{22}&\cdots&p_{2M}\\ \vdots&\vdots&\ddots&\vdots\\ p_{N1}&p_{N2}&\cdots&p_{NM}\end{bmatrix}  \tag{11}\]  
where all elements in the equation are non-negative and the sum of all elements in each row is 1. Theoretically, the larger the state space of the Markov chain, the better, but this will increase the amount of system calculations, requiring a larger memory. From a practical situation to consider, the state space should not be too large. When the state space is 2, the transition probability matrix \(P\) has two unknowns; when the state space is 3, the transition probability matrix \(P\) has six unknowns. Therefore, as the state space increases, there are more and more unknowns, which increases the computational difficulty. In summary, this paper chooses two state spaces, that is, the two-state Markov chain is incorporated into the RPWM technique. The control method of a permanent magnet synchronous motor based on a two-state Markov chain RPWM is implemented as shown in Figure 6. Specifically, when the carrier frequency is greater than \(f_{c}\), it is set as State 1; when it is less than \(f_{c}\), it is set as State 2. When the carrier frequency is in State 1, the probability that the carrier frequency will be in State 2 in the next moment is \(p\), and the probability that it remains in State 1 is \(1-p\). When the carrier frequency is in State 2, the probability that it will be in State 1 in the next moment is \(p\), and the probability that it remains in State 2 is \(1-p\). By analyzing and deriving the implementation method, the transition probability matrix of the RPWM based on the two-state Markov chain can be finally obtained with the following expression:  
\[P_{M}= \begin{bmatrix}p_{11}&p_{12}\\ p_{21}&p_{22}\end{bmatrix} = \begin{bmatrix}1-p&p\\ p&1-p\end{bmatrix}