# Dynamic Observer Modeling and Minimum-Variance Self-Tuning Control of EDM Interelectrode Gap
## 3 Order Identification Based on EDM System  
In the actual process, due to the real-time erosion of the workpiece and electrode, the interelectrode gap \(d\) changes dynamically. By detecting the time constant \(\tau\) in real time, the interelectrode gap \(d\) can be calculated by using the interelectrode gap model established by the previous section. In this study, the motion position of the electrode was used as the control input and the interelectrode gap \(d\) as the output. By continuously adjusting the electrode position, the interelectrode gap \(d\) can be precisely controlled. Combined with the characteristics of the EDM system, system identification theory [26] was used to establish a single-input, single-output (SISO) model. On the basis of input and output data, the order of the model was identified. The determinant ratio method directly identified the order of the model by adopting the input and output data. First of all, the data matrix \(\mathbf{H}(\hat{n})\) was constructed. Then, the determinant ratio of the matrix was used to construct the expression \(DR^{*}(\hat{n})\). When \(\hat{n}\) is a positive integer starting from one, if \(DR(\hat{n})\) has a significant increase relative to \(DR^{*}(\hat{n}-1)\), then \(\hat{n}\) is considered to be closer to the true order, i.e., the order \(n_{0}=\hat{n}\) of the model can be taken. The model of single-input, single-output process is described as:  
\[A(z^{-1})y(k)=B(z^{-1})u(k)+\xi(k) \tag{13}\]  
where \(u(k)\) is the input variable of the process. In the identification process, \(u(k)\) represents the moving position of the electrode. \(y(k)\) is the output variable of the process and the interelectrode gap \(d\). \(\xi(k)\) is the uncorrelated random noise with the mean value of zero and the variance \(\sigma_{v}^{2}\). \(A(z^{-1})\) and \(B(z^{-1})\) are the delay operator polynomials:  
\[\left\{ \begin{array}{l}A(z^{-1})=1+a_{1}z^{-1}+\cdots+a_{n}z^{-n}\\ B(z^{-1})=b_{1}z^{-1}+b_{2}z^{-2}+\cdots+b_{n}z^{-n}\end{array} \right. \tag{14}\]  
Figure 6: Distribution relationship between actual gap and model-calculated gap. The estimated value of the model order is \(\hat{n}\), using the existing input and output data to construct the following matrix \(\mathbf{H}_{\hat{n}}\):  
\[ \begin{array}{llllllll}\mathbf{H}_{n}&=&\left[\begin{array}{ccccc}y(n)&y(n-1)& \cdots&y(1)&u(n)&u(n-1)&\cdots&u(1)\\ y(n+1)&y(n)&\cdots&y(2)&u(n+1)&u(n)&\cdots&u(2)\\ \vdots&\vdots&\ddots&\vdots&\vdots&\vdots&\ddots&\vdots\\ y(n+L-1)&y(n+L-2)&\cdots&y(L)&u(n+L-1)&u(n+L-2)&\cdots&u(L)\\ \end{array}\right]\\ =&\left[\begin{array}{ccccc}&\mathbf{Y}_{n}&&&&\mathbf{U}_{n}&&&\end{array}\right] \end{array}  \tag{15}\]  
where \(L\) is the data length. In order to improve the accuracy of order discrimination as much as possible and to reduce the influence of error factors, the following determinant ratio was constructed to determine the order of the model:  
\[DR(\hat{n})=\frac{\det[\mathbf{H}(\hat{n})]}{\det[\mathbf{H}(\hat{n}+1)]} \tag{16}\]  
where  
\[\left\{ \begin{array}{ll}\mathbf{H}(\hat{n})=\frac{1}{L}\mathbf{H}_{\hat{n}}^{\tau} \mathbf{H}_{\hat{n}}\\ \mathbf{H}(\hat{n}+1)=\frac{1}{L}\mathbf{H}_{\hat{n}+1}^{\tau}\mathbf{H}_{\hat{n}+1}\end{array} \right. \tag{17}\]  
When \(\hat{n}\) is a positive integer starting from one and if \(DR^{*}(\hat{n})\) is significantly increased compared to \(DR^{*}(\hat{n}-1)\), then \(\hat{n}\) can be considered as close to the real order of the model, i.e., the order of the model can be taken as \(n_{0}=\hat{n}\). The M sequence is a binary pseudorandom code sequence the autocorrelation function of which is close to the pulse function. However, the M sequences contain DC components, which can cause \"net disturbances\" to the identified objects. The spectral density of the inverted M sequence is similar to that of the M sequence, which is twice as large as that of the M sequence and has no direct current component.