Skip to content

HardFOC driver

AS5047U Driver

A C++20 driver for the ams OSRAM AS5047U 14-bit magnetic rotary position sensor. It reads angle, velocity and field diagnostics over CRC-protected SPI, configures the ABI, UVW and PWM outputs and programs the OTP, on any MCU with an SPI master.

Quickstart API guide Source on GitHub

The driver has no platform code. You give it a class with one method that moves a frame over SPI; it does the rest: frame building, CRC-8, the one-frame-late read protocol, read-back checks of every write, error flags and unit conversion.

14-bit on-axis magnetic rotary position sensor AS5047U ams OSRAM
Measures
Absolute angle, 14 bit (16384 positions per turn), velocity 24.141 °/s per LSB, AGC and field magnitude
Host interface
SPI mode 1 (CPOL = 0, CPHA = 1) up to 10 MHz; 16-bit frames, or 24- and 32-bit frames with CRC-8
Outputs
ABI incremental up to 4096 pulses per turn, UVW commutation for 1 to 7 pole pairs, 12-bit PWM
Supply
4.5 V to 5.5 V on VDD (internal LDO), or 3.0 V to 3.6 V on VDD and VDD3V3 tied
Limits
Up to 28000 rpm, −40 °C to 150 °C, field 35 mT to 70 mT at the die
Package and memory
TSSOP-14; settings and zero position in volatile registers, burnable once to OTP

Datasheet

What you get

  • One object per sensor. AS5047U<YourSpi> reads the angle (GetAngle(), GetAngleDegrees()), the uncompensated angle, velocity in LSB, °/s, rad/s or rpm, AGC and magnitude. See API guide.
  • All three frame formats. 16-bit frames for the fastest reads, 24-bit frames with CRC, 32-bit frames with a PAD byte for daisy chains. Writes always use a CRC frame. See SPI protocol.
  • Checked writes and replies. Every register write is read back on the next frame, every 24- and 32-bit reply the driver uses is CRC-checked, and port bus errors fail the call; all are retried on request. See API guide.
  • The outputs configured in one call. ABI resolution, index width, UVW pole pairs, PWM pin, hysteresis, direction, zero position, DAEC and the adaptive filter. See Configuration.
  • Typed registers. Every register is a struct with named bit fields, for ReadReg<>() and WriteReg().
  • OTP programming. The datasheet's burn sequence in ProgramOTP(). See OTP programming.
  • Tested without hardware. Host unit tests run the driver against a model of the chip's SPI slave. See Testing and CI.

Where to go next

  • Quickstart


    Wire the sensor, write the port, read an angle in about 15 lines.

  • Hardware


    Pins, bus settings, timing, power modes and the magnet.

  • Architecture


    The three layers and what each one owns.

  • API guide


    Read, configure, set up the outputs and handle errors, task by task.

  • Porting


    Implement the SPI interface for your MCU.

  • API reference


    Every class, member and register, generated from the headers.