58#ifndef _AMS_AS5048B_H_
59#define _AMS_AS5048B_H_
62#define ANGLE_READ_ERROR -1000
70#define AS5048_ADDRESS 0x40
71#define AS5048B_PROG_REG 0x03
72#define AS5048B_ADDR_REG 0x15
73#define AS5048B_ZEROMSB_REG 0x16
74#define AS5048B_ZEROLSB_REG 0x17
75#define AS5048B_GAIN_REG 0xFA
76#define AS5048B_DIAG_REG 0xFB
77#define AS5048B_MAGNMSB_REG 0xFC
78#define AS5048B_MAGNLSB_REG 0xFD
79#define AS5048B_ANGLMSB_REG 0xFE
80#define AS5048B_ANGLLSB_REG 0xFF
81#define AS5048B_RESOLUTION 16384.0
88#define EXP_MOVAVG_LOOP 1
125 double angleR(
int unit =
U_RAW,
boolean newVal =
true);
137 uint8_t _chipAddress;
138 uint8_t _addressRegVal;
139 uint16_t _zeroRegVal;
140 double _lastAngleRaw;
141 double _movingAvgExpAngle;
142 double _movingAvgExpSin;
143 double _movingAvgExpCos;
144 double _movingAvgExpAlpha;
145 int _movingAvgCountLoop;
149 uint8_t readReg8(uint8_t address);
150 uint16_t readReg16(uint8_t address);
151 void writeReg(uint8_t address, uint8_t value);
152 double convertAngle(
int unit,
double angle);
153 double getExpAvgRawAngle(
void);
154 void printDebug(
void);
#define U_RAW
Definition ams_as5048b.h:91
Definition ams_as5048b.h:106
uint8_t addressRegR(void)
reads I2C address register value
Definition ams_as5048b.cpp:223
void updateMovingAvgExp(void)
Performs an exponential moving average on the angle. Works on Sine and Cosine of the angle to avoid i...
Definition ams_as5048b.cpp:373
double angleR(int unit=U_RAW, boolean newVal=true)
reads current angle value and converts it into the desired unit
Definition ams_as5048b.cpp:340
void setClockWise(boolean cw=true)
Set / unset clock wise counting - sensor counts CCW natively.
Definition ams_as5048b.cpp:106
uint16_t angleRegR(void)
Definition ams_as5048b.cpp:293
uint8_t getAutoGain(void)
reads the 1 bytes auto gain register value
Definition ams_as5048b.cpp:308
double getMovingAvgExp(int unit=U_RAW)
sent back the exponential moving averaged angle in the desired unit
Definition ams_as5048b.cpp:409
void zeroRegW(uint16_t regVal)
writes the 2 bytes Zero position register value
Definition ams_as5048b.cpp:256
void doProgZero(void)
Burn values to the zero position OTP register.
Definition ams_as5048b.cpp:167
void progRegister(uint8_t regVal)
writes OTP control register
Definition ams_as5048b.cpp:124
uint16_t zeroRegR(void)
reads the 2 bytes Zero position register value
Definition ams_as5048b.cpp:273
void addressRegW(uint8_t regVal)
write I2C address value (5 bits) into the address register
Definition ams_as5048b.cpp:202
void doProg(void)
Burn values to the slave address OTP register.
Definition ams_as5048b.cpp:140
void begin(void)
init values and overall behaviors for AS5948B use
Definition ams_as5048b.cpp:57
void toggleDebug(void)
Toggle debug output to serial.
Definition ams_as5048b.cpp:90
AMS_AS5048B(void)
Definition ams_as5048b.cpp:32
void resetMovingAvgExp(void)
Definition ams_as5048b.cpp:414
uint16_t magnitudeR(void)
reads the 2 bytes magnitude register value
Definition ams_as5048b.cpp:288
void setZeroReg(void)
sets current angle as the zero position
Definition ams_as5048b.cpp:238
uint8_t getDiagReg(void)
reads the 1 bytes diagnostic register value
Definition ams_as5048b.cpp:323