satnogs-rotator-firmware
Public Member Functions | Private Member Functions | Private Attributes | List of all members
AS5601 Class Reference

Class that functions for interacting with AS5601 magnetic rotary position sensor. More...

#include <as5601.h>

Public Member Functions

void Begin ()
 Initialize the I2C bus. More...
 
uint8_t get_pos (double *new_pos)
 Calculate an unwrap the position. More...
 
uint8_t get_agc ()
 Calculate the automatic gain control (AGC) More...
 
uint16_t get_magnitude ()
 Get the magnitude value of the internal CORDIC output. More...
 
uint16_t get_conf ()
 Get the configuration register. More...
 
uint8_t set_zero ()
 Set zero by setting offset angle. More...
 
void init_zero ()
 Reset zero position set the offset to zero. More...
 
void set_gear_ratio (uint8_t enc_ratio)
 Set the gear ratio between encoder and measure axis. More...
 

Private Member Functions

uint8_t i2c_byte_transaction (uint8_t i2c_address, uint8_t i2c_register)
 
uint16_t i2c_word_transaction (uint8_t i2c_address, uint8_t i2c_register)
 

Private Attributes

double _angle_offset = 0
 
int32_t _n = 0
 
float _raw_prev_pos = 0
 
uint8_t _enc_ratio = 0
 

Detailed Description

Class that functions for interacting with AS5601 magnetic rotary position sensor.

Definition at line 35 of file as5601.h.

Member Function Documentation

◆ Begin()

void AS5601::Begin ( )
inline

Initialize the I2C bus.

Definition at line 43 of file as5601.h.

References I2C_FREQ.

◆ get_agc()

uint8_t AS5601::get_agc ( )
inline

Calculate the automatic gain control (AGC)

Returns
The AGC range is 0-255 counts, the gain value should be in the center of its range

Definition at line 96 of file as5601.h.

References AGC, AS5601_ID, and i2c_byte_transaction().

Here is the call graph for this function:

◆ get_conf()

uint16_t AS5601::get_conf ( )
inline

Get the configuration register.

Returns
The Configuration register

Definition at line 116 of file as5601.h.

References AS5601_ID, CONF_HIGH, and i2c_word_transaction().

Here is the call graph for this function:

◆ get_magnitude()

uint16_t AS5601::get_magnitude ( )
inline

Get the magnitude value of the internal CORDIC output.

Returns
The magnitude value of the internal CORDIC output

Definition at line 106 of file as5601.h.

References AS5601_ID, i2c_word_transaction(), and MAGNITUDE_HIGH.

Here is the call graph for this function:

◆ get_pos()

uint8_t AS5601::get_pos ( double *  new_pos)
inline

Calculate an unwrap the position.

Parameters
new_posCalculate the current position of the sensor
Returns
The state of the AS5601: Magnet is too strong Magnet is too weak Magnet was detect

Definition at line 59 of file as5601.h.

References _angle_offset, _enc_ratio, _n, _raw_prev_pos, AS5601_ID, i2c_byte_transaction(), i2c_word_transaction(), RAW_ANG_HIGH, and STATUS_REG.

Referenced by homing(), loop(), and set_zero().

Here is the call graph for this function:

◆ i2c_byte_transaction()

uint8_t AS5601::i2c_byte_transaction ( uint8_t  i2c_address,
uint8_t  i2c_register 
)
inlineprivate

Definition at line 162 of file as5601.h.

Referenced by get_agc(), get_pos(), and i2c_word_transaction().

◆ i2c_word_transaction()

uint16_t AS5601::i2c_word_transaction ( uint8_t  i2c_address,
uint8_t  i2c_register 
)
inlineprivate

Definition at line 172 of file as5601.h.

References i2c_byte_transaction().

Referenced by get_conf(), get_magnitude(), and get_pos().

Here is the call graph for this function:

◆ init_zero()

void AS5601::init_zero ( )
inline

Reset zero position set the offset to zero.

Definition at line 141 of file as5601.h.

References _angle_offset.

Referenced by homing().

◆ set_gear_ratio()

void AS5601::set_gear_ratio ( uint8_t  enc_ratio)
inline

Set the gear ratio between encoder and measure axis.

Parameters
enc_ratioAn uitn8_t, that represents the gear ratio

Definition at line 152 of file as5601.h.

References _enc_ratio.

Referenced by setup().

◆ set_zero()

uint8_t AS5601::set_zero ( )
inline

Set zero by setting offset angle.

Returns
The state of the AS5601: Magnet is too strong Magnet is too weak Magnet was detect

Definition at line 129 of file as5601.h.

References _angle_offset, and get_pos().

Referenced by homing().

Here is the call graph for this function:

Member Data Documentation

◆ _angle_offset

double AS5601::_angle_offset = 0
private

Definition at line 157 of file as5601.h.

Referenced by get_pos(), init_zero(), and set_zero().

◆ _enc_ratio

uint8_t AS5601::_enc_ratio = 0
private

Definition at line 160 of file as5601.h.

Referenced by get_pos(), and set_gear_ratio().

◆ _n

int32_t AS5601::_n = 0
private

Definition at line 158 of file as5601.h.

Referenced by get_pos().

◆ _raw_prev_pos

float AS5601::_raw_prev_pos = 0
private

Definition at line 159 of file as5601.h.

Referenced by get_pos().


The documentation for this class was generated from the following file: