The detailed implementation of two-level detection method is specified in the following, taking TMAG3001 as an example.
- Obtain the magnetic flux change in Z axis by pressing the joystick
This step is used to set a correct threshold for hardware detection and a
designed for step for software detection. - Set a corresponding threshold on Z axis by using THR_Config_3 register in TMAG3001 or
Z_THR_Confing in TMAG5173.
Larger thresholds
require more pressing distance in the Z axis which also allows for larger offset
in X and Y. A lower threshold means a reduced pressing distance in Z-axis, but
this can cause a false trigger if set to low. - Set the interrupt signal in INT pin by writing 1h to INT_CONFIG_1 4-2 bits.
The INT pin sends a signal to MCU to indicate that
the magnetic flux has already crossed the threshold. - During normal operation the 3D linear Hall-effect sensor works in continuous sample or trigger
sample mode based on user setting. The MCU calculates the slew rate or absolute
change value based on the conversion number to determine whether the threshold
is exceeded.
- Once the hardware threshold or the slew rate exceeds the setting value the device enters
iterrupt or latch mode. The previous X and Y axis are recorded into an array
immediately and then MAG_CH_EN to 4h is set to 4H(Only convert Z-axis magnetic
flux). After the interrupt is cleared, the main function returns to normal
working mode and sets MAG_CH_EN to 7h(enable all three-axis conversions).
Figure 3-4 shows the flowchart of detailed implementation of proposed detection method.