159 #ifndef __AVR_ATmega328P__
160 #error !!This library only supports the ATmega328p MCU!!
163 #include <inttypes.h>
181 #define INTFREQ 28200.0f
187 #define ENCODERADDR 0x36
192 #define MAGNITUDE 0x1B
194 #define ENCODERINTFREQ 1000.0
195 #define ENCODERSPEEDCONSTANT ENCODERINTFREQ/10.0/360.0
207 #define REPSTART 0x10
209 #define TXADDRACK 0x18
211 #define TXDATAACK 0x28
213 #define RXADDRACK 0x40
235 #define A 0.001295752996237
236 #define B 0.000237488365866
237 #define C 0.000000083423218
240 #define BETA (1.0 - ALPHA)
243 extern "C" void INT0_vect(
void) __attribute__ ((signal,used));
244 extern "
C"
void INT1_vect(
void) __attribute__ ((signal,used));
245 extern "
C"
void TIMER2_COMPA_vect(
void) __attribute__ ((signal,naked,used));
246 extern "
C"
void TIMER1_COMPA_vect(
void) __attribute__ ((signal,used));
252 float getFloatValue(
void);
253 uint64_t getRawValue(
void);
254 void setValue(
float val);
255 float2 & operator=(
const float &value);
256 bool operator==(
const float2 &value);
257 bool operator!=(
const float2 &value);
258 bool operator>=(
const float2 &value);
259 bool operator<=(
const float2 &value);
260 bool operator<=(
const float &value);
261 bool operator<(
const float2 &value);
262 bool operator>(
const float2 &value);
263 float2 & operator*=(
const float2 &value);
264 float2 & operator-=(
const float2 &value);
265 float2 & operator+=(
const float2 &value);
266 float2 & operator+=(
const float &value);
267 float2 & operator/=(
const float2 &value);
268 const float2 operator+(
const float2 &value);
269 const float2 operator-(
const float2 &value);
270 const float2 operator*(
const float2 &value);
271 const float2 operator/(
const float2 &value);
275 friend void TIMER2_COMPA_vect(
void) __attribute__ ((signal,used));
423 friend void TIMER1_COMPA_vect(
void) __attribute__ ((signal,used));
427 volatile float angle;
478 volatile uint16_t faultStepDelay;
479 volatile float tolerance;
480 volatile float stepResolution;
483 friend void TIMER2_COMPA_vect(
void) __attribute__ ((signal,naked,used));
484 friend
void TIMER1_COMPA_vect(
void) __attribute__ ((signal,used));
628 void moveSteps(uint32_t steps,
bool dir,
bool holdMode);
676 void setup(
bool mode = NORMAL, uint8_t microStepping = SIXTEEN,
float faultSpeed = 3000.0, uint32_t faultTolerance = 20);
746 void cmd(uint8_t cmd);
769 bool readByte(
bool ack, uint8_t *data);
784 bool read(uint8_t slaveAddr, uint8_t regAddr, uint8_t numOfBytes, uint8_t *data);
798 bool start(uint8_t addr,
bool RW);
812 bool restart(uint8_t addr,
bool RW);
824 bool writeByte(uint8_t data);
839 bool write(uint8_t slaveAddr, uint8_t regAddr, uint8_t numOfBytes, uint8_t *data);
859 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