Software example. AMS AS5510
AMS AS5510 is a 10-bit linear incremental position sensor that offers precise angle measurement with a resolution of 1.95µm/LSB. It employs a simple 2-pole magnet to measure lateral movement with an air gap of around 1.0mm. The device features an I²C interface, allowing for easy connectivity to microcontrollers. With its compact size and low power consumption, AS5510 is ideal for applications requiring accurate position sensing in limited spaces.
Реклама
Реклама
AS5510-AB-Manual
7 Software example
After powering up the system, a delay of >1.5ms must be performed before the first I²C
Read/Write command with the AS5510.
-
-
The initialization after power up is optional. It consists of:
- Sensitivity configuration (Register 0Bh)
Magnet polarity (Register 02h bit 1)
Slow or Fast mode (Register 02h bit 3)
- Power Down mode (Register 02h bit 0)
Reading the magnetic field value is straight forward. The following source code reads the 10 -bit magnetic field value, and converts to the magnetic field strength in mT (millitesla).
Example: Sensitivity configured to +-50mT range (97.66mT/LSB); Polarity = 0; default setting:
- D9..0 value = 0 means -50mT on the hall sensor.
- D9..0 value = 511 means 0mT on the hall sensor (no magnetic field, or no magnet).
- D9..0 value = 1023 means +50mT on the hall sensor.
Void main_loop(unsigned char Sensitivity_Mode)
{ unsigned char Data1, Data2; short value;
// 10-bit output value (0~1023) float magnetic_field;
// The value 511 is the middle point @ 0mT
// Value of the magnetic field in mT
Data_LSB = I2C_Read8(I2C_ADDR, 0x00); // Read D7..0
Data_MSB = I2C_Read8(I2C_ADDR, 0x01); // Read D9..8 + OCF + Parity value = ((Data_MSB & 0x03)<<8) + Data_LSB; switch (Sensitivity_Mode) // Sensitivity_Mode is the value stored in
// register 0Bh
{ case 0: // Register [0Bh] <= 0 (+- 50mT range, 97.66uT/LSB) magnetic_field = (value - 511) * 0.09766; break; case 1: case 2:
// Register [0Bh] <= 0 (+- 25mT range, 48.83uT/LSB) magnetic_field = (value - 511) * 0.04883; break;
// Register [0Bh] <= 0 (+- 12.5mT range, 24.41uT/LSB) magnetic_field = (value - 511) * 0.02441; break; www.ams.com Revision 1.2 - 21/08/13 page 9/11
Изтегляне
Реклама