## 3 Sliding Mode Terminal Iterative Learning Compensation Method  
1. Define \(\mathrm{E_{k}}\) as the terminal dimensional error of the \(\mathrm{k_{th}}\) workpiece, which is shown as Equation (15): \[\mathrm{E_{k}}=\mathrm{D_{desired}}-\mathrm{D_{k}}\] (15) Here, \(\mathrm{D_{k}}\) is the terminal dimension of the \(\mathrm{k_{th}}\) workpiece, which is measurable by laser sensor. \(\mathrm{D_{desired}}\) is the desired dimension of the workpiece. If \(\mathrm{E_{k}}\) is within the accepted error limit \(\mathrm{E_{lim}}\), the error compensation is ignored; otherwise, the compensation is operated. Substituting Equation (13) into Equation (15) yields Equation (16). Equation (16) is transformed as follows: \[\mathrm{E_{k}}=\mathrm{D_{desired}}-\mathrm{D_{k-1}}-\varphi_{\mathrm{k}} \Delta\mathrm{u_{k}}\] (16)
2. Introduce an iteration-dependent slide surface function and an index function [26], which are two common functions in sliding mode control. The Equations are shown as follows: \[\mathrm{S_{k}}=(\mathrm{E_{k}}-\mathrm{E_{k-1}})+\upalpha\mathrm{E_{k}}\] (17) \[\mathrm{J}=||\mathrm{  
Since \(\beta>0\), \(\left||\varphi_{\mathrm{k}}{}^{\mathrm{T}}\mathrm{S}_{\mathrm{k}}||<\left||\varphi _{\mathrm{k}}{}^{\mathrm{T}}\mathrm{S}_{\mathrm{k-1}}\right||\right|\). Then \(\lim\limits_{k\to\infty}||\varphi_{\mathrm{k}}{}^{\mathrm{T}}\mathrm{S}_{ \mathrm{k}}||\)=0. Since \(\varphi_{\mathrm{k}}\) is bounded, \(\varphi_{\mathrm{k}}{}^{\mathrm{T}}\) is bounded. Therefore, the following Equation (24) can be derived.  
\[\lim\limits_{k\to\infty}||\mathrm{S}_{\mathrm{k}}||=0 \tag{24}\]  
Therefore, the sliding surface will converge to 0. Substituting Equation (17) into Equation (24), \(\lim\limits_{k\to\infty}||(\mathrm{E}_{\mathrm{k}}-\mathrm{E}_{\mathrm{k-1}})+ \alpha\mathrm{E}_{\mathrm{k}}||\)=0. Then, Equation (25) can be deduced. \[\lim\limits_{k\to\infty}||\mathrm{E}_{\mathrm{k}}||=\lim\limits_{k\to\infty} \left|\left|\frac{\mathrm{E}_{\mathrm{k-1}}}{1+\alpha}\right|\right|=\lim \limits_{k\to\infty}\left|\left|\frac{\mathrm{E}_{0}}{(1+\alpha)^{k}}\right|\right| \tag{25}\]  
Since \(\alpha>0\), the following Equation (26) can be derived. \[\lim\limits_{k\to\infty}||\mathrm{E}_{\mathrm{k}}||=0 \tag{26}\]  
Therefore, the terminal error will converge to 0. As mentioned above, the convergence analysis is made. As it is mentioned in Section 2, the system input is constant of every cycle at an arbitrary sampling time for one batch and it is executed by X axis. The compensation is executed by the compensation module if it is necessary; the compensation input for the \((\mathrm{k+1})_{\mathrm{th}}\) workpiece is computed as follows. \[\mathrm{com}_{k+1=}\mathrm{com}_{\mathrm{k}}+\frac{\varphi_{\mathrm{k+1}} \mathrm{E}_{\mathrm{k}}}{||\varphi_{\mathrm{k+1}}||^{2}}-\frac{(2+\alpha+ \beta)\varphi_{\mathrm{k+1}}\mathrm{E}_{\mathrm{k}}-\varphi_{\mathrm{k+1}} \mathrm{E}_{\mathrm{k-1}}}{(1+\alpha)(1+\beta)||\varphi_{\mathrm{k+1}}||^{2}} \tag{27}\]  
Here, the compensation is computed by the previous two-dimensional errors, and \(\varphi_{\mathrm{k}}\) is computed in Equation (14). The flowchart of the compensation method is shown in Figure 4. Note that in the judgment module, the compensation direction needs to be defined. If \(\mathrm{E}_{\mathrm{k}}\) is less than \((-\mathrm{E}_{\mathrm{lim}})\), that is to say, the dimension of this machined workpiece is less than the desired dimension, the compensation input will be positive. If \(\mathrm{E}_{\mathrm{k}}\) is greater than positive error limit \((+\mathrm{E}_{\mathrm{lim}})\), that is to say, the dimension of this machined workpiece is greater than the desired dimension, the compensation will be negative. For the machine tool, stability and safe operation are of great importance. Under this premise, if the compensation value is very large, the compensation axis may result in irreversible fault. In order to ensure the safety of the machine tool, a compensation limit \(\mathrm{com}_{\mathrm{max}}\) is introduced to avoid excessive fluctuation.