Go to the documentation of this file.
40 #define DIRECTION(n) (((n)&0x1)<<4)
41 #define EN_PWM_MODE(n) (((n)&0x1)<<2)
42 #define I_SCALE_ANALOG(n) (((n)&0x1)<<0)
45 #define X_COMPARE 0x05
46 #define IHOLD_IRUN 0x10
47 #define TPOWERDOWN 0x11
50 #define TCOOLTHRS 0x14
57 #define VSTART_REG 0x23
64 #define VSTOP_REG 0x2B
65 #define TZEROWAIT 0x2C
69 #define SG_STOP(n) (((n)&0x1)<<10)
70 #define RAMP_STAT 0x35
76 #define FREEWHEEL(n) (((n)&0x3UL)<<20)
77 #define PWM_AUTOSCALE(n) (((n)&0x1UL)<<18)
78 #define PWM_FREQ(n) (((n)&0x3UL)<<16)
79 #define PWM_GRAD(n) (((n)&0xFF)<<8)
80 #define PWM_AMPL(n) (((n)&0xFF)<<0)
87 #define DISS2G(n) (((n)&0x1UL)<<30)
88 #define DEDGE(n) (((n)&0x1UL)<<29)
89 #define INTPOL(n) (((n)&0x1UL)<<28)
90 #define MRES(n) (((n)&0xFUL)<<24)
91 #define SYNC(n) (((n)&0xFUL)<<20)
92 #define VHIGHCHM(n) (((n)&0x1UL)<<19)
93 #define VHIGHFS(n) (((n)&0x1UL)<<18)
94 #define VSENSE(n) (((n)&0x1UL)<<17)
95 #define TBL(n) (((n)&0x3UL)<<15)
96 #define CHM(n) (((n)&0x1UL)<<14)
97 #define RNDTF(n) (((n)&0x1)<<13)
98 #define DISFDCC(n) (((n)&0x1)<<12)
99 #define TFD3(n) (((n)&0x1)<<11)
100 #define HEND(n) (((n)&0xF)<<7)
101 #define HSTRT_TFD(n) (((n)&0x7)<<4)
102 #define TOFF(n) (((n)&0xF)<<0)
107 #define COOLCONF 0x6D
108 #define SFILT(n) (((n)&0x1UL)<<24)
109 #define SGT(n) (((n)&0x7FUL)<<16)
110 #define SEIMIN(n) (((n)&0x1UL)<<15)
111 #define SEDN(n) (((n)&0x3)<<13)
112 #define SEMAX(n) (((n)&0xF)<<8)
113 #define SEUP(n) (((n)&0x3)<<5)
114 #define SEMIN(n) (((n)&0xF)<<0)
118 #define DC_SG(n) (((n)&0xFFUL)<<16)
119 #define DC_TIME(n) (((n)&0x3FF)<<0)
121 #define DRV_STATUS 0x6F
123 #define IHOLDDELAY(n) (((n)&0xFUL)<<16)
124 #define IRUN(n) (((n)&0x1F)<<8)
125 #define IHOLD(n) (((n)&0x1F)<<0)
128 #define WRITE_ACCESS 0x80
132 #define POSITIONING_MODE 0x00
133 #define VELOCITY_MODE_POS 0x01
134 #define VELOCITY_MODE_NEG 0x02
135 #define HOLD_MODE 0x03
137 #define DRIVER_STOP 0
138 #define DRIVER_VELOCITY 1
139 #define DRIVER_POSITION 2
141 #define ACCELERATIONCONVERSION 1.0/116.415321827
142 #define VELOCITYCONVERSION 1.0/0.953674316
150 class uStepperDriver{
177 void setPosition( int32_t position );
187 void setVelocity( uint32_t velocity );
196 void setAcceleration( uint32_t acceleration );
205 void setDeceleration( uint32_t deceleration );
231 void setShaftDirection(
bool direction );
248 int32_t getVelocity(
void );
259 int32_t getPosition(
void );
266 void setHome(int32_t initialSteps = 0);
283 int32_t writeRegister( uint8_t address, uint32_t datagram );
296 int32_t readRegister( uint8_t address );
301 uint16_t getStallValue(
void );
304 volatile int32_t xTarget = 0;
307 volatile int32_t xActual = 0;
319 uint8_t current = 16;
320 uint8_t holdCurrent = 0;
321 uint8_t holdDelay = 0;
326 uint32_t VMAX = 200000;
339 void updateCurrent(
void );
346 void setRampMode( uint8_t
mode );
348 void setDirection(
bool direction );
352 void enableStealth(
void );
360 void readMotorStatus(
void);
Prototype of class for accessing all features of the uStepper S in a single object.
void enableStallguard(int8_t threshold=4, bool stopOnStall=false)
Enable TMC5130 StallGuard.
void chipSelect(uint8_t pin, bool state)
void disableStallguard(void)
Disables the builtin stallguard offered from TMC5130, and reenables StealthChop.
void stop(bool mode=HARD)
Stop the motor.
void clearStall(void)
Clear the stallguard, reenabling the motor to return to its previous operation.
void init(void)
Internal function to prepare the uStepperS in the constructor.
void setHoldCurrent(double current)
Set motor hold current.
friend class uStepperDriver
void setCurrent(double current)
Set motor output current.