Go to the documentation of this file.
41 #define DIRECTION(n) (((n)&0x1)<<4)
42 #define EN_PWM_MODE(n) (((n)&0x1)<<2)
43 #define I_SCALE_ANALOG(n) (((n)&0x1)<<0)
46 #define X_COMPARE 0x05
47 #define IHOLD_IRUN 0x10
48 #define TPOWERDOWN 0x11
51 #define TCOOLTHRS 0x14
58 #define VSTART_REG 0x23
65 #define VSTOP_REG 0x2B
66 #define TZEROWAIT 0x2C
70 #define SG_STOP(n) (((n)&0x1)<<10)
71 #define RAMP_STAT 0x35
77 #define FREEWHEEL(n) (((n)&0x3UL)<<20)
78 #define PWM_AUTOSCALE(n) (((n)&0x1UL)<<18)
79 #define PWM_FREQ(n) (((n)&0x3UL)<<16)
80 #define PWM_GRAD(n) (((n)&0xFF)<<8)
81 #define PWM_AMPL(n) (((n)&0xFF)<<0)
88 #define DISS2G(n) (((n)&0x1UL)<<30)
89 #define DEDGE(n) (((n)&0x1UL)<<29)
90 #define INTPOL(n) (((n)&0x1UL)<<28)
91 #define MRES(n) (((n)&0xFUL)<<24)
92 #define SYNC(n) (((n)&0xFUL)<<20)
93 #define VHIGHCHM(n) (((n)&0x1UL)<<19)
94 #define VHIGHFS(n) (((n)&0x1UL)<<18)
95 #define VSENSE(n) (((n)&0x1UL)<<17)
96 #define TBL(n) (((n)&0x3UL)<<15)
97 #define CHM(n) (((n)&0x1UL)<<14)
98 #define RNDTF(n) (((n)&0x1)<<13)
99 #define DISFDCC(n) (((n)&0x1)<<12)
100 #define TFD3(n) (((n)&0x1)<<11)
101 #define HEND(n) (((n)&0xF)<<7)
102 #define HSTRT_TFD(n) (((n)&0x7)<<4)
103 #define TOFF(n) (((n)&0xF)<<0)
108 #define COOLCONF 0x6D
109 #define SFILT(n) (((n)&0x1UL)<<24)
110 #define SGT(n) (((n)&0x7FUL)<<16)
111 #define SEIMIN(n) (((n)&0x1UL)<<15)
112 #define SEDN(n) (((n)&0x3)<<13)
113 #define SEMAX(n) (((n)&0xF)<<8)
114 #define SEUP(n) (((n)&0x3)<<5)
115 #define SEMIN(n) (((n)&0xF)<<0)
119 #define DC_SG(n) (((n)&0xFFUL)<<16)
120 #define DC_TIME(n) (((n)&0x3FF)<<0)
122 #define DRV_STATUS 0x6F
124 #define IHOLDDELAY(n) (((n)&0xFUL)<<16)
125 #define IRUN(n) (((n)&0x1F)<<8)
126 #define IHOLD(n) (((n)&0x1F)<<0)
129 #define WRITE_ACCESS 0x80
133 #define POSITIONING_MODE 0x00
134 #define VELOCITY_MODE_POS 0x01
135 #define VELOCITY_MODE_NEG 0x02
136 #define HOLD_MODE 0x03
138 #define DRIVER_STOP 0
139 #define DRIVER_VELOCITY 1
140 #define DRIVER_POSITION 2
142 #define ACCELERATIONCONVERSION 1.0/116.415321827
143 #define VELOCITYCONVERSION 1.0/0.953674316
151 class uStepperDriver{
178 void setPosition( int32_t position );
188 void setVelocity( uint32_t velocity );
197 void setAcceleration( uint32_t acceleration );
206 void setDeceleration( uint32_t deceleration );
232 void setShaftDirection(
bool direction );
249 int32_t getVelocity(
void );
260 int32_t getPosition(
void );
267 void setHome(int32_t initialSteps = 0);
284 int32_t writeRegister( uint8_t address, uint32_t datagram );
297 int32_t readRegister( uint8_t address );
302 uint16_t getStallValue(
void );
305 volatile int32_t xTarget = 0;
308 volatile int32_t xActual = 0;
320 uint8_t current = 16;
321 uint8_t holdCurrent = 0;
322 uint8_t holdDelay = 0;
327 uint32_t VMAX = 200000;
340 void updateCurrent(
void );
347 void setRampMode( uint8_t
mode );
349 void setDirection(
bool direction );
353 void enableStealth(
void );
361 void readMotorStatus(
void);
Prototype of class for accessing all features of the uStepper S in a single object.
void chipSelect(uint8_t pin, bool state)
void enableStallguard(int8_t threshold=4, bool stopOnStall=false, float rpm=10.0)
Enable TMC5130 StallGuard.
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.