154 #ifndef __AVR_ATmega328P__
155 #error !!This library only supports the ATmega328p MCU!!
158 #include <inttypes.h>
176 #define INTFREQ 28200.0f
182 #define ENCODERADDR 0x36
187 #define MAGNITUDE 0x1B
189 #define ENCODERINTFREQ 1000.0
190 #define ENCODERSPEEDCONSTANT ENCODERINTFREQ/10.0/360.0
202 #define REPSTART 0x10
204 #define TXADDRACK 0x18
206 #define TXDATAACK 0x28
208 #define RXADDRACK 0x40
230 #define A 0.001295752996237
231 #define B 0.000237488365866
232 #define C 0.000000083423218
235 #define BETA (1.0 - ALPHA)
238 extern "C" void INT0_vect(
void) __attribute__ ((signal));
239 extern "
C"
void INT1_vect(
void) __attribute__ ((signal));
240 extern "
C"
void TIMER2_COMPA_vect(
void) __attribute__ ((signal,naked));
241 extern "
C"
void TIMER1_COMPA_vect(
void) __attribute__ ((signal));
247 float getFloatValue(
void);
248 uint64_t getRawValue(
void);
249 void setValue(
float val);
250 float2 & operator=(
const float &value);
251 bool operator==(
const float2 &value);
252 bool operator!=(
const float2 &value);
253 bool operator>=(
const float2 &value);
254 bool operator<=(
const float2 &value);
255 bool operator<=(
const float &value);
256 bool operator<(
const float2 &value);
257 bool operator>(
const float2 &value);
258 float2 & operator*=(
const float2 &value);
259 float2 & operator-=(
const float2 &value);
260 float2 & operator+=(
const float2 &value);
261 float2 & operator+=(
const float &value);
262 float2 & operator/=(
const float2 &value);
263 const float2 operator+(
const float2 &value);
264 const float2 operator-(
const float2 &value);
265 const float2 operator*(
const float2 &value);
266 const float2 operator/(
const float2 &value);
270 friend void TIMER2_COMPA_vect(
void) __attribute__ ((signal));
418 friend void TIMER1_COMPA_vect(
void) __attribute__ ((signal));
422 volatile float angle;
473 volatile uint16_t faultStepDelay;
474 volatile float tolerance;
475 volatile float stepResolution;
478 friend void TIMER2_COMPA_vect(
void) __attribute__ ((signal,naked));
479 friend
void TIMER1_COMPA_vect(
void) __attribute__ ((signal));
623 void moveSteps(uint32_t steps,
bool dir,
bool holdMode);
660 void setup(
bool mode = NORMAL, uint8_t microStepping = SIXTEEN,
float faultSpeed = 3000.0, uint32_t faultTolerance = 20);
730 void cmd(uint8_t cmd);
753 bool readByte(
bool ack, uint8_t *data);
768 bool read(uint8_t slaveAddr, uint8_t regAddr, uint8_t numOfBytes, uint8_t *data);
782 bool start(uint8_t addr,
bool RW);
796 bool restart(uint8_t addr,
bool RW);
808 bool writeByte(uint8_t data);
823 bool write(uint8_t slaveAddr, uint8_t regAddr, uint8_t numOfBytes, uint8_t *data);
843 uint8_t getStatus(
void);
uStepperEncoder(void)
Constructor.
void setup(bool mode=NORMAL, uint8_t microStepping=SIXTEEN, float faultSpeed=3000.0, uint32_t faultTolerance=20)
Initializes the different parts of the uStepper object.
Prototype of class for the temperature sensor.
uint16_t getStrength(void)
Measure the strength of the magnet.
float getSpeed(void)
Measure the current speed of the motor.
bool getMotorState(void)
Get the current state of the motor.
Prototype of class for accessing all features of the uStepper in a single object. ...
void enableMotor(void)
Enables the stepper driver output stage.
float getMaxAcceleration(void)
Get the value of the maximum motor acceleration.
float getTemp(void)
Request a reading of current temperature.
bool getCurrentDirection(void)
Returns the direction the motor is currently configured to rotate.
float getAngleMoved(void)
Measure the angle moved from reference position.
void hardStop(bool holdMode)
Stop the motor without deceleration.
void setMaxAcceleration(float accel)
Set the maximum acceleration of the stepper motor.
void startTimer(void)
Starts timer for stepper algorithm.
void setMaxVelocity(float vel)
Sets the maximum rotational velocity of the motor.
void moveSteps(uint32_t steps, bool dir, bool holdMode)
Make the motor perform a predefined number of steps.
float getMaxVelocity(void)
Returns the maximum rotational velocity of the motor.
void softStop(bool holdMode)
Stop the motor with deceleration.
uint8_t detectMagnet(void)
Detect if magnet is present and within range.
void stopTimer(void)
Stops the timer for the stepper algorithm.
uint8_t getAgc(void)
Read the current AGC value of the encoder chip.
void runContinous(bool dir)
Make the motor rotate continuously.
Prototype of class for accessing the TWI (I2C) interface of the AVR (master mode only).
Prototype of class for the AS5600 encoder.
void setHome(void)
Define new reference(home) position.
float getAngle(void)
Measure the current shaft angle.
volatile float angleMoved
uStepperTemp(void)
Constructor.
void disableMotor(void)
Disables the stepper driver output stage.
int64_t getStepsSinceReset(void)
Get the number of steps applied since reset.
void setup(void)
Setup the encoder.
uint32_t initialDecelSteps