Fast, cheap, and scalable magnetic tracker with an array of magnetoresistors

We present the hardware of a cheap multi-sensor magnetometric setup where a relatively large set of magnetic field components is measured in several positions by calibrated magnetoresistive detectors. The setup is developed with the scope of mapping the (inhomogeneous) field generated by a known magnetic source, which is measured as superimposed to the (homogeneous) geomagnetic field. The final goal is to use the data produced by this hardware to reconstruct position and orientation of the magnetic source with respect to the sensor frame, simultaneously with the orientation of the frame with respect to the environmental field. Possible applications of the setup are shortly discussed, together with a synthetic description of the data elaboration and analysis.


Introduction
Magnetic field measurements can be performed with a variety of sensors, whose sensitivity, robustness, dynamic range, linearity, reliability, speed, simplicity, and cost range in very broad intervals. The state-of-art sensors in terms of sensitivity are based on the superconductor quantum interference devices (SQUIDs) and surpass the sensitivity level of 1fT/ √ Hz, their main drawback is the need of cryogenics. Optical atomic magnetometry constitutes another technology that in some implementations -particularly in the so called Spin-Exchange-Relaxation-Free (SERF)-may compete with SQUIDs in terms of sensitivity. It enables also the construction of relatively simple and robust sensors with sensitivity at the pT/ √ Hz level, including miniaturized devices, and implementations with a high-frequency response. Optical atomic magnetometers (OAMs) do not require cryogenics. On the other hand, they are based on spectroscopy in high quality vapour cells and commonly ligthed with laser sources, both features making them expensive and not easily integrable in solid state devices. When these extreme performances are not required, fluxgate technology offers an eligible alternative, on the basis of which different grades of sensors are produced with a rather wide range of sensitivities and costs. When sensitivities of the order of nT/ √ Hz are sufficient, beside low cost fluxgate sensors, the solid-state technology offers nowadays extremely cheap and easyuse devices based on the magnetoresistive effects. The magnetoresistive effect (discovered and formerly studied by lord Kelvin [1], [2]) in its giant [3], tunnel [4], and anisotropic [5] occurrences is profitably used to measure fields of several tens of micro Tesla, i.e. of the order of the geomagnetic field, with typical sensitivities in the nT/ √ Hz range and bandwidth extending up to kHz, or -depending on the implementation-to MHz and beyond [6]. Devices based on magnetoresitance (MR) with sensitivity levels attaining the pT/ √ Hz above 1 kHz have been reported [7]. The magnetoresistive sensors (similarly to SQUIDs and fluxgates, and in contrast to typical OAM magnetometers) are vectorial in nature, i.e. respond to single components of the magnetic field: an assembly of three orthogonally oriented sensors enables a complete measurement of the magnetic field vector. Other popular solid state sensors are based on the Hall effect, their sensitivity and accuracy is worse than MR and they are more commonly used to roughly estimate (or rather just to detect) relatively strong fields.
A synthetic, rough overview of the available technologies and of the accessible bandwidth and sensitivity intervals for magnetometric measurements is provided in Fig.1 The success of MR technology is also related to its easy integration with silicon-based electronic devices. Integrated circuits (ICs) containing one or more magnetoresistive elements became recently very popular, and their cost decreased by order of magnitudes in the last decade thanks to large-scale production: nowadays twoor three-axis devices are widely used as sensors for electronic compasses, such as those contained in smartphones and drones. Other applications of these cheap sensors Indicative and approximate representation of typical field and frequency ranges for different kinds of magnetometry technologies and of their possible applications. Magnetoresistors match requirements for navigation an tracking, while higher sensitivity is needed for biomagnetic detection (as in magnetocardiography MCG and magnetoencephalography MEG), where SQUIDs and AOM are the eligible choices. AOM in their radio-frequency (RF) implementations offer excellent performance at high frequencies. Flux gate sensors are produced different grades of performance, and partially overlap with the MR applicability. Hall sensors are relegated to evaluating stronger fields, with quite smaller precision.
include virtual and augmented realities, navigation, nondestructive evaluation, and various industrial activities [6], [8], [9]. Modern MR ICs contain not only magnetoresistive sensors but also signal conditioning and DAQ electronics, together with special reset circuits that facilitate the MR use and improve reliability and reproducibility of their response, as well as circuitry for digital data transfer.
We concentrated our attention on a family of ICs designed for I 2 C transmission of 3D magnetic data, which allow for an acquisition and data transfer rate as fast as 200 readings (3 data per read) per second. Due to the typical presence of a single sensor per user, in most cases these ICs have a static, not reconfigurable I 2 C address. Some devices have indeed reconfigurable address. In the case of the IC used in our prototypes two address configuration pins (for a maximum of four chips per bus are available). This limitation leads, when a sensor array is needed, to develop control-interface circuits with a parallelized architecture. At a cost of the obviously heavier circuitry, such an approach brings the second (but not secondary) advantage of accelerating the data acquisition and making it simultaneous all over the sensor set.
The aim of our work is to acquire at a relatively high rate (hundreds samples per second) magnetometric data sets that can be elaborated to reconstruct the position of magnetic field sources, i.e. to track their spatial coordinates and the angles of their orientation. In the frequent case of a simple source like a magnetic dipole [10], [11], [12], the tracking procedure does provide three spatial coordinates and three components of the magnetic dipole. As soon as the measurement is performed in an external field (such as the geomagnetic field, which can be assumed homogeneous over the volume of the sensor frame), three more field components have to be worked out, that is a total of 3 + 3 + 3 = 9 tracking data to be extracted per measurement. These 9 data contain redundant information in the case of repeated measurements, because both the modulus of the dipole moment and the modulus of the ambient field can be assumed constant. In other terms, rotations of the dipole around its direction and rotations of the sensors around the ambient field do not cause field variations. In other terms, in the assumption that the intensity of the magnetic source and/or of the environmental field are constant, the number of freedom degrees (and hence of fit parameters) would be reduced from 9 down to 8 or 7.
The information about the two blind co-ordinates could be retrieved by using a non-dipolar source (e.g. a set of two rigidly connected dipoles) and complementing the environmental magnetic field with a measure of the gravitational field. In this paper, we will not address these possible improvements. The use of non punctual sources, with the introduction of multipolar terms that break the dipolesymmetry has been successfully attempted and reported in the literature [13]. Similarly, the system could be used to track two or more dipolar sources arbitrarily located with respect to each other [14], [15]. In this case, the enhancement in the source degrees of freedom would require more computing resources and an increase of the minimal number of sensors.
The capability of tracking objects with adequately fast time response is a challenging and intriguing achievement, with important implications in several research and application areas. In particular, tracking methods based on magnetometric measurements offer a minimally invasive methodology and has been studied/proposed in a variety of applications, including medical diagnostics [16] tracking of vehicles [17], biology [18], robotics [19].
Further possible applications may arise in diverse other areas, also depending on the precision and speed that can be achieved, like body part tracking (such as eye, tongue, hand, finger), human-computer interfaces, virtual and augmented reality etc.
Several approaches have been proposed to face the inverse problem of reconstructing the field source parameters from the field measurement (see e.g. ref. [20] and references therein). Depending on the application, required accuracy, precision, robustness and speed of the tracking procedure may change, and different methodologies can be applied.

I. setup overview
We have designed and built an interface circuit capable of operating arrays made of up to eight threeaxis MR sensors, which can be variously disposed and grouped in the space. A picture of a sensor array and Figure 2. The prototype of the electronics equipped with a sensor array designed to perform eye tracking. The eight three-axial sensors appear in the two parallel PCBs on the left, while the acquisition, recording and data-transfer electronics is implemented in the PCB on the right, where batteries and USB connector are visible. The flat connection allows to interface the PCBs with 3+5 or 4+4 sensor arrays.
interface electronics is shown in Fig.2. A PCB hosting micro-controller, eeprom memories, internal and external supply circuitry and USB interface is connected to two sensor boards which can host 4+4 or 5+3 IC sensors (as in the case shown in that figure). Each sensor has a dedicated I 2 C bus for communicating with the microcontroller. The latter may send commands (and receive data) simultaneously to (from) the eight sensors. The data can be either immediately transmitted to the computer or stored into an eeprom memory for successive download. The second option is used in the calibration procedure (see Sec.IV below). Details of the available functionalities and consequent possible operations are provided in the next sections. These are designed in view of producing fast (real time) tracking devices with a high throughput rate (hundred trackings per second) and high precision (submillimetric spatial and 2 degree angular resolutions).

II. Sensor specifications
The ICs Isentek 8308 [21] is a three axis magnetometer based on anisotropic magnetoresistance effect, whose main characteristics are reported in Tab.II. The chip implements reset, temperature compensation and analog-todigital conversion circuitry, and communicates trough an I 2 C port. Both on-demand and continuous data outputs can be queried. The maximum data acquisition rate is 200 Sa/s, and different kinds of internal filters can be activated to improve the the S/N ratio at expense of the actual bandwidth. Sensitivity and offset have nonnegligible deviations from ideality so that a calibration is necessary (see Sec.IV). These parameters may also change with time and (slightly) with temperature, so that an adequate measurement accuracy can be kept at the cost of repeated calibrations. It is worth noting that the temperature compensation circuitry helps reducing this problem since the effects of typical daily environmental temperature drifts can be neglected. In our implementation, a temperature sensor has been included, so that the user knows both the temperature at which the calibration data were collected and the current temperature: an alert is provided when the deviation exceeds a threshold, making a new calibration advisable. A data-consistency analysis is also available to point out the need of recalibrating the unit, as discussed at the end of Sec.IV.

III. Scalability
The system developed aims to measure simultaneously the environmental field and the field generated by a small, closely located magnetic source (target). The finite dynamic range of the sensors makes necessary to deal with fields contributions of comparable intensities. This condition should be fulfilled at least on a sensor subset providing a number of independent data sufficient to localize the target, i.e. not smaller than the number of freedom degrees of the system.
Good operating conditions can be identified as those in which the target generates on the sensors fields ranging from 1/10 to 10 times the ambient field. So, keeping in mind the environmental field normal value of some tens of µT, the 1/r 3 dependence of the dipolar field, and the typical magnetization values of permanent magnets (about 1T/µ 0 for the used Nd devices), one finds that the best condition is fulfilled when the sensor-target distance is about 50 times larger than the linear size of the magnet. E.g., a one cm 3 magnet produces a field comparable to the Earth one at about a half-meter distance. The chip size being sub-millimetric, this thumb rule applies when scaling down the system size as long as the sensor-target distance still remains much larger than the sensor size (e.g., targets as small as 1 mm size can be used at a distance of about 5 cm from the sensors).
Of course, accordingly to the required tracking accuracy, the sensor positions must be known with an adequate precision. In our case, the latter is determined by the PCB mount and is definitely submillimetric. However the determination of the sensor positions can be improved on the basis of magnetometric data analysis [22], and in some of our preliminary prototypes such kind of procedure resulted to be crucial to guarantee the reliability of the tracking algorithms.
IV. Sensor calibration MR sensors have a relatively accurate response in terms of linearity, but suffer from important offset and variable gain. Moreover both gain and offset may vary with temperature and change in time. In addition, unpredictable values are found after powering the device on.
An important improvement has been introduced on the basis of a pulsed field cycling technique. This technique of reset field pulses has been also studied to improve the ultra-low frequency performance of MR devices [23]. Modern magnetoresistance ICs contain apposite inputs to apply reset pulses (strong current pulses flow in a conductor built in the proximity of the magnetoresistive element, in order to re-magnetize its components in an appropriate and reproducible way).
In more integrated devices the current pulses are produced internally and the reset field cycle is automatically applied at the restart. The reset operation brings the sensor to work properly (reasonably low offsets and reasonably ideal gains along all the axes); nonetheless whenever good accuracy is required, some calibration procedure [24] is advisable or necessary. In fact, the final offset value is substantially non-zero, and the gain may differ by several percents among the sensors contained in a single IC. An accurate evaluation of offsets and gains makes it possible to convert the raw data into field measurements, so to overcome these non idealities.
Our setup includes both in the H/W and in the S/W apposite parts devoted to facilitate the calibration procedure. Similarly to what described in Ref. [24], the calibration procedure is accomplished by recording many data (simultaneously for all the 3D sensors of the array) while rotating the system freely and randomly in a (nominally) homogeneous field. In this measurement, each sensor feels the magnetic induction vector B as it moves on a spherical surface centered in the zero-field point of a Cartesian coordinate system: whenever the measured quantities V does not span a spherical surface, this can be due to non-zero offsets, to unequal gains, and to non-linear terms in the sensors' response. In the hypothesis of a linear response, the measured quantities describe an off-center ellipsoid rather than a centered spherical surface: the displacement of the center is then caused by the offsets, while the eccentricity is due to the gain anisotropy.
It is worth noting that similar calibration procedures based on static measurements have been proposed, as well. It is indeed possible to build up a tri-axial field generator, finely calibrate it with the help of a scalar magnetometer and then use it to produce a rotating field of an assigned intensity. The latter can be, in turn, applied to calibrate vectorial sensors such as triaxial magnetoresistive devices [25].
An optimization procedure is used to determine offsets and gains for all the sensors, and to save those values for successive data conversion. As described below (see Sec.V), this kind of calibration measurement is more favourably performed with no cable connection. The optimization is usually done over data sets containing several hundreds measurement (a maximum of N=2000 measurements is set by the eeprom memory size) the minimized quantity being where B 0 is the field modulus (arbitrarily set), k is the sensor index running from 0 to K − 1, O (k) j are the offset vectors to be determined, T (k) ij are elements of triangular matrices (to be determined), and n denotes the measurement index (running from 1 to N). The elements T (k) ij are ideally equal for i = j (the inverse gains), while the offdiagonal elements are ideally zero for i > j. In contrast the diagonal element can be different from each other if the gain is not isotropic, and the off-diagonal element could be non-zero, in the case of possible small misalignments (imperfect orthogonality) of the three axes.
Let the optimal offsets and conversion matrices be given by O (k−opt) j and T (k−opt) ij , respectively, and let's define that is the i th component of the field in the position r k of the k th sensor, as obtained from the sensors output V j in the n th measurement. Then, as the offsets are removed and the response has been made isotropic, further calibration is necessary to refer all the sensors to one co-ordinate system. To this aim, the data recorded in the mentioned calibration measurement are compared to each other. One sensor (let it be the 0 th one) is selected as a reference one, and a rotation matrix is determined for each sensor with k = 1...K − 1, by minimizing the vector differences between the field measured by that sensor and the reference one. In our implementation the rotation matrices are defined in terms of Euler angles, and the minimized quantities are where R ) are rotation matrices defined by the three angles θ (k) , φ (k) , ψ (k) to be determined for each k = 1...K − 1.
In conclusion, each of the K sensors requires the determination of nine parameters (three offsets, three gains, three orthogonality-imperfection-compensation terms) for the conversion of the recorded values V (k) into magnetic induction vectors B (k) and each sensor (apart from the reference one) requires the determination of three rotation angles. The whole set of m = 9K + 3(K − 1) calibration parameters (m = 93 in the considered case of K = 8 sensors) is saved at the end of a calibration procedure and made available to perform the V → B conversions in the subsequent measurements.
Once the calibration parameters have been determined, a field estimation referenced to a unique Cartesian frame is available. This enables an additional procedure to check the validity persistence of the calibration parameters on the fly. This validation is performed by comparing the field components measured by the K sensors in homogeneous field with their median value. In particular, the software evaluates, for each sensor, the quantity where B k,n,i denotes the i th component of the field as measured by the k th sensor at the n th measurement in a set of N , andB k,n,i denotes the median value of the i th component of the field measured by the K sensors at the n th measurement. The presence of anomalously large E k values produces an alert, and the user can disregard the data from the corresponding sensor(s) in the subsequent tracking, or decide to execute a new calibration procedure.
V. Power supply The circuit is normally supplied through the USB port, however it is possible to start it in a battery-supply mode, in order to acquire and store the calibration data with no cable constraints. To this aim, there is a button connecting the battery, and a button starting the calibration measurement, When the calibration measurement starts, a circuit maintains the battery connection. During this selfsupplied operation, a flashing led denotes the acquisition. At the end of the acquisition, the self-supplied mode is maintained for a 30 sec delay, during which the operator can restore the cable operation. In this manner, the circuit remains supplied, and no reset pulses are applied. This feature is designed to guarantee that the acquired data accurately describe the sensor response, since the latter could be modified in the case of a ICs reboot, due to the automatically applied reset pulses.

VI. Parallel I 2 C buses
Apart from the problem arose from the fixed I 2 C address (a feature that characterize many MR IC types) it is advantageous to parallelize the communication with sets of ICs, both to accelerate the global data acquisition rate and to enable simultaneous (i.e. mutually time-consistent) measurements. We have studied and developed a simple but effective circuit enabling both parallel data reading from the sensors and fast composite data transmission to PC. The developed electronics may communicate (for H/W configuration and for data transfer) with eight (K = 8) chips at once, providing thus up to K × 3 magnetometric data per reading. The data transfer rate is limited either by the sensor throughput rate over the I 2 C bus or by the composite data transmission rate over the USB port: in the present implementation a rate as large as 100 Sa/s (2400 data/second) has been demonstrated, while a 200 Sa/s (4800 data/second) is the limit set by the IC specifications. Concerning the USB communication, it is a potential bottle neck. It is machine dependent and may vary unpredictably e.g. with the number of processes running in the computer, and particularly with the presence of other interfaces connected. An overview of the firmware principle of operation is represented in Fig.3. The system can be switched on in two ways:

VII. Firmware
• by connecting the USB cable to a PC • by pressing the power button on the circuit In the first case, the system is supplied by the PC, while in the second case a on-board battery is used (the second case is used in the wireless calibration).
When the system starts up, the peripherals of the microcontroller are configured and the variables used (MCU Init) are initialized. In particular, among the configured peripherals, it is worth mentioning the ADC converter which measures the supply voltage and the timer for the real time operating system (RTOS) described below. In addition, a map of the sensors that are actually connected is built. The latter is then used when the data are transferred from the parallel I 2 C buses to the on-board memory or to the USB interface, as described in Sec.VI.
Then a test is performed to verify if the system has been started by connecting the USB cable or by pressing the power button; in the second case a switch (mosfet transistor) is closed, to maintain the battery power supply when the power button is released by the user.
At the same time it is evaluated whether the system calibration button (P0) was also pressed during the powerup phase; in this case a flag variable called cal_Flag is set to True. This flag is used during the operation of the RTOS. The next operation (Sensor Init) is the initialization of the sensors that have been detected and included in the sensor map. Now the RTOS can start. The scheduler rules the execution sequence and times of the various programs (tasks)within an iterated cycle. During this cycle it is evaluated for each task whether it is time to run it on the basis of the time elapsed after the last execution: individual time intervals are defined for each task.
The tasks to be performed are: • Reading the state of the buttons (Read buttons) (every 5 ms) • Granting communication between the module and the PC via an USB interface (USB) (every 10 ms). If the buffer contains a character, this is added at the end of a string variable. If this character is a line termination character, the string variable is analyzed by a subroutine (Parser) and, if it is recognized as a valid command, such command is executed. • Performing other operations (every 1 s). These operations consist in testing whether the USB cable has been connected then disconnecting the battery from the system to prevent unnecessary discharge; if, during the calibration phase, the P0 button is pressed, the system is switched off; the same thing happens after a preselected period of time following the end of the system calibration, as well. • Reading the MR sensors the period is determined by the Conv_rate or Cal_rate variable • Reading the temperature sensor (every 100ms) The flowcharts of two significative tasks are represented as an example in Fig.4 VIII. Data transfer The data transfer can be performed both in ASCII format (useful for debugging) and in binary format. The measurement can be executed both one by one (on demand) and continuously. In the second case, a "start-conversion" command is sent, and a continuous data flux is transferred (the DAQ rate has been previously set and can be as large as 200 Sa/s) until a "stop-conversion" command is sent. In these conditions the binary transmission is compulsory, to prevent data overflow. A peculiar transmission protocol has been designed to detect transmission errors. As seen in Sec.II, the data are signed two-byte integers. However the 14 bit resolution makes some values impossible to be generated. We use this feature to implement a onebyte transmission check. The values are transmitted after having been added to 2 14 (so to make all of them positive) and after having doubled the result (so to make all the data even). Under this condition, neither the most significant byte nor the least one can be "FF", and such reserved "FF" value is used as a end-of-line marker in the USB communication. The received data are then truncated at the "FF" byte, and the whole data set is disregarded whenever "FF" does not occur after K × 3 × 2 significant bytes. This features improves the system robustness to data-transfer misalignments.

IX. Data elaboration
The computer program that controls the device is written in LabView. It contains several units designed to • Initialize the communications • Set the sensor settings (FS, filters, acquisition rate) • Check the temperature • Download the raw calibration data from the eeprom • Analyze the calibration data and infer the conversion parameter set • Start the measurement • Convert the raw data into magnetic values • Analyze the magnetic data to track the magnetic target • Show and save the tracking output The first operations are made at the start or on demand, while the last two tasks are performed online and require accurate programming to prevent data overflow with consequent lost data or delayed system response. Particular care must be devoted to the data analysis program which infers the target position and orientation from the magnetometric measurement. Details about this problem are extensively provided elsewhere, while here we shortly summarize the methodologies applied to this aim.
The software implemented to extract tracking data from magnetometric data is based on a standard best-fit procedure using a Levenberg Marquardt algorithm [26], [27], [28], [11]. The input data are the magnetometric values and a set of sensor co-ordinates, the magnetic target is modeled as a dipole, and the target function of the best-fit procedure is set as the dipole field superimposed to a homogeneous field. The fit output consists of 9 values representing parameters three spatial co-ordinate of the dipole, three dipole moment components, and three background field components (we are neglecting the redundancy mentioned in the introduction). The need of determining 9 co-ordinates makes evident that the thumbrule discussed in Sec.III should apply for at least three 3D sensors, with obvious advantages in terms of accuracy and reliability when a larger number of sensors are close enough to detect the inhomogeneous field generated by the target. Assuming that the target moves slowly with respect to the acquisition rate, every fit output is profitably used as a guess for the next evaluation [14]. As known, a reliable guess helps greatly accelerating the convergence of nonlinear functions as those used in the present case.
To date, a last-step-output guess has proved to work efficiently in tests with sources moving at a speed of a few cm/s and rotating at a few rad/s. More advanced guessing, based on the analysis of a longer tracking history, could be developed for faster magnetic sources and will be assessed in future work.
We verified that an ordinary personal computer with a single last-track guess, is capable to run the best-fit procedure in a time shorter than the 10ms acquisition time, so to provide an estimation of the target position and orientation before that a new data set is acquired, thus getting substantially a real-time functionality.

X. Conclusion
We have built and tested a cheap and reliable hardware based on commercial magnetoresistive sensors that, after appropriate calibration procedures, provides a set of 24 magnetometric measurement data with a rate as large as 100 Sa/s. The hardware contains a microprocessor enabling immediate data transfer to a personal computer, which in turns executes data elaboration to extract multidimensional (from 7D to 9D) spatial and angular coordinates of the magnetic source with respect to the sensor array and of the latter with respect to ambient field. The tracker is scalable in size and can be of interest for several kinds of applications ranging from medical diagnostics to virtual and augmented reality.
The subject of this work, in virtue of its interesting potentialities and of its demonstrated performance in terms of precision and speed achievable, belongs to the contents of a recently applied patent [29].