uStepper
 All Classes Files Functions Variables Macros Pages
Public Member Functions | Private Attributes | Friends | List of all members
uStepperEncoder Class Reference

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))
 

Detailed Description

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.

Constructor & Destructor Documentation

uStepperEncoder::uStepperEncoder ( void  )

Constructor.

This is the constructor of the uStepperEncoder class.

Definition at line 171 of file uStepper.cpp.

Member Function Documentation

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.

Returns
0 - Magnet detected and within limits
1 - Magnet too strong
2 - Magnet 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.

Returns
current AGC value

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.

Returns
Floating point representation of the current motor shaft angle

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.

Returns
Current speed in revolutions per second (RPS)

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

Returns
Strength of 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.

Member Data Documentation

volatile float uStepperEncoder::angleMoved
private

Variable used to store that measured angle moved from the reference position

Definition at line 370 of file uStepper.h.

volatile float uStepperEncoder::curSpeed
private

Variable used to store the last measured rotational speed of the motor shaft

Definition at line 369 of file uStepper.h.

float uStepperEncoder::encoderOffset
private

Angle of the shaft at the reference position.

Definition at line 367 of file uStepper.h.

volatile float uStepperEncoder::oldAngle
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.


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