39 #define DIRECTION(n) (((n)&0x1)<<4) 40 #define EN_PWM_MODE(n) (((n)&0x1)<<2) 41 #define I_SCALE_ANALOG(n) (((n)&0x1)<<0) 44 #define X_COMPARE 0x05 45 #define IHOLD_IRUN 0x10 46 #define TPOWERDOWN 0x11 48 #define TCOOLTHRS 0x14 55 #define VSTART_REG 0x23 62 #define VSTOP_REG 0x2B 63 #define TZEROWAIT 0x2C 67 #define RAMP_STAT 0x35 73 #define FREEWHEEL(n) (((n)&0x3UL)<<20) 74 #define PWM_AUTOSCALE(n) (((n)&0x1UL)<<18) 75 #define PWM_FREQ(n) (((n)&0x3UL)<<16) 76 #define PWM_GRAD(n) (((n)&0xFF)<<8) 77 #define PWM_AMPL(n) (((n)&0xFF)<<0) 84 #define DISS2G(n) (((n)&0x1UL)<<30) 85 #define DEDGE(n) (((n)&0x1UL)<<29) 86 #define INTPOL(n) (((n)&0x1UL)<<28) 87 #define MRES(n) (((n)&0xFUL)<<24) 88 #define SYNC(n) (((n)&0xFUL)<<20) 89 #define VHIGHCHM(n) (((n)&0x1UL)<<19) 90 #define VHIGHFS(n) (((n)&0x1UL)<<18) 91 #define VSENSE(n) (((n)&0x1UL)<<17) 92 #define TBL(n) (((n)&0x3UL)<<15) 93 #define CHM(n) (((n)&0x1UL)<<14) 94 #define RNDTF(n) (((n)&0x1)<<13) 95 #define DISFDCC(n) (((n)&0x1)<<12) 96 #define TFD3(n) (((n)&0x1)<<11) 97 #define HEND(n) (((n)&0xF)<<7) 98 #define HSTRT_TFD(n) (((n)&0x7)<<4) 99 #define TOFF(n) (((n)&0xF)<<0) 104 #define COOLCONF 0x6D 105 #define SFILT(n) (((n)&0x1UL)<<24) 106 #define SGT(n) (((n)&0x7FUL)<<16) 107 #define SEIMIN(n) (((n)&0x1UL)<<15) 108 #define SEDN(n) (((n)&0x3)<<13) 109 #define SEMAX(n) (((n)&0xF)<<8) 110 #define SEUP(n) (((n)&0x3)<<5) 111 #define SEMIN(n) (((n)&0xF)<<0) 115 #define DC_SG(n) (((n)&0xFFUL)<<16) 116 #define DC_TIME(n) (((n)&0x3FF)<<0) 118 #define DRV_STATUS 0x6F 120 #define IHOLDDELAY(n) (((n)&0xFUL)<<16) 121 #define IRUN(n) (((n)&0x1F)<<8) 122 #define IHOLD(n) (((n)&0x1F)<<0) 125 #define WRITE_ACCESS 0x80 129 #define POSITIONING_MODE 0x00 130 #define VELOCITY_MODE_POS 0x01 131 #define VELOCITY_MODE_NEG 0x02 132 #define HOLD_MODE 0x03 134 #define DRIVER_STOP 0 135 #define DRIVER_VELOCITY 1 136 #define DRIVER_POSITION 2 138 #define ACCELERATIONCONVERSION 1.0/116.415321827 139 #define VELOCITYCONVERSION 1.0/0.953674316 147 class uStepperDriver{ 174 void setPosition( int32_t position );
184 void setVelocity( uint32_t velocity );
193 void setAcceleration( uint32_t acceleration );
202 void setDeceleration( uint32_t deceleration );
228 void setShaftDirection(
bool direction );
245 int32_t getVelocity(
void );
256 int32_t getPosition(
void );
276 int32_t writeRegister( uint8_t address, uint32_t datagram );
289 int32_t readRegister( uint8_t address );
292 volatile int32_t xTarget = 0;
304 uint8_t current = 16;
305 uint8_t holdCurrent = 10;
306 uint8_t holdDelay = 0;
311 uint32_t VMAX = 200000;
318 void chipSelect(
bool state);
323 void updateCurrent(
void );
330 void setRampMode( uint8_t
mode );
332 void setDirection(
bool direction );
336 void enableStealth(
void);
338 void readMotorStatus(
void);
Prototype of class for accessing all features of the uStepper S in a single object.
void setHoldCurrent(double current)
Set motor hold current.
Prototype of class for the TMC5130 Driver.
void stop(bool mode=HARD)
Stop the motor.
void init(void)
Internal function to prepare the uStepperS in the constructor.
Function prototypes and definitions for the uStepper S library.
void setCurrent(double current)
Set motor output current.