

The AS5047P is a high-resolution magnetic rotary position sensor designed to provide precise angular position measurements. With a 14-bit resolution, it ensures accurate and reliable performance in demanding applications. The sensor uses a contactless magnetic measurement principle, making it robust against environmental factors such as dust, dirt, and oil. It supports SPI and PWM communication interfaces, offering flexibility for integration into various systems.








| Parameter | Value |
|---|---|
| Resolution | 14-bit |
| Supply Voltage (VDD) | 3.3V or 5V |
| Current Consumption | 12 mA (typical) |
| Interface | SPI, PWM |
| Maximum Speed | 28,000 RPM |
| Operating Temperature | -40°C to +125°C |
| Magnetic Field Strength | 30 mT to 70 mT |
| Package | TSSOP-14 |
| Pin Number | Pin Name | Description |
|---|---|---|
| 1 | VDD3V3 | 3.3V power supply input |
| 2 | VDD5V | 5V power supply input |
| 3 | GND | Ground |
| 4 | CSn | Chip Select (active low) for SPI communication |
| 5 | CLK | SPI Clock input |
| 6 | MISO | SPI Master-In-Slave-Out (data output) |
| 7 | MOSI | SPI Master-Out-Slave-In (data input) |
| 8 | PWM | Pulse Width Modulation output for angular position |
| 9 | A | Incremental encoder A output |
| 10 | B | Incremental encoder B output |
| 11 | Index | Incremental encoder index pulse output |
| 12 | PROG | Programming pin for OTP (One-Time Programmable) memory |
| 13 | TEST | Test pin (leave unconnected in normal operation) |
| 14 | NC | Not connected |
#include <SPI.h>
// Define SPI pins for the AS5047P
const int CSn = 10; // Chip Select pin connected to Arduino pin 10
void setup() {
// Initialize SPI communication
SPI.begin();
pinMode(CSn, OUTPUT);
digitalWrite(CSn, HIGH); // Set CSn high to deselect the sensor
Serial.begin(9600); // Initialize serial communication for debugging
}
uint16_t readAngle() {
uint16_t angle = 0;
// Start SPI communication with the AS5047P
digitalWrite(CSn, LOW); // Select the sensor
delayMicroseconds(1); // Short delay for stability
// Send the command to read the angle (0x3FFF is the angle register)
uint16_t command = 0x3FFF;
uint8_t highByte = SPI.transfer((command >> 8) & 0xFF); // Send high byte
uint8_t lowByte = SPI.transfer(command & 0xFF); // Send low byte
// Combine the received bytes into a 14-bit angle value
angle = ((highByte << 8) | lowByte) & 0x3FFF;
digitalWrite(CSn, HIGH); // Deselect the sensor
return angle;
}
void loop() {
uint16_t angle = readAngle(); // Read the angular position
float degrees = (angle * 360.0) / 16384.0; // Convert to degrees (14-bit resolution)
Serial.print("Angle: ");
Serial.print(degrees);
Serial.println(" degrees");
delay(100); // Wait 100 ms before the next reading
}
No Output or Incorrect Readings:
Noise in Readings:
SPI Communication Fails:
PWM Output Not Detected:
Q: Can the AS5047P be used with a 5V microcontroller?
A: Yes, the AS5047P supports both 3.3V and 5V power supplies, making it compatible with 5V microcontrollers.
Q: What type of magnet should I use?
A: Use a diametrically magnetized magnet with a magnetic field strength of 30 mT to 70 mT.
Q: How do I calculate the angle from the PWM output?
A: Measure the duty cycle of the PWM signal. The angle is proportional to the duty cycle, where 0% corresponds to 0° and 100% corresponds to 360°.