SBAA512 July   2021

# 1 Application Brief

## Introduction

The ability to monitor the position of a moving object and provide feedback to a microcontroller improves mechanical precision and adds to the overall utility and quality of any mechanism. Depending on the motion being tracked and the format of the system feedback, a variety of sensing options are available.

When Hall effect sensors are used for this purpose, position encoding becomes a contact-free solution capable of detecting motion of objects moving freely in almost any environment.

Of particular interest, 3D Hall effect sensors offer a unique ability to provide information about the complete magnetic field, which enables absolute position detection for any 3D movement. This makes these devices particularly valuable for a wide variety of position sensing applications such as joysticks, linear position modules in automated systems, and gear shifters as a few examples.

## Magnet in Free Space

When considering a 3D Hall effect sensor, the immediate thought is that any magnet moving in free space about the sensor could be easily detected and monitored. If we consider that there is often symmetry of the magnetic field about the pole of a magnet, then we can quickly deduce that there might be multiple positions that could produce the same input condition. As a result, this function does require careful planning in order to successfully determine absolute position.

Any dipole magnet might be used for this purpose, and efforts to manually position the magnet around a sensor will produce changes along each axis. The challenge, however, is ensuring that the change in magnetic flux density can be used to distinguish the motion of the magnet.

Figure 1-1 Example Magnetic Fields

Inspecting the vector lines closely, two relative positions appear to solve this challenge. Placing the sensor centered on the axis of polarization provides an input to the sensor which is easily identified and unidirectional regardless of distance to the magnet. Similarly, placement coplanar with the pole boundary will produce this same effect. At this location, the vector will be parallel to the face of the magnet irrespective of the range to the sensor.

Figure 1-2 Unidirectional Vector Locations

These two locations are most easily aligned to the sensor and therefore provide the simplest means to demonstrate this concept.

In the case where the sensor is oriented along the axis of the cylindrical magnet, we might then determine the proximity to the magnet by examining the magnitude of the input field and calculating distance using Equation 1

Equation 1. $B\left(z\right)=\frac{{B}_{r}}{2}\left(\frac{z+T}{\sqrt{{r}^{2}+{\left(z+T\right)}^{2}}}-\frac{z}{\sqrt{{r}^{2}+{z}^{2}}}\right)$

Similarly, this might be done using a block magnet using Equation 2

Equation 2.

Where:

• Br = the remnants of the magnet
• W= the width of the block magnet
• L = the length of the block magnet
• T = the thickness of the magnet
• z = the distance from the magnet surface along the axis of polarization.
• r = the radius of the cylindrical magnet

Based on these calculations, we can now determine the magnetic flux density anywhere along a line following the polarization of the magnet. This relationship can be used to track the magnet position as it moves away from or towards the sensor. The one requirement will be, however, that the pole of the magnet is always oriented towards the sensor. When the magnet is perfectly aligned to the z axis of the sensor, this orientation is typical to what might be used with a one dimensional sensor. In many instances it is necessary to add a second degree of freedom. Rotating the magnet about the sensor at a fixed distance will maintain a fixed magnitude of magnetic flux density, but the vector will now be pointing in another direction. Placing the magnet anywhere along the surface of an imaginary sphere about the sensor with the pole directed radially inward will result with a constant magnitude vector when measured using a 3D Hall effect sensor.

The total magnitude of magnetic flux density is shown in Equation 3

Equation 3.

Calculating backwards using Equations 1 and 3 it is possible to determine the radius,r, from the sensor. We can also use the relative magnitudes of X,Y,and Z components of the B field to determine both φ and θ to complete the position calculation in a spherical geometry as depicted in Figure 1-3. This can also be transformed to a Cartesian reference as needed.

As a demonstration of this motion, consider the orbital joystick pictured in Figure 1-4. Here the magnet may be mounted to a sliding screw which can be turned to adjust the range to the sensor. The slider will guide the magnet up and down the curved arm in the θ direction. Additionally, the arm is able to rotate about the sensor 360° in the φ direction.

Figure 1-4 TMAG5170 Orbital Attachment

As an example, we can capture data as the magnet is rotated about the sensor and produce a plot of magnet location about the sensor. Figure 1-5 is a 3D plot showing the locations of samples captured as the magnet is moved about the sensor based on the input magnetic flux density. Slight variations in radius can occur due to mechanical flex of the plastic and assembly tolerances. Allowing for these variations, position of the magnet is simple to extract from the output data in order to provide position tracking across a wide range of motion.

Figure 1-5 Orbital Attachment Example Data

This attachment was designed to connect to the TMAG5170 EVM and 3D design files are available at Orbital Design Files.

## Joystick

Hall effect sensors are similarly suitable to adapt to a joystick function. A 4-position joystick might be designed using a magnet at the end of a pivoting shaft shown in Figure 1-6. A simplistic design for this control can be setup using a Hall effect switch, such as DRV5032, for each position in order to detect the tilt of magnet.

Figure 1-6 Four Direction Joystick

When carefully placed, each sensor will only receive enough input magnetic flux density when the magnet is tilted in its direction. This way, each joystick position will correlate only to a single sensor. The significant benefit of this over electro-mechanical systems is that the Hall effect sensor is contact-free and reduces the total number of mechanical fail points.

A drawback of this configuration is that the position information is binary in nature. With each position either on or off, it is impossible to determine the degree of tilt. To maintain the 4 direction joystick, but to add magnitude as well, it is possible to replace each of the DRV5032 switches with a DRV5055. DRV5055 is capable of producing a linear output with respect to the magnitude of the magnetic field input. With this change, each sensor will now produce a variable output which might be used to determine how far the joystick has been rocked in any of the four directions.

To expand this concept further, a single TMAG5170 is capable of determining both tilt and angle. If the magnet was switched to a spherical shape, it would now be possible to minimize the overall design size by using the magnet itself as a mechanical pivot. See Figure 1-7 for an example of how this is done.

Figure 1-7 Thumb Toggle Joystick Exploded View

With the pole of the magnet directed down towards the sensor, the field will be directed entirely along the z-axis. Then as the magnet tilts any direction, there will be a resulting portion of the vector with x and y components. Here we can determine the magnitude of the tilt by calculating magnitude using only the X and Y components.

Equation 4. $\left(B\right)=\sqrt{{{B}_{x}}^{2}+{{B}_{y}}^{2}}$

Additionally the angle might be calculated using the arc-tangent function using both the x and y components as inputs.

Equation 5. $\theta ={\mathrm{tan}}^{-1}\left(\frac{{B}_{y}}{{B}_{x}}\right)$

The further that this magnet is tilted, the greater the resulting magnitude for these axes will be. The end result is a very simple mechanism which quickly and easily determines tilt magnitude and angle.

Figure 1-8 B-Field Magnitude and Angle

This attachment was designed to connect to the TMAG5170 EVM and 3D design files are available at Joystick Design Files.

For more details and guides related to using linear Hall effect sensors for absolute position measurements with either one dimensional or 3D position sensors, see Table 1-1 and Table 1-2.

Table 1-1 Alternative Device Recommendation
DeviceCharacteristicsDesign Considerations
DRV5055Commercial (Automotive) single axis bipolar linear Hall-effect sensor with Analog output available in SOT-23 and TO-92 packagesAnalog outputs are subject to electrical noise and calculations require MCU computations. Single axis sensitivity constrains the ability to track movement in free space.
DRV5056Commercial (Automotive) single axis unipolar linear Hall-effect sensor with Analog output available in SOT-23 and TO-92 packagesAnalog outputs are subject to electrical noise and require MCU computations. Positive value sensitivity on a single axis greatly constrains the ability to track movement in free space.
DRV5057Commercial (Automotive) single axis bipolar linear Hall-effect sensor with PWM output available in SOT-23 and TO-92 packagesPWM outputs require conversion, but are less susceptible to coupled noise. Single axis sensitivity constrains the ability to track movement in free space.
DRV5032Unipolar or Bipolar single axis Hall-effect switch available in SOT-23, TO-92, or X2SON packagesHall-effect switches are useful for discrete position tracking, such as the 4 direction joystick function. This device is a low power Hall effect sensor ideal for battery powered applications.
TMAG5170-Q1Automotive grade linear 3D Hall-effect position sensor with SPI interface available in 8 pin DGK package

Complete magnetic vector senstivity. This device is able to track a wide range of magnet positions, though careful planning is still required to ensure all input conditions map to a unique position.

TMAG5273Linear 3D Hall-effect position sensor with I2C interface available in 6 pin SOT-23 packageSimilar to the TMAG5170, but operates over I2C with wider sensitivity tolerance specifications.
Table 1-2 Related Technical Resources
NameDescription
Linear Hall Effect Sensor Array DesignA guide to designing sensor arrays for tracking motion across long paths
Intro to linear Hall effect sensors: Achieve contactless accurate position sensingA discussion on the differences between a linear output and switched output Hall effect sensors.
What is a Hall-effect sensor?A discussion about the Hall-effect and how it is used to create magnetic sensors
Angle Measurement With Multi-Axis Hall-effect SensorsA guide to monitoring absolute angle position using a 3D Hall effect sensor
TMAG5170 EVMGUI and attachments incorporate angle measurement using a precise three dimensional linear Hall-effect sensor
TAMG5273 EVMGUI and attachments incorporate angle measurement using a three dimensional linear Hall-effect sensor
TI Precision Labs - Magnetic SensorsA helpful video series describing the Hall effect and how it is used in various applications