## 2 Position-Based Repetitive Torque Observer and Compensation Strategy
### Realization of PBR-TOB  
As shown in Figure 4, the position-based repetitive control torque observer structure (PBR-TOB) structure consists of a torque observer structure (TOB), which is a linear time-based observer (enclosed  
Figure 5: (a) Plug-in type repetitive controller (RC); (b) Simplified structure.  
Figure 6: Frequency-varying characteristic of the cogging torque signal.  
Figure 7: Position-based repetitive controller for the cogging torque signal.  
in blue dashed line), and a PBR, which is a nonlinear position-based delay function (enclosed in red dotted line). To implement the above design, the signal processing flow of the Digital Signal Processor (DSP) includes two sub-flows, as shown in Figure 8; one is a time-based signal process for TOB, and the other is a position-based procedure that is triggered by encoder pulse variation for PBR. The position-based delay can be realized by the read and write process of a memory array in every sampling period according to encoder pulse variation.  
This paragraph demonstrates how the position-based delay (by a rotor cycle) is achieved. Let \(N_{\text{Res}}\)(pulses / turn) be the resolution of an incremental encoder. A learning memory array \(T_{Q}[N_{mem}]\) of size \(N_{Mem}(=N_{\text{Res}})\) is utilized to latch the cogging torque information for every position. For example, \(T_{Q,k}[n]\) indicates the latched information for position \(n\) at turn \(k\), where \(n\in Z[0,N_{\text{Mem}}-1]\) and \(k\in Z[0,\infty]\). With the assumption that the rotor speed \(\omega_{m}>0\) (\(CCW\)), once the periodic timer interrupt is triggered at time instance \(m\), the DSP checks if any encoder pulse variation is detected to execute a related position-based procedure. As shown in Figure 9a, if there is no position variation, the memorized data \(T_{Q,k-1}[n]\), corresponding to the cogging torque of position \(n\) in the previous turn \(k\)-\(l\), is set as the feedforward term \(T_{FF,m}\) toward the observer. However, as shown in Figure 9b, if the rotor position changes from position \(n\) to \(n\)+\(l\), the position-based delay procedure reads the memory \(T_{Q,k-1}[n+1]\), corresponding to the cogging torque of position \(n\)+\(l\) in the previous turn \(k\)-\(l\), as the feedforward term \(T_{FF,m}\). Simultaneously, \(T_{Q,m}\), the estimated cogging torque of time instance \(m\) is latched into the corresponding memory \(T_{Q,k}[N+1]\) as new data for the current turn \(k\).  
Figure 8: Working flow for PBR-TOB.  
Figure 9: Timer interrupt process: (**a**) No position variation is detected; (**b**) Position variation is detected (from n to n + 1).  
A simple example with encoder resolution \(N_{Mem}=4\) is demonstrated in Figure 10.  
However, there are some constraints for the position-based delay process. Since the timer interrupt is triggered under the sample rate \(f_{S}(Hz)\), the frequency of the detected encoder pulse \(f_{enc}(Hz)\) can be calculated by the motor speed \(\omega_{m}(rpm)\):  
\[f_{enc}=\frac{\omega_{m}}{60}\times N_{\text{Res}}. \tag{9}\]  
As shown in Figure 11, in order to catch all the information into the memory array, according to the Nyquist sampling theorem, the sampling frequency must be higher than two times the encoder frequency.  
\[f_{S}>2\times f_{enc} \tag{10}\]  
If the conditions mentioned above are satisfied, the cogging torque can be estimated and updated simultaneously, as shown in Figure 12. If the encoder resolution is higher, the resulting observed cogging accuracy is higher.  
Figure 11: Relation between detected encoder pulse and observer calculation interrupts.  
Figure 10: Example for \(N_{Mem}=4\).