# Adaptive Algorithm for Fast 3D Characterization of Magnetic Sensors
## 2 Materials and Methods
### Adaptive Filter  
In this contribution, we assume a high similarity between sensor system responses to magnetic excitation from similar directions. We want to exploit this by initializing a directional response estimate with the last finished estimate from an orientationally close excitation. For that, we use a normalized least mean squares (NLMS) algorithm to estimate the sensor's impulse response  
\[\mathbf{h}=\Big{[}h_{0},h_{1},\ldots,h_{N-1}\Big{]}^{\mathrm{T}} \tag{10}\]  
of length \(N\). We assume a maximal filter length that can capture the full sensor behavior. Our goal of a precise impulse response estimation is a system identification task for which a generalized representation based on [24] is shown in Figure 4. Here, idealized digital-analog conversions and vice versa are assumed. This is also assumed in the following derivations to highlight the parallels between the physical system and the estimated model taken advantage of by the NLMS. The sensor produces the ideal sensor output \(d(n)\) due to excitation with the signal \(x(n)\), which is connected via the impulse response by the relation  
\[d(n)=\mathbf{h}^{\mathrm{T}}\mathbf{x}(n). \tag{11}\]  
The respective signal vector \(\mathbf{x}(n)\) consists of the last \(N\) samples of the corresponding time signal. This ideal output is then superimposed by some noise \(b(n)\) from various sources (e.g., magnetic (Barkhausen) noise, electromagnetic noise from circuit components such as amplifiers and superimposed interference signals, \(1/f\) noise, mechanical noise [25; 26]) to produce the measured output signal \[y(n)=d(n)+b(n). \tag{12}\]  
The adaptive filter \(\hat{\mathbf{h}}(n)\) is excited with the same signal \(x(n)\) and provides an estimated output signal  
\[\hat{d}(n)=\hat{\mathbf{h}}^{\mathrm{T}}(n)\,\mathbf{x}(n), \tag{13}\]  
which ideally should reproduce the measured output for the sensor. Correspondingly, the error for this adaptive filter is defined as  
\[e(n)=y(n)-\hat{d}(n), \tag{14}\]  
with a small error indicating a good adaptation of the filter to the actual sensor system (including noise); thus, the error is a good estimate of the sensor characteristics for the chosen excitation. Only real-valued time signals are considered in this work, so notation considering generally possible complex-valued signals is omitted. We also use a reference channel to eliminate the influence of digital-analog conversions and vice versa in the overall system (cf. Figure 1) by using a direct feedback channel in addition to the coil excitation channels on the output and the sensor voltage at the input. We use the adaptive identification approach with the minimization of the expected value of the system distance between the real sensor and the estimated system  
\[\mathrm{E}\bigg{\{}\Big{\|}\Delta\mathbf{h}(n)\Big{\|}^{2}\bigg{\}}=\mathrm{E} \bigg{\{}\Big{\|}\mathbf{h}-\hat{\mathbf{h}}(n)\Big{\|}^{2}\bigg{\}} \tag{15}\]  
as our optimization target over time [24]. The adaptation procedure is generally based on a gradient-based incremental linear change to the current filter estimate \(\hat{\mathbf{h}}(n)\) from one time step to the next. Thus, a general update of the filter coefficients can be described with the time-varying scaling step size term \(\mu(n)\) and a correction term \(\Delta_{\mathrm{corr}}\big{(}\mathbf{x}(n),e(n)\big{)}\) depending on the excitation signal vector and error signal as  
\[\hat{\mathbf{h}}(n+1)=\hat{\mathbf{h}}(n)+\mu(n)\,\Delta_{\mathrm{corr}}\big{(}\mathbf{x} (n),e(n)\big{)} \tag{16}\]  
with the correction depending on the chosen adaptation scheme. Our choice for this scheme, as mentioned above, is the NLMS algorithm, which extends this correction term to  
\[\Delta_{\mathrm{corr}}\big{(}\mathbf{x}(n),e(n)\big{)}=\mathbf{x}(n)\frac{e(n)}{\|\mathbf{ x}(n)\|^{2}}. \tag{17}\]  
Figure 4: Adaptive filter used for system identification.