1. Testing principle
KTH5701 is a 3D linear Hall sensor developed by Quintiles Microelectronics. By detecting the XYZ three-axis magnetic field values, any pairwise combination can be used to directly output the angle through the chip's internal CORDIC algorithm, and the off-axis calibration and temperature compensation functions are integrated internally, which can be used to detect the rotation angle. Fix the radially magnetized magnet on the wind direction pole, and detect the position of the magnet through 5701 to convert it into the corresponding wind direction.
2. Circuit block diagram

1. Angle detection part
KTH5701 is a digital output 3D Hall chip, which integrates three independent Hall sensors for the X-axis, Y-axis and Z-axis. The signal chain uses a high-precision operational amplifier to convert analog signals into digital output through a 16-bit ADC. The external host can use SPI or I2C modes to read out the measurement data. In addition, a temperature sensor is integrated inside the chip for temperature compensation of the magnetic field. KTH5701 supports multiple working modes such as continuous sensing mode, wake-up sleep mode and single measurement mode, and is suitable for different application scenarios. The BUTT_OUT pin is used to detect the button function between the magnet and the chip, and can also be configured in Trigger mode to trigger a single measurement. At the same time, KTH5701 integrates the CORDIC algorithm and supports plane angle output (XY plane, XZ plane, YZ plane). The addition of the amplitude trim register greatly facilitates two common knob application scenarios: on-axis and off-axis. Supports magnetic field threshold detection corresponding to the selected plane (XY plane, XZ plane, YZ plane), and the same chip can detect both knobs and buttons at the same time. This product has the characteristics of high integration and flexible use, and is widely suitable for various application scenarios.

2. The power supply part
XL2009 is a switching step-down DC-DC conversion chip that supports DC8V~36V wide voltage input. The input fixed switching frequency is 180KHz, which can reduce the size of external components and facilitate EMC design. The chip has excellent linear regulation and load regulation, and the output voltage supports arbitrary adjustment between 1.25V and 32V. The chip integrates over-current protection, over-temperature protection, short-circuit protection and other reliability modules.

3. Communication part
The communication part uses the communication isolation chip ADUM1210 + MAX13487 to convert the TTL level of the microcontroller into a 485 signal. And add TVS and self-restoring fuse to the 485 chip output pin.

4. Main control part
The main control part adopts STC microcontroller, and uses P3^7 as the system reset button. After long pressing for 5S, the system parameters will be restored to factory settings.

The current structure adopts the on-axis installation method, so the XY axis is used to measure the angle output. The measurement mode is configured as continuous sensing mode. Each time the chip completes a measurement, it will pull the INT pin high. After the microcontroller enters the interrupt and reads the data, the INT pin will be set low. For related register descriptions, please refer to P26~35 of the specification sheet.
Register 0x1C:

AplaneSel: Set to 00, the chip outputs the XY plane magnetic field angle value.
magnOsr: ADC oversampling rate for magnetic field measurement, here set to 11, and the number of sampling points is 256.
gain: Gain control register, the default setting is 0110.
digCtrl: digital filter. This is set to 111.
Register 0x1D:

measTime: continuous sensing mode or wake-up sleep mode, the intermittent waiting time between each two measurements. 20mS/LSB, here set to 0x16. Combined with the XY measurement time during continuous measurement, it takes approximately 500mS to complete a measurement cycle.
Register 0x1E:

Zero: Set the zero point angle value. I will introduce how to use this later during calibration.
5701 workflow: Register initialization --> Set continuous working mode --> Enter measurement interrupt --> Read measurement data
Note:
INT pin, the host sends continuous sensing mode or single measurement command to the chip, and the chip completes a corresponding measurement After the item is measured, the INT pin will be set to 1, and will remain 1 until the chip sends a read command and reads back the measurement data.
When reading or writing registers, be sure to set the chip to IDLE mode. Registers can be read and written only in IDLE mode.
5. Communication protocol
This case uses RS485 and Modbus_RTU communication protocols. The default baud rate is 9600, no parity, default address 0x01, setting range 0x01~0xFF.
1. Communication format


2. Holding register

3. Detailed explanation of instructions
When using address 00 to query the register, only one and only one device is allowed on the bus, otherwise communication exceptions will occur.
(1) Query the current angle value
. Send:

Receive:

The read data DATA = 0x4000, converted to decimal is 16384. According to the angle calculation formula, angle = 16384/65536*360 = 90°
(2) Set the current angle to For example, if the current angle value of zero point
is 16384, just send 16384.
Send:

Receive:

6. Finished product display
