202 #ifndef __AVR_ATmega328P__ 203 #error !!This library only supports the ATmega328p MCU!! 206 #include <inttypes.h> 208 #include <avr/delay.h> 242 #define INTFREQ 28200.0f 244 #define INTPERIOD 1000000.0/INTFREQ 246 #define INTPIDDELAYCONSTANT 0.028199994 257 #define ENCODERINTFREQ 1000.0 259 #define ENCODERSPEEDCONSTANT ENCODERINTFREQ/10.0/4096.0 261 #define ENCODERADDR 0x36 269 #define MAGNITUDE 0x1B 287 #define REPSTART 0x10 290 #define TXADDRACK 0x18 293 #define TXDATAACK 0x28 296 #define RXADDRACK 0x40 321 #define A 0.001295752996237 323 #define B 0.000237488365866 325 #define C 0.000000083423218 369 float getFloatValue(
void);
370 uint64_t getRawValue(
void);
371 void setValue(
float val);
372 float2 & operator=(
const float &value);
373 bool operator==(
const float2 &value);
374 bool operator!=(
const float2 &value);
375 bool operator>=(
const float2 &value);
376 bool operator<=(
const float2 &value);
377 bool operator<=(
const float &value);
378 bool operator<(
const float2 &value);
379 bool operator>(
const float2 &value);
383 float2 & operator+=(
const float &value);
494 float getAngle(
void);
506 float getSpeed(
void);
515 uint16_t getStrength(
void);
526 uint8_t getAgc(
void);
538 uint8_t detectMagnet(
void);
556 float getAngleMoved(
void);
566 void setup(uint8_t mode);
737 volatile uint32_t speedValue[2];
766 volatile bool invertDir;
781 void startTimer(
void);
792 void stopTimer(
void);
804 void enableMotor(
void);
814 void disableMotor(
void);
820 void pidDropIn(
void);
873 void setMaxAcceleration(
float accel);
884 float getMaxAcceleration(
void);
897 void setMaxVelocity(
float vel);
909 float getMaxVelocity(
void);
924 void runContinous(
bool dir);
944 void moveSteps(int32_t steps,
bool dir,
bool holdMode);
960 void hardStop(
bool holdMode);
977 void softStop(
bool holdMode);
1016 void setup( uint8_t mode =
NORMAL,
1017 uint8_t microStepping =
SIXTEEN,
1018 float faultTolerance = 10.0,
1019 float faultHysteresis = 5.0,
1022 float dterm = 0.006,
1023 bool setHome =
true);
1035 bool getCurrentDirection(
void);
1047 bool getMotorState(
void);
1071 int32_t getStepsSinceReset(
void);
1084 void pwmD8(
double duty);
1095 void setCurrent(
double current);
1105 void pwmD8(
int mode);
1118 void pwmD3(
double duty);
1129 void pwmD3(
int mode);
1140 void updateSetPoint(
float setPoint);
1153 float moveToEnd(
bool dir);
1165 void moveToAngle(
float angle,
bool holdMode);
1176 void moveAngle(
float angle,
bool holdMode);
1184 bool isStalled(
void);
1186 bool detectStall(
float diff,
bool running);
1225 bool cmd(uint8_t cmd);
1257 bool readByte(
bool ack, uint8_t *data);
1280 bool read(uint8_t slaveAddr, uint8_t regAddr, uint8_t numOfBytes, uint8_t *data);
1299 bool start(uint8_t addr,
bool RW);
1318 bool restart(uint8_t addr,
bool RW);
1330 bool writeByte(uint8_t data);
1352 bool write(uint8_t slaveAddr, uint8_t regAddr, uint8_t numOfBytes, uint8_t *data);
1374 uint8_t getStatus(
void);
void interrupt0(void)
Used by dropin feature to take in step pulses.
Prototype of class for the temperature sensor.
void TIMER1_COMPA_vect(void) __attribute__((signal
Measures angle and speed of motor.
volatile uint16_t counter
friend void TIMER2_COMPA_vect(void) __attribute__((signal
Used to apply step pulses to the motor.
Prototype of class for accessing all features of the uStepper in a single object. ...
void TIMER2_COMPA_vect(void) __attribute__((signal
Used to apply step pulses to the motor.
volatile int32_t stepsSinceReset
volatile int32_t angleMoved
volatile uint16_t oldAngle
Prototype of class for accessing the TWI (I2C) interface of the AVR (master mode only).
Prototype of class for the AS5600 encoder.
volatile float hysteresis
void setHome(void)
Define new reference(home) position.
volatile int16_t revolutions
void interrupt1(void)
Used by dropin feature to take in enable signal.
Function prototypes and definitions for the uStepper Servo library.
volatile float stepConversion
uint32_t initialDecelSteps