Example program for the HMC1501 magnetic 90° angle sensor connected to a HX711 high precision 24-bit programmable analog-to-digital converter (ADC) .
Example program for the HMC1501 magnetic 90° angle sensor. The HMC1501 analog output is connected to a HX711 high precision 24-bit analog to digital converter module.
HMC1501
The Honeywell HMC1501 is a miniature surface mount sensor for linear, 90° angular, or rotary displacement designed for magnetic saturating field sensing. The HMC1501 contains a single saturated-mode Wheatstone bridge sense element that creates an output voltage with respect to the direction of the magnetic flux passing over the sensor surface. It's a cost effective and space-efficient solution for high volume OEM designs. Applications for the HMC1501 sensor include Position Sensing, Rotary speed and angle detection, and non-contact precision location measurement systems. The HMC1501 sensor utilize Honeywell’s Anisotropic Magneto-Resistive (AMR) technology that provides advantages over hall-effectbased magnetic sensors. It is able to resolve better than tenths of a degree or tenths of millimeters, withstand large variations in magnet-to-sensor gaps, and exhibit insensitivity to shocks and vibrations.
Wiring of a connection with an HX711 Analog-to-Digital converter module:
Used libraries:
Import libraryHMC1501
Library for the HMC1501 magnetic 90° angle sensor.
Import libraryHX711
Library for communication with the HX711 24-Bit Analog-to-Digital converter.
main.cpp
- Committer:
- hudakz
- Date:
- 2020-09-19
- Revision:
- 0:7eed1f44df4a
- Child:
- 1:668c95f5e6f9
File content as of revision 0:7eed1f44df4a:
#include "mbed.h" #include "HX711.h" #include "HMC1501.h" // DigitalOut led1(LED1); HX711 hx711(3.2f, D2, D3, 32); // avdd in Volts, sck pin, dout pin, gain HMC1501 hmc1501(-35.5, 47.05); // measured by rotating a magnet: minV [mV], maxV [mV] Ticker ticker; volatile bool tick = false; // /** * @brief * @note * @param * @retval */ void onTick() { tick = true; } /** * @brief * @note * @param * @retval */ int main() { printf("Starting...\r\n"); ticker.attach_us(onTick, 1000 * 1000); // 500ms hx711.powerUp(); while (true) { if (tick) { tick = false; led1 = !led1; if (hx711.isReady()) { float mV = hx711.read(); // read voltage in mV printf("hx711 voltage \t= %fmV\r\n", mV); printf("hmc1501 offset \t= %f mV\r\n", hmc1501.getOffset()); printf("hmc1501 angle \t= %f deg\r\n", hmc1501.angle(mV)); printf("-------------------------------------------\r\n"); } } } }