147 #ifndef __AVR_ATmega328P__
148 #error !!This library only supports the ATmega328p MCU!!
151 #include <inttypes.h>
169 #define INTFREQ 28200.0f
175 #define ENCODERADDR 0x36
180 #define MAGNITUDE 0x1B
182 #define ENCODERINTFREQ 1000.0
183 #define ENCODERSPEEDCONSTANT ENCODERINTFREQ/10.0/360.0
195 #define REPSTART 0x10
197 #define TXADDRACK 0x18
199 #define TXDATAACK 0x28
201 #define RXADDRACK 0x40
223 #define A 0.001295752996237
224 #define B 0.000237488365866
225 #define C 0.000000083423218
228 #define BETA (1.0 - ALPHA)
231 extern "C" void INT0_vect(
void) __attribute__ ((signal));
232 extern "
C"
void INT1_vect(
void) __attribute__ ((signal));
233 extern "
C"
void TIMER2_COMPA_vect(
void) __attribute__ ((signal,naked));
234 extern "
C"
void TIMER1_COMPA_vect(
void) __attribute__ ((signal));
240 float getFloatValue(
void);
241 uint64_t getRawValue(
void);
242 void setValue(
float val);
243 float2 & operator=(
const float &value);
244 bool operator==(
const float2 &value);
245 bool operator!=(
const float2 &value);
246 bool operator>=(
const float2 &value);
247 bool operator<=(
const float2 &value);
248 bool operator<=(
const float &value);
249 bool operator<(
const float2 &value);
250 bool operator>(
const float2 &value);
251 float2 & operator*=(
const float2 &value);
252 float2 & operator-=(
const float2 &value);
253 float2 & operator+=(
const float2 &value);
254 float2 & operator+=(
const float &value);
255 float2 & operator/=(
const float2 &value);
256 const float2 operator+(
const float2 &value);
257 const float2 operator-(
const float2 &value);
258 const float2 operator*(
const float2 &value);
259 const float2 operator/(
const float2 &value);
263 friend void TIMER2_COMPA_vect(
void) __attribute__ ((signal));
411 friend void TIMER1_COMPA_vect(
void) __attribute__ ((signal));
415 volatile float angle;
466 volatile uint16_t faultStepDelay;
467 volatile float tolerance;
468 volatile float stepResolution;
471 friend void TIMER2_COMPA_vect(
void) __attribute__ ((signal,naked));
472 friend
void TIMER1_COMPA_vect(
void) __attribute__ ((signal));
616 void moveSteps(uint32_t steps,
bool dir,
bool holdMode);
653 void setup(
bool mode = NORMAL, uint8_t microStepping = SIXTEEN,
float faultSpeed = 3000.0, uint32_t faultTolerance = 20);
723 void cmd(uint8_t cmd);
746 bool readByte(
bool ack, uint8_t *data);
761 bool read(uint8_t slaveAddr, uint8_t regAddr, uint8_t numOfBytes, uint8_t *data);
775 bool start(uint8_t addr,
bool RW);
789 bool restart(uint8_t addr,
bool RW);
801 bool writeByte(uint8_t data);
816 bool write(uint8_t slaveAddr, uint8_t regAddr, uint8_t numOfBytes, uint8_t *data);
836 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