Computationally Efﬁcient Magnetic Position System Calibration †

: Properties such as high resolution, contactless (and thus wear-free) measurement, low power consumption, robustness against temperature and contamination as well as low cost make magnetic position and orientation systems appealing for a large number of industrial applications. Nevertheless, one major practical challenge is their sensitivity to fabrication tolerances. In this work, we propose a novel method for magnetic position system calibration based on the analytical computation of the magnetic ﬁeld and on the application of an evolutionary optimization algorithm. This scheme enables the calibration of more than 10 degrees of freedom within a few seconds on standard quad-core × 86 processors, and is demonstrated by calibrating a highly cost-efﬁcient 3D-printed 3-axis magnetic joystick.


Background
Magnetic position and orientation (MPO) sensor systems generally consist of permanent magnets that move relative to magnetic field sensors, which allow for the motion to be determined from the sensor output. They are widely used in the industry to track movements in mechanical systems, having typical motion ranges of a few millimeters up to several centimeters [1,2]. Applications include linear position detection in gear shifts, gas and brake pedals [3], hydraulic and pneumatic cylinders [4], angular position sensing for shaft rotation and wheel speed (in the gear box or for transmission [5]). They can also be employed for joystick position detection [6], as well as for more complex motion tracking of six degrees of freedom [7], which is exploited, for instance, in medical diagnostic applications [8].
Magnetic position sensing principles are remarkably competitive. The non-contact operation makes them practically wear-free and results in long lifetimes, extending up to decades. Magnetostatic field propagation through media such as water, oil dust and dirt makes MPO systems very robust for application in harsh environments like machinery without the need for expensive contamination controls [1]. Combined with the cheap and available fully CMOS-integrated sensor technology [9], MPO systems can provide high resolutions at unmatched cost-efficiency.

Problem and Motivation
The development of MPO systems is an ongoing theoretical and experimental effort dealing mostly with stray field robustness [10], system fabrication tolerances and combining the signals of multiple sensors with sophisticated algorithms [7]. While such complex implementations can achieve a high level of precision and stability, they often neglect the production cost factor, which is a critical aspect for industrial applications. In this context, the Mini-Drive system was proposed to detect the motion of a 3-axis joystick using only a single 3D-sensor and a single magnet [11,12]. However, like with most MPO systems, the major drawback lies in the difficulty to cope with system fabrication tolerances: a high-precision device manufacture would indeed immediately cancel the cost advantage.
In this paper, we extend previous works [13] to show that-despite imprecise fabrication and cheap sensing technology-Mini-Drive-based position systems can be effectively realized by applying a user-friendly, fast and computationally inexpensive calibration algorithm, thereby successfully addressing the industrial demand for maximal cost-efficiency.

The Mini-Drive Implementation
The Mini-Drive represents a specific implementation of a novel concept for a continuously moving 1-sensor 1-magnet 3-axis joystick referred to as MJ113 [14]. In the original theoretical proposal [11], the motion of a joystick lever that can rotate about its own axis is detected, thereby combining 2D tilt motion with a rotation degree of freedom. Similarly to the BMW iDrive system [15], only 5 discrete tilt states are detected, namely the central position and the full tilt in each of the four directions.
A one-to-one correspondence between the mechanical states and the sensor output is achieved by fixing a magnet at the end of the joystick lever with a lateral displacement with respect to the rotation axis and with its magnetization perpendicular both to this sideways displacement and to the lever axis. A 3D-magnetic field sensor is placed centrally below, as outlined in the system sketch in Figure 1. This unique arrangement is patented by Infineon Technologies [12]. For each tilt state, a full mechanical rotation of the lever corresponds to a closed loop in the magnetic state space (see Figure 1c). The specific system layout ensures that these loops are maximally separated from each other and that their corresponding field amplitudes can be measured by the sensor below [11]. While continuous detection of the system rotation state is in principle possible, in this work, we are only interested in measuring reasonable steps of 2/3/5/10 degrees, corresponding to 180/120/72/36 states per loop, respectively. The original BMW iDrive system is limited to 28 states per loop.

System Fabrication
The mechanical components of the Mini-Drive are manufactured using a high-resolution 3D Systems HiQ + HS industrial 3D printer and a polyamide-based powder (PA2200) as printing material, which makes the fabrication very cost-effective. The design follows the original proposal by [16]. Figure 2 shows the individual components as well as the assembled device from different perspectives. The joystick lever is endowed with a center ball which defines the center of tilt and allows for full rotation of the lever about its axis. A cross-shaped cavity in the upper half of the device housing limits the possible tilts to four discrete directions only. The center ball is pressed into a circular cavity of the lower housing by a "hat". The force is generated by printed springs in the upper housing such that the lever recovers its zero-tilt position as soon as the user releases it. An off-the-shelf cubical NdFeB permanent magnet is embedded in a cavity at the bottom of the lever. Finally, an Infineon XMC2Go test board [17] is integrated in the system in such a way that its TLV493D-A1B6 3D Hall magnetic field sensor [18] is located directly below the magnet and lies on the axis of rotation of the joystick lever. The low-cost 3D Hall sensor features a small PG-TSOP6-6 package (2.9 × 1.6 × 1.1 mm 3 ), low power consumption, various digital signal compensations, 12-bit data resolution in each direction and a measurement range of ±130 mT.

Read-Out
While it is relatively easy to compute the magnetic field generated by a permanent magnet in a given position in space, the inverse problem-i.e., determining the magnet position starting from a magnetic field measurement-is often mathematically ill-posed and computationally demanding [19,20]. One of the biggest challenges of MPO system design is to solve the inverse problem within milliseconds to enable real-time measurement and interaction. To make things even more difficult, there are generally no computation resources available beyond the sensor ICs or microcontrollers. Most state-of-the-art systems solve this problem by approximating the field with simple functions that are easily invertible, as for instance the arctan2-function in linear position applications [3,4]. Such approximations are only suitable for systems with few degrees of freedom, whereas more sophisticated systems perform direct numerical inversion on 3D approximations of the field, that are based either on analytical solutions of permanent magnet problems or on simple look-up tables [7,8].
The Mini-Drive read-out is based on a look-up table, which is highly efficient thanks to the small state space (only five loops with 36 to 180 rotation states each, see Section 2.1). The inversion is computed by direct comparison between the measurement and the look-up table, which takes only a few milliseconds on the XMC-1100 microcontroller.

Calibration Procedure
Several system tolerances arise from the cheap Mini-Drive fabrication, including variations in the position and orientation of magnet and sensor and inaccuracies in the joystick positioning, rotation and tilt. Moreover, imprecise magnetization of the magnet also affects the system, along with variations of the sensor characteristics or environmental disturbances. In order to eliminate the influence of the major tolerances, we propose a simple procedure in which the user is asked to provide four well-separated measurement points for each magnetic loop. As the absolute rotational positions are not required, such calibration data are easily generated via four consecutive 90 • rotations, each followed by one tilt in all directions. A detailed description of the user calibration scheme is reported in [21].
The calibration task consists of fitting the magnetic loops onto the calibration data by variation of the system tolerances. Our implementation combines a differential evolution optimizer [22] with an analytical computation of the field of cuboid permanent magnets [23]. The cost function to be minimized via least squares fitting is based on a badness value, which is defined for all states as the ratio of the distance from the correct loop to the distance from the nearest incorrect loop. This cost function choice ensures that the correct tilt states are favoured over the incorrect ones.
The fields are computed using the Magpylib toolbox [24], which provides a user-friendly Python interface, specifically designed for dealing with MPO systems. Comparison to finite element computations shows that the relative error of the Magpylib analytical solution is less than 1%. One of the main reasons for choosing a cuboid permanent magnet is that the analytical solution for the field is a closed-form expression and a vectorized implementation of its results is achieved within effective computation times of a few microseconds on standard ×86 CPUs [24]. The fast computation times granted by this approach are necessary to feed the evolutionary optimizer which, in turn, can draw additional performance from multi-processing. This implementation can compute 8-12 tolerances within few seconds on simple mobile hardware like an Intel core i5-8365U.
The calibration yields a set of tolerances that can then be used to compute the five magnetic loops for the creation of a look-up table of arbitrary rotational discretization. It is critical to note that curve fitting based on more calibration data is not a viable option, as the rotational states are not equally spaced on the magnetic loops and the calibration data have no absolute rotational position. Figure 2a shows the main geometrical parameters of the Mini-Drive: the distance from the center of tilt d CoT (measured between the upper surface of the magnet and the geometrical center of the centerball), the magnet lateral displacement x displ (defined as the distance between the lever axis and the vertical plane cutting the magnet in a half), the airgap ∆ (namely the distance between the magnet lower face and the sensitive area of the TLV493D-A1B6 sensor, located 0.65 mm below its packaging [18]) and the maximum tilt angle θ max . A batch of 15 Mini-Drives was 3D-printed with the following nominal features: d CoT = 6.3 mm, x displ = 3 mm, ∆ = 3 mm and θ max = 10 • . The corresponding uncertainties are δ d CoT = 0.3 mm, δ x displ = 0.1 mm, δ ∆ = 0.3 mm and δ θ max = 0.2 • , respectively (as inferred from repeated length measurements performed on the devices). The side length of the cubical magnet is l = 5 mm with an error δ l = 0.1 mm (as provided by the supplier).

Measurements
In order to gain an insight into the influence of the fabrication tolerances, for each device the magnetic field components were recorded 200 times for every individual tilt state, while manually rotating the joystick lever around its axis. The points in Figure 3b refer to a single Mini-Drive, whereas Figure 3a displays the measurement output from all the joysticks: due to the fabrication tolerances, large variations can be observed among the states of the various devices in the magnetic field space.

Calibration
The result of a calibration which includes magnet position (3 degrees of freedom, DoFs), magnet magnetization (3 DoFs), tilt angles (4 DoFs) and sensor position (3 DoFs) is shown in Figure 3c. For each tilt state, 50 magnetic field measurements are recorded and their distance to the respective theoretical loops is displayed in mT. Cross markers correspond to the uncalibrated states, while circular markers refer to the calibrated ones after the application of the 4-point procedure outlined in Section 2.4. The orange region marks the nearest incorrect tilt state. As many uncalibrated states lie above this false-tilt threshold, the uncalibrated system would yield incorrect outputs. The calibrated states, on the contrary, lie much closer to the correct loops (<8 mT) than the wrong ones (>17 mT), thereby making their exact identification a simple task.
Still, it seems that the calibrated states can lie quite far (3-8 mT) from their designated circles, see e.g., the yellow peaks between position 150 and 200 in Figure 3c. This is due to both the cheap mechanics and to the fact that the user moves the joystick by hand to collect the data. The result of a full calibration where all the 250 measurement points are used in the algorithm instead of only 4 per loop is indicated by the black solid line and the gray region. By comparison, we can conclude that the 4-point calibration is surprisingly efficient, as the best possible result is mostly achieved. The use of less than 4 points proved unstable for the calibration, while the employment of more points did not bring any significant improvement.

Conclusions
In this work, we reported on the successful application of a novel scheme based on analytical methods for the calibration of a 3-axis magnetic joystick-the Mini-Drive-manufactured via 3D printing. This calibration method makes use of the analytical solution for the magnetic field and-taking advantage of the fast analytical field computation-applies a differential evolution algorithm to solve a multivariate optimization problem that includes multiple relevant fabrication tolerances. The calibration procedure requires the measurement of only four points for each tilt with unknown rotational position, which is easily and quickly carried out by an end-user.
This novel scheme enables the calibration of more than 10 degrees of freedom within a few seconds on conventional PCs, thereby making it possible to cope with the fabrication tolerances without the need to resort to a high-precision manufacture that would nullify the cost-efficiency of the system. Ongoing work is devoted to study the potential of this method for the design and calibration of innovative, exotic and inexpensive magnetic position systems. Funding: This project has been supported by the COMET K1 centre ASSIC Austrian Smart Systems Integration Research Center. The COMET (Competence Centers for Excellent Technologies) Program is supported by BMVIT, BMWFW and the federal provinces of Carinthia and Styria.