# Dynamic Compensation of a Fluxgate Magnetometer Based on a Hybrid Optimizing Algorithm
## 2 Materials and Methods
### Construction of the Dynamic Compensator for the Fluxgate Magnetometer
#### 2.1.2 Principle and Modeling of Dynamic Compensation  
The dynamic characteristic compensation of the fluxgate magnetometer is to connect a dynamic characteristic compensation linked to the output end of the current sensor system. Thus, a new compensation synthesis system is formed with the current system. The goal of compensation is to reduce the dynamic error between the output of the whole compensation synthesis system and the measured signal so as to improve the dynamic characteristics of the fluxgate magnetometer. The dynamic characteristic compensation principle of the fluxgate magnetometer is shown in Figure 5.  
Where, \(x(t)\) is the measured signal, namely, the input signal of the fluxgate magnetometer, and \(y(t)\) is the output signal of it. After dynamic compensation, the output signal \(y(t)\) of the fluxgate sensor is \(u(t)\). The dynamic compensation link expands the working frequency band of the magnetometer, which reduces the amplitude attenuation and phase difference in the magnetometer to the measured signal. Finally, the output signal \(u(t)\) through the magnetometer and the dynamic compensation link is closer to the measured signal \(x(t)\). The amplitude-frequency response curve of the magnetometer system before and after dynamic compensation is shown in Figure 6. Before compensation, the effective working frequency band of the magnetometer is \(\omega 1\). Through a series dynamic compensation link, the effective working frequency band of the compensation synthesis system is extended to \(\omega 2\) so that the components in a larger frequency range of the measured signal can be collected, and the dynamic distortion of the output signal can be reduced. Figure 5: Dynamic characteristic compensation principle of the fluxgate magnetometer. Considering that the factors and mechanisms affecting the dynamic characteristics of the magnetic sensor are complex, this paper selects system identification and modeling methods to solve the parameters of the dynamic compensator. The dynamic response of the sensor is taken as the input of the dynamic compensator, and the measured signal is taken as the output of the dynamic compensator. The parameters of the dynamic compensator are solved by the optimization algorithm to realize the modeling of the dynamic compensator. The basic schematic diagram is shown in Figure 7.  
In a sampling signal system, the dynamic characteristics of a discrete linear system can be described by the following difference equation [22]:  
\[u(k)+\sum_{i=1}^{m}a_{i}u(k-i)= \sum_{j=0}^{n}b_{j}y(k-j)+e(k) \tag{3}\]  
where \(u(k)\) represents the output of the dynamic compensator at time \(k\), and \(u(k-i)\) represents the output of the dynamic compensator at time \(k-i\). Similarly, \(y(k)\) and \(y(k-j)\), respectively, represent the input of the dynamic compensator at times \(k\) and \(k-j\), that is, the output of the magnetometer at the corresponding time. \(m\) and \(n\) represent the order, and \(e(k)\) represents noise. The output of a dynamic compensator depends not only on its input sequence, but also on the historical sequence of its output. Convert Equation (3) to a vector form:  
\[u(k)=AU_{k}+e(k) \tag{4}\]  
where \(A=[-a1,\,-a2,\,\ldots-am,\,b0,\,b1,\,\ldots bn]\) is the coefficient vector; \(Uk=[u(k-1),\,\ldots,\,u(k-m),\,y(k),\,\ldots,\,y(k-n)]^{T}\) contains the output and input sequences of the dynamic compensator; and \(e(k)\) is noise. Figure 6: Diagram of amplitude–frequency characteristic curves before and after dynamic compensation: (**a**) magnetometer; (**b**) compensation link; (**c**) after compensation. Figure 7: The basic principle of the dynamic compensation solution. The designed block diagram of the compensator is shown in Figure 8.  
The dynamic test signal \(x(t)\) is measured by the magnetometer output signal \(y(k)\), which is also used as the input of the dynamic compensator. After dynamic compensation by the dynamic compensator, the output is \(u(k)\). The dynamic test signal \(x(k)\) is \(x(t)\) after discrete sampling.