137 #ifndef __AVR_ATmega328P__
138 #error !!This library only supports the ATmega328p MCU!!
141 #include <inttypes.h>
149 #define INTFREQ 32830.0f
155 #define ENCODERADDR 0x36
160 #define MAGNITUDE 0x1B
162 #define ENCODERINTFREQ 244.3
163 #define ENCODERSPEEDCONSTANT ENCODERINTFREQ/360.0
175 #define REPSTART 0x10
177 #define TXADDRACK 0x18
179 #define TXDATAACK 0x28
181 #define RXADDRACK 0x40
203 #define A 0.001295752996237
204 #define B 0.000237488365866
205 #define C 0.000000083423218
212 extern "C" void TIMER2_COMPA_vect(void) __attribute__ ((signal,naked));
219 extern "C" void TIMER1_COMPA_vect(
void) __attribute__ ((signal));
365 friend void TIMER1_COMPA_vect(
void) __attribute__ ((signal));
420 friend void TIMER2_COMPA_vect(
void) __attribute__ ((signal,naked));
564 void moveSteps(uint32_t steps,
bool dir,
bool holdMode);
671 void cmd(uint8_t cmd);
694 bool readByte(
bool ack, uint8_t *data);
709 bool read(uint8_t slaveAddr, uint8_t regAddr, uint8_t numOfBytes, uint8_t *data);
723 bool start(uint8_t addr,
bool RW);
737 bool restart(uint8_t addr,
bool RW);
749 bool writeByte(uint8_t data);
764 bool write(uint8_t slaveAddr, uint8_t regAddr, uint8_t numOfBytes, uint8_t *data);
784 uint8_t getStatus(
void);
uStepperEncoder(void)
Constructor.
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.
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
void setup(void)
Initializes the different parts of the uStepper object.
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