73 this->pointer = _pointer;
104 while(TCNT1 > 15900);
110 this->
VMAX = velocity;
112 if(this->
VMAX > 0x7FFE00)
114 this->
VMAX = 0x7FFE00;
122 this->
AMAX = acceleration;
124 if(this->
AMAX > 0xFFFE)
134 this->
DMAX = deceleration;
136 if(this->
DMAX > 0xFFFE)
175 value |= (0x01 << 4);
177 value &= ~(0x01 << 4);
241 if (value & 0x00800000)
268 this->xTarget =
xTarget + initialSteps;
269 this->xActual = initialSteps;
275 this->xTarget = initialSteps;
276 this->xActual = initialSteps;
288 TIMSK1 &= ~(1 << OCIE1A);
292 uint32_t
package = 0;
299 this->
status = this->pointer->
SPI(address);
301 package |= this->pointer->SPI((datagram >> 24) & 0xff);
303 package |= this->pointer->SPI((datagram >> 16) & 0xff);
305 package |= this->pointer->SPI((datagram >> 8) & 0xff);
307 package |= this->pointer->SPI((datagram) & 0xff);
312 TIMSK1 |= (1 << OCIE1A);
320 TIMSK1 &= ~(1 << OCIE1A);
327 this->
status = this->pointer->
SPI(address);
328 this->pointer->
SPI(0x00);
329 this->pointer->
SPI(0x00);
330 this->pointer->
SPI(0x00);
331 this->pointer->
SPI(0x00);
338 this->
status = this->pointer->
SPI(address);
339 value |= this->pointer->
SPI(0x00);
341 value |= this->pointer->
SPI(0x00);
343 value |= this->pointer->
SPI(0x00);
345 value |= this->pointer->
SPI(0x00);
349 TIMSK1 |= (1 << OCIE1A);
367 else if( threshold < -64)
386 stall_speed = stall_speed * 1.2;
void setAcceleration(uint32_t acceleration)
Set motor acceleration.
void setDirection(bool direction)
uint16_t getStallValue(void)
Returns the load measurement used for Stall detection.
void chipSelect(bool state)
void readMotorStatus(void)
void setDeceleration(uint32_t deceleration)
Set motor deceleration.
int32_t getPosition(void)
Returns the current position of the motor driver.
void disableStallguard(void)
void updateCurrent(void)
Writes the current setting registers of the motor driver
void setShaftDirection(bool direction)
Set motor driver direction.
uStepperDriver(void)
Constructor.
void stop(void)
Stops any ongoing movement with deceleration.
int32_t writeRegister(uint8_t address, uint32_t datagram)
Write a register of the motor driver.
void init(uStepperS *_pointer)
Initiation of the motor driver.
void setHoldCurrent(uint8_t current)
Set motor driver hold current.
void enableStallguard(int8_t threshold, bool stopOnStall, float rpm)
int32_t readRegister(uint8_t address)
Reads a register from the motor driver.
void setVelocity(uint32_t velocity)
Set motor velocity.
int32_t getVelocity(void)
Returns the current speed of the motor driver.
void setCurrent(uint8_t current)
Set motor driver current.
void setHome(int32_t initialSteps=0)
Resets the internal position counter of the motor driver.
void setRampMode(uint8_t mode)
Set motor driver to position mode or velocity mode.
void setPosition(int32_t position)
Set the motor position.
Prototype of class for accessing all features of the uStepper S in a single object.
volatile int32_t pidPositionStepsIssued
void setSPIMode(uint8_t mode)
uint8_t SPI(uint8_t data)
#define I_SCALE_ANALOG(n)
#define VELOCITY_MODE_NEG
#define VELOCITY_MODE_POS