Skip to content

Driver

AS5047U Driver

A C++20 driver for the AS5047U 14-bit magnetic rotary position sensor. It reads the angle and the velocity over CRC-protected SPI frames, resolves the chip's error flags, sets the zero and the outputs, and burns the OTP, on any MCU.

Quickstart API guide Source on GitHub

The driver has no platform code. You give it a small class that brings the bus up and moves bytes; it does the rest: the start-up wait for the chip's ready indication, the frame format and CRC, ERRFL handling and its latch, unit conversion and the OTP procedure.

Magnetic rotary position sensor AS5047U ams OSRAM
Function
Absolute angle over 360°, 14 bits (16384 counts, 0.022° per count); velocity at 24.141 °/s per count; up to 28000 rpm
Interface
SPI mode 1, up to 10 MHz; 16-bit frames, or 24- and 32-bit frames with CRC-8
Compensation
Dynamic angle error compensation (DAEC) and an adaptive velocity filter
Integrity
CRC-8 on frames; ERRFL error and warning flags; AGC and DIA for the magnet and the internal loops
Outputs
ABI quadrature (up to 4096 pulses per revolution), UVW commutation (1 to 7 pole pairs) and PWM
Non-volatile memory
One-time-programmable zero position and settings
Supply
3.0 V to 3.6 V, or 4.5 V to 5.5 V through the on-chip LDO

What you get

  • One object per chip. AS5047U<YourPort> takes a reference to your port and does no I/O until EnsureInitialized(). See API guide.
  • Errors you can act on. Every call returns Result<T> with an Error such as Bus, Crc or DeviceFault. See API guide.
  • Datasheet defaults. Config{} holds the reset values of an unprogrammed part; a burned part is read back instead. See Configuration and OTP programming.
  • Zero-overhead portability. The port is a CRTP class checked by a concept: two bus hooks, plus optional delay (for the OTP burn) and logging hooks found at compile time. See Porting.
  • No heap, no exceptions, no RTTI. The host tests build with -fno-exceptions -fno-rtti. See Contract.
  • Tested without hardware. Host tests run the driver against a register model of the chip. See Testing and CI.

Datasheet

Document Revision Get it
Datasheet: AS5047U High Resolution Rotary Position Sensor (ams OSRAM DS000637) v1-01, 2020-12-16 vendor page

Written against these revisions; the SHA-256 of each file is in docs/datasheets.yml. Where each part of the driver is in the datasheet: Datasheet map.

Where to go next

  • Quickstart


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

  • Hardware


    Pins, SPI frames, timing, power and the magnet.

  • Contract


    What the driver promises, what it needs, threading and errors.

  • API guide


    Initialise, measure, set the zero and handle errors, task by task.

  • Porting


    Implement the port for your MCU.

  • API reference


    Every class and member, generated from the headers.