Posts

Showing posts from October, 2021

AS5048A Magnetic Encoder and STM32

Image
This past week I began to write the controller firmware - mainly playing with the AS5048A angular position sensor from AMS. Here is the datasheet .  This sensor will be used to get the rotor position and then compute the resulting electrical angle for the Clarke/Park transforms and also it will be used to find rotor speed for the out loop.  I will be using an STM32F446 board to run the loop as it has a high clock speed. The AS5048A sends its measurements over SPI. Below is the read package sent from the sensor: We get 14 bits of position data - aka 16384 ticks per revolution, or a resolution of 0.0219 degrees. I wrote this read() function that sends the SPI command package and reads the resulting response: uint16_t read(uint16_t registerAddress) { uint16_t command = 0x4000; // PAR=0 R/W=R uint8_t RxBuff[2]; uint8_t TxBuff[2]; command = command | registerAddress; command |= (uint16_t) (spiCalcEvenParity(command) << 0xF); TxBuff[0] = command >> 8; TxBuff[1] = co