## 2 Position-Based Repetitive Torque Observer and Compensation Strategy
### Torque Compensation Strategy  
#### 2.4.1 Online Compensation with Cogging Torque Table Learning Strategy  
The online torque compensation strategy is proposed as shown in Figure 13 to provide a closed loop learning process, which updates the estimated cogging torque table as the motor is controlled under a specific speed. Once the cogging torque is well compensated, one can easily observe the torque compensation effect by speed control performance. The processes are listed below.  
1. Control the motor to a specific speed.
2. After the PBR-TOB operates to steady state, SW1 is switched on to compensate the torque command online.
3. If the compensate effect is not satisfied, one can adjust the cutoff frequency of the learning filter and the bandwidth of PBR-TOB.
4. After the closed loop reaches steady state, SW2 is switched on to get an offline compensate table.  
In order to get the best resolution for an offline cogging torque table, the motor is required to control within a specific speed range, which is defined as follows.  
1. According to Equations (12) and (13), the motor speed \(0<\omega_{\rm m}<\frac{30\rm f_{5}}{\rm N_{\rm Res}}\) must be satisfied.
2. The lower the speed, the higher the cogging torque resolution.
3. The steady-state speed error is maximum.  
Figure 12: Cogging torque and estimated cogging torque table (no load torque added).  
Figure 13: Online compensation with a cogging torque table learning block diagram.  
Where the steady-state speed error (SSSE) for a certain time interval is defined as:  
\[\omega_{m\_SSSE}=\big{|}Max(\omega_{m})-Min(\omega_{m})\big{|}. \tag{11}\]  
The online torque compensation strategy is specified as follows. At the first turn, the learning memory array at the last turn \(T_{Q\_k-1}[n]\) is used as the initial condition. After the first turn, a forgetting factor \(W_{Q}\) is utilized as Equation (12) to weight the latest observed information \(T_{Q\_k-1}[N]\) and the previous compensation information \(T_{C\_k-1}[N]\). The observed information in previous turns will be gradually forgotten because of the weighting factor, and the latest observed values would only contribute part of the compensation, such that the noise and uncertainty in each turn can be distributed and reduced. The forgetting factor is chosen to be \(W_{Q}\)= 0.5 in order to balance the weight of the latest and previous data in this paper.  
\[\left\{\begin{array}{l}T_{C\_k}[N]=T_{Q\_k-1}[N],\ (first\ compensation\ turn)\\ T_{C\_k}[N]=T_{C\_k-1}[N]\times\big{(}1-W_{Q}\big{)}+T_{Q\_k-1}[N]\times W_{ Q}(After\ first\ compensation\ turn)\end{array}\right. \tag{12}\]  
When the online compensation strategy reaches the steady state, the offline cogging torque table can be obtained by averaging the observed information \(T_{Q\_k}\) of \(l\) turns at each position such that the noise and uncertainty of each turns can be lowered:  
\[T_{C\_Off\_k}[n]=\sum_{k=1}^{k=l}T_{Q\_k}[n]/l. \tag{13}\]  
Two advantages of the online strategy are mentioned below. (1) The characteristic of the PBR-TOB is that the cogging torque table will be updated after one rotor turn; in other words, the observation and compensation operate under different rates, and the stability of this structure is relatively high. (2) The initial condition of the learning memory array can be a previous estimated table or a zero array, no matter what the initial condition is, the PBR-TOB alters the table into the shape of the cogging torque. Its potential application is the detection of PM magnetic flux fault.