Prototype of class for the AS5600 encoder. More...
#include <uStepper.h>
Public Member Functions | |
uStepperEncoder (void) | |
Constructor. More... | |
float | getAngle (void) |
Measure the current shaft angle. More... | |
float | getSpeed (void) |
Measure the current speed of the motor. More... | |
uint16_t | getStrength (void) |
Measure the strength of the magnet. More... | |
uint8_t | getAgc (void) |
Read the current AGC value of the encoder chip. More... | |
uint8_t | detectMagnet (void) |
Detect if magnet is present and within range. More... | |
float | getAngleMoved (void) |
Measure the angle moved from reference position. More... | |
void | setup (void) |
Setup the encoder. More... | |
void | setHome (void) |
Define new reference(home) position. More... | |
Private Attributes | |
float | encoderOffset |
volatile float | oldAngle |
volatile float | curSpeed |
volatile float | angleMoved |
Friends | |
void | TIMER1_COMPA_vect (void) __attribute__((signal)) |
Prototype of class for the AS5600 encoder.
This class enables the user of the library to access the AS5600 encoder on the uStepper board. This class can be instantiated as a standalone object if all the features of the uStepper is not needed by the programmers specific application.
Definition at line 269 of file uStepper.h.
uStepperEncoder::uStepperEncoder | ( | void | ) |
Constructor.
This is the constructor of the uStepperEncoder class.
Definition at line 171 of file uStepper.cpp.
uint8_t uStepperEncoder::detectMagnet | ( | void | ) |
Detect if magnet is present and within range.
This function detects whether the magnet is present, too strong or too weak.
Definition at line 269 of file uStepper.cpp.
uint8_t uStepperEncoder::getAgc | ( | void | ) |
Read the current AGC value of the encoder chip.
This function returns the current value of the AGC register in the encoder chip (AS5600). This value ranges between 0 and 255, and should preferably be as close to 128 as possible.
Definition at line 260 of file uStepper.cpp.
float uStepperEncoder::getAngle | ( | void | ) |
Measure the current shaft angle.
This function reads the current angle of the motor shaft. The resolution of the angle returned by this function is 0.087890625 degrees (12 bits) The Angle is read by means of the I2C interface, using the I2C interface implemented in this library.
Definition at line 239 of file uStepper.cpp.
float uStepperEncoder::getAngleMoved | ( | void | ) |
Measure the angle moved from reference position.
This function measures the angle moved from the shaft reference position. When the uStepper is first powered on, the reference position is reset to the current shaft position, meaning that this function will return the angle rotated with respect to the angle the motor initially had. It should be noted that this function is absolute to an arbitrary number of revolutions !
The reference position can be reset at any point in time, by use of the setHome() function.
Definition at line 176 of file uStepper.cpp.
float uStepperEncoder::getSpeed | ( | void | ) |
Measure the current speed of the motor.
This function returns the current speed of the motor. The speed is not calculated in this function, it is merely returning a variable. The speed is calculated in the interrupt routine associated with timer1.
Definition at line 207 of file uStepper.cpp.
uint16_t uStepperEncoder::getStrength | ( | void | ) |
Measure the strength of the magnet.
This function returns the strength of the magnet
Definition at line 251 of file uStepper.cpp.
void uStepperEncoder::setHome | ( | void | ) |
Define new reference(home) position.
This function redefines the reference position to the current angle of the shaft
Definition at line 229 of file uStepper.cpp.
void uStepperEncoder::setup | ( | void | ) |
Setup the encoder.
This function initializes all the encoder features.
Definition at line 212 of file uStepper.cpp.
|
private |
Variable used to store that measured angle moved from the reference position
Definition at line 370 of file uStepper.h.
|
private |
Variable used to store the last measured rotational speed of the motor shaft
Definition at line 369 of file uStepper.h.
|
private |
Angle of the shaft at the reference position.
Definition at line 367 of file uStepper.h.
|
private |
Used to stored the previous measured angle for the speed measurement, and the calculation of angle moved from reference position
Definition at line 368 of file uStepper.h.